From c1957c0a14afedf7e1408abb1776e6349c5395d6 Mon Sep 17 00:00:00 2001 From: messense Date: Tue, 9 Apr 2024 19:07:43 +0800 Subject: [PATCH] Remove rust-cpython from project init/new template --- guide/src/distribution.md | 13 ++++--------- guide/src/local_development.md | 6 ++++-- src/new_project.rs | 6 +++--- src/templates/Cargo.toml.j2 | 2 -- src/templates/lib.rs.j2 | 7 ------- src/templates/pyproject.toml.j2 | 4 +--- test-crates/update_readme.py | 2 +- tests/cmd/init.stdout | 4 ++-- tests/cmd/new.stdout | 4 ++-- 9 files changed, 17 insertions(+), 31 deletions(-) diff --git a/guide/src/distribution.md b/guide/src/distribution.md index 0bcfa9b5c..c4073728d 100644 --- a/guide/src/distribution.md +++ b/guide/src/distribution.md @@ -86,20 +86,16 @@ Options: --compatibility [...] Control the platform tag on linux. - Options are `manylinux` tags (for example `manylinux2014`/`manylinux_2_24`) or `musllinux` - tags (for example `musllinux_1_2`) and `linux` for the native linux tag. + Options are `manylinux` tags (for example `manylinux2014`/`manylinux_2_24`) or `musllinux` tags (for example `musllinux_1_2`) and `linux` for the native linux tag. - Note that `manylinux1` and `manylinux2010` is unsupported by the rust compiler. Wheels - with the native `linux` tag will be rejected by pypi, unless they are separately validated - by `auditwheel`. + Note that `manylinux1` and `manylinux2010` is unsupported by the rust compiler. Wheels with the native `linux` tag will be rejected by pypi, unless they are separately validated by `auditwheel`. The default is the lowest compatible `manylinux` tag, or plain `linux` if nothing matched This option is ignored on all non-linux platforms -i, --interpreter [...] - The python versions to build wheels for, given as the executables of interpreters such as - `python3.9` or `/usr/bin/python3.8` + The python versions to build wheels for, given as the executables of interpreters such as `python3.9` or `/usr/bin/python3.8` -f, --find-interpreter Find interpreters from the host machine @@ -110,8 +106,7 @@ Options: [possible values: pyo3, pyo3-ffi, rust-cpython, cffi, uniffi, bin] -o, --out - The directory to store the built wheels in. Defaults to a new "wheels" directory in the - project's target directory + The directory to store the built wheels in. Defaults to a new "wheels" directory in the project's target directory --skip-auditwheel Don't check for manylinux compliance diff --git a/guide/src/local_development.md b/guide/src/local_development.md index 54dd4a1a5..4d1506c02 100644 --- a/guide/src/local_development.md +++ b/guide/src/local_development.md @@ -34,8 +34,7 @@ Options: --pip-path Use a specific pip installation instead of the default one. - This can be used to supply the path to a pip executable when the current virtualenv does - not provide one. + This can be used to supply the path to a pip executable when the current virtualenv does not provide one. -q, --quiet Do not print cargo log messages @@ -58,6 +57,9 @@ Options: --future-incompat-report Outputs a future incompatibility report at the end of the build (unstable) + --uv + Use `uv` to install packages instead of `pip` + -h, --help Print help (see a summary with '-h') diff --git a/src/new_project.rs b/src/new_project.rs index e8eeeb0df..fdc62ec1e 100644 --- a/src/new_project.rs +++ b/src/new_project.rs @@ -171,7 +171,7 @@ pub struct GenerateProjectOptions { #[arg( short, long, - value_parser = ["pyo3", "rust-cpython", "cffi", "uniffi", "bin"] + value_parser = ["pyo3", "cffi", "uniffi", "bin"] )] bindings: Option, } @@ -229,9 +229,9 @@ fn generate_project( validate_name(temp.as_str()).map_err(|e| anyhow::anyhow!(e))? }; let bindings_items = if options.mixed { - vec!["pyo3", "rust-cpython", "cffi", "uniffi"] + vec!["pyo3", "cffi", "uniffi"] } else { - vec!["pyo3", "rust-cpython", "cffi", "uniffi", "bin"] + vec!["pyo3", "cffi", "uniffi", "bin"] }; let bindings = if let Some(bindings) = options.bindings { bindings diff --git a/src/templates/Cargo.toml.j2 b/src/templates/Cargo.toml.j2 index 59a45ff73..e2d5dba4f 100644 --- a/src/templates/Cargo.toml.j2 +++ b/src/templates/Cargo.toml.j2 @@ -13,8 +13,6 @@ crate-type = ["cdylib"] [dependencies] {% if bindings == "pyo3" -%} pyo3 = "0.21.1" -{% elif bindings == "rust-cpython" -%} -cpython = "0.7.1" {% elif bindings == "uniffi" -%} uniffi = "0.27.0" diff --git a/src/templates/lib.rs.j2 b/src/templates/lib.rs.j2 index 02d2c3c65..4a28d6255 100644 --- a/src/templates/lib.rs.j2 +++ b/src/templates/lib.rs.j2 @@ -13,13 +13,6 @@ fn {{crate_name}}(m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_function(wrap_pyfunction!(sum_as_string, m)?)?; Ok(()) } -{%- elif bindings == "rust-cpython" -%} -use cpython::py_module_initializer; - -py_module_initializer!({{crate_name}}, |py, m| { - m.add(py, "__doc__", "Module documentation string")?; - Ok(()) -}); {%- elif bindings == "uniffi" -%} fn add(a: u32, b: u32) -> u32 { a + b diff --git a/src/templates/pyproject.toml.j2 b/src/templates/pyproject.toml.j2 index 5ab63e647..c5f578f00 100644 --- a/src/templates/pyproject.toml.j2 +++ b/src/templates/pyproject.toml.j2 @@ -21,7 +21,7 @@ tests = [ ] {% endif -%} -{% if bindings in ["bin", "cffi", "pyo3", "rust-cpython"] or mixed_non_src -%} +{% if bindings in ["bin", "cffi", "pyo3"] or mixed_non_src -%} [tool.maturin] {% if bindings == "cffi" or bindings == "bin" -%} bindings = "{{ bindings }}" @@ -31,7 +31,5 @@ python-source = "python" {% endif -%} {% if bindings == "pyo3" -%} features = ["pyo3/extension-module"] -{% elif bindings == "rust-cpython" -%} -features = ["cpython/extension-module"] {% endif -%} {% endif -%} diff --git a/test-crates/update_readme.py b/test-crates/update_readme.py index faa583c85..9380f0c15 100644 --- a/test-crates/update_readme.py +++ b/test-crates/update_readme.py @@ -6,7 +6,7 @@ FILES = [ "README.md", - "guide/src/develop.md", + "guide/src/local_development.md", "guide/src/tutorial.md", "guide/src/distribution.md", ] diff --git a/tests/cmd/init.stdout b/tests/cmd/init.stdout index 023b3d7ac..460d47951 100644 --- a/tests/cmd/init.stdout +++ b/tests/cmd/init.stdout @@ -9,6 +9,6 @@ Options: --name Set the resulting package name, defaults to the directory name --mixed Use mixed Rust/Python project layout --src Use Python first src layout for mixed Rust/Python project - -b, --bindings Which kind of bindings to use [possible values: pyo3, rust-cpython, - cffi, uniffi, bin] + -b, --bindings Which kind of bindings to use [possible values: pyo3, cffi, uniffi, + bin] -h, --help Print help diff --git a/tests/cmd/new.stdout b/tests/cmd/new.stdout index 9f8f2ad08..0f7a733c1 100644 --- a/tests/cmd/new.stdout +++ b/tests/cmd/new.stdout @@ -9,6 +9,6 @@ Options: --name Set the resulting package name, defaults to the directory name --mixed Use mixed Rust/Python project layout --src Use Python first src layout for mixed Rust/Python project - -b, --bindings Which kind of bindings to use [possible values: pyo3, rust-cpython, - cffi, uniffi, bin] + -b, --bindings Which kind of bindings to use [possible values: pyo3, cffi, uniffi, + bin] -h, --help Print help