diff --git a/templates/mixed/.gitignore b/templates/.gitignore similarity index 100% rename from templates/mixed/.gitignore rename to templates/.gitignore diff --git a/templates/mixed/Cargo.toml b/templates/Cargo.toml similarity index 100% rename from templates/mixed/Cargo.toml rename to templates/Cargo.toml diff --git a/templates/pure-rust/cargo-generate.toml b/templates/cargo-generate.toml similarity index 59% rename from templates/pure-rust/cargo-generate.toml rename to templates/cargo-generate.toml index a97dcdc26..22d00065d 100644 --- a/templates/pure-rust/cargo-generate.toml +++ b/templates/cargo-generate.toml @@ -1,9 +1,17 @@ +[placeholders.mixed_layout] +type = "bool" +prompt = "Use mixed Rust/Python project layout?" +default = false + [placeholders.binding] type = "string" prompt = "What binding to use?" choices = ["pyo3", "rust-cpython", "cffi", "bin"] default = "pyo3" +[conditional.'mixed_layout != true'] +ignore = [ "{{crate_name}}/" ] + [conditional.'binding != "bin"'] ignore = [ "src/main.rs" ] diff --git a/templates/mixed/cargo-generate.toml b/templates/mixed/cargo-generate.toml deleted file mode 100644 index daaf646db..000000000 --- a/templates/mixed/cargo-generate.toml +++ /dev/null @@ -1,5 +0,0 @@ -[placeholders.binding] -type = "string" -prompt = "What binding to use?" -choices = ["pyo3", "rust-cpython", "cffi"] -default = "pyo3" diff --git a/templates/pure-rust/.gitignore b/templates/pure-rust/.gitignore deleted file mode 100644 index c8f044299..000000000 --- a/templates/pure-rust/.gitignore +++ /dev/null @@ -1,72 +0,0 @@ -/target - -# Byte-compiled / optimized / DLL files -__pycache__/ -.pytest_cache/ -*.py[cod] - -# C extensions -*.so - -# Distribution / packaging -.Python -.venv/ -env/ -bin/ -build/ -develop-eggs/ -dist/ -eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -include/ -man/ -venv/ -*.egg-info/ -.installed.cfg -*.egg - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt -pip-selfcheck.json - -# Unit test / coverage reports -htmlcov/ -.tox/ -.coverage -.cache -nosetests.xml -coverage.xml - -# Translations -*.mo - -# Mr Developer -.mr.developer.cfg -.project -.pydevproject - -# Rope -.ropeproject - -# Django stuff: -*.log -*.pot - -.DS_Store - -# Sphinx documentation -docs/_build/ - -# PyCharm -.idea/ - -# VSCode -.vscode/ - -# Pyenv -.python-version diff --git a/templates/pure-rust/Cargo.toml b/templates/pure-rust/Cargo.toml deleted file mode 100644 index c977fdf2d..000000000 --- a/templates/pure-rust/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "{{project-name}}" -version = "0.1.0" -edition = "2018" -description = "{{description}}" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[lib] -name = "{{crate_name}}" -crate-type = ["cdylib"] - -[dependencies] -{% case binding -%} -{%- when "pyo3" -%} -pyo3 = { version = "0.15.1", features = ["extension-module"] } -{%- when "rust-cpython" -%} -cpython = { version = "0.7.0", features = ["extension-module"] } -{%- else -%} -{%- endcase %} diff --git a/templates/pure-rust/pyproject.toml b/templates/pure-rust/pyproject.toml deleted file mode 100644 index 397439554..000000000 --- a/templates/pure-rust/pyproject.toml +++ /dev/null @@ -1,17 +0,0 @@ -[build-system] -requires = ["maturin>=0.12,<0.13"] -build-backend = "maturin" - -[project] -name = "{{project-name}}" -requires-python = ">=3.6" -classifiers = [ - "Programming Language :: Rust", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy", -] -{% if binding == "cffi" -%} -dependencies = ["cffi"] -{%- endif %} -[tool.maturin] -bindings = "{{binding}}" diff --git a/templates/pure-rust/src/lib.rs b/templates/pure-rust/src/lib.rs deleted file mode 100644 index 777ef9dac..000000000 --- a/templates/pure-rust/src/lib.rs +++ /dev/null @@ -1,17 +0,0 @@ -{%- case binding -%} -{%- when "pyo3" -%} -use pyo3::prelude::*; - -#[pymodule] -fn {{crate_name}}(_py: Python, m: &PyModule) -> PyResult<()> { - Ok(()) -} -{%- when "rust-cpython" -%} -use cpython::py_module_initializer; - -py_module_initializer!({{crate_name}}, |py, m| { - m.add(py, "__doc__", "Module documentation string")?; - Ok(()) -}); -{%- else -%} -{% endcase %} diff --git a/templates/mixed/pyproject.toml b/templates/pyproject.toml similarity index 100% rename from templates/mixed/pyproject.toml rename to templates/pyproject.toml diff --git a/templates/mixed/src/lib.rs b/templates/src/lib.rs similarity index 100% rename from templates/mixed/src/lib.rs rename to templates/src/lib.rs diff --git a/templates/pure-rust/src/main.rs b/templates/src/main.rs similarity index 100% rename from templates/pure-rust/src/main.rs rename to templates/src/main.rs diff --git a/templates/mixed/{{crate_name}}/__init__.py b/templates/{{crate_name}}/__init__.py similarity index 100% rename from templates/mixed/{{crate_name}}/__init__.py rename to templates/{{crate_name}}/__init__.py