Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions crates/uv/src/commands/project/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ fn pyproject_build_backend_prerequisites(
[package]
name = "{module_name}"
version = "0.1.0"
edition = "2021"
edition = "2024"

[lib]
name = "_core"
Expand All @@ -1085,7 +1085,7 @@ fn pyproject_build_backend_prerequisites(
[dependencies]
# "extension-module" tells pyo3 we want to build an extension module (skips linking against libpython.so)
# "abi3-py39" tells pyo3 (and maturin) to build using the stable ABI with minimum Python version 3.9
pyo3 = {{ version = "0.22.4", features = ["extension-module", "abi3-py39"] }}
pyo3 = {{ version = "0.27.1", features = ["extension-module", "abi3-py39"] }}
"#},
)?;
}
Expand Down Expand Up @@ -1174,18 +1174,17 @@ fn generate_package_scripts(
indoc::formatdoc! {r#"
use pyo3::prelude::*;

#[pyfunction]
fn hello_from_bin() -> String {{
"Hello from {package}!".to_string()
}}

/// A Python module implemented in Rust. The name of this function must match
/// A Python module implemented in Rust. The name of this module must match
/// the `lib.name` setting in the `Cargo.toml`, else Python will not be able to
/// import the module.
#[pymodule]
fn _core(m: &Bound<'_, PyModule>) -> PyResult<()> {{
m.add_function(wrap_pyfunction!(hello_from_bin, m)?)?;
Ok(())
mod _core {{
use pyo3::prelude::*;

#[pyfunction]
fn hello_from_bin() -> String {{
"Hello from {package}!".to_string()
}}
}}
"#},
)?;
Expand Down
42 changes: 20 additions & 22 deletions crates/uv/tests/it/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3366,18 +3366,17 @@ fn init_app_build_backend_maturin() -> Result<()> {
lib_core_contents, @r###"
use pyo3::prelude::*;

#[pyfunction]
fn hello_from_bin() -> String {
"Hello from foo!".to_string()
}

/// A Python module implemented in Rust. The name of this function must match
/// A Python module implemented in Rust. The name of this module must match
/// the `lib.name` setting in the `Cargo.toml`, else Python will not be able to
/// import the module.
#[pymodule]
fn _core(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_function(wrap_pyfunction!(hello_from_bin, m)?)?;
Ok(())
mod _core {
use pyo3::prelude::*;

#[pyfunction]
fn hello_from_bin() -> String {
"Hello from foo!".to_string()
}
}
"###
);
Expand All @@ -3392,7 +3391,7 @@ fn init_app_build_backend_maturin() -> Result<()> {
[package]
name = "foo"
version = "0.1.0"
edition = "2021"
edition = "2024"

[lib]
name = "_core"
Expand All @@ -3402,7 +3401,7 @@ fn init_app_build_backend_maturin() -> Result<()> {
[dependencies]
# "extension-module" tells pyo3 we want to build an extension module (skips linking against libpython.so)
# "abi3-py39" tells pyo3 (and maturin) to build using the stable ABI with minimum Python version 3.9
pyo3 = { version = "0.22.4", features = ["extension-module", "abi3-py39"] }
pyo3 = { version = "0.27.1", features = ["extension-module", "abi3-py39"] }
"###
);
});
Expand Down Expand Up @@ -3623,18 +3622,17 @@ fn init_lib_build_backend_maturin() -> Result<()> {
lib_core_contents, @r###"
use pyo3::prelude::*;

#[pyfunction]
fn hello_from_bin() -> String {
"Hello from foo!".to_string()
}

/// A Python module implemented in Rust. The name of this function must match
/// A Python module implemented in Rust. The name of this module must match
/// the `lib.name` setting in the `Cargo.toml`, else Python will not be able to
/// import the module.
#[pymodule]
fn _core(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_function(wrap_pyfunction!(hello_from_bin, m)?)?;
Ok(())
mod _core {
use pyo3::prelude::*;

#[pyfunction]
fn hello_from_bin() -> String {
"Hello from foo!".to_string()
}
}
"###
);
Expand All @@ -3649,7 +3647,7 @@ fn init_lib_build_backend_maturin() -> Result<()> {
[package]
name = "foo"
version = "0.1.0"
edition = "2021"
edition = "2024"

[lib]
name = "_core"
Expand All @@ -3659,7 +3657,7 @@ fn init_lib_build_backend_maturin() -> Result<()> {
[dependencies]
# "extension-module" tells pyo3 we want to build an extension module (skips linking against libpython.so)
# "abi3-py39" tells pyo3 (and maturin) to build using the stable ABI with minimum Python version 3.9
pyo3 = { version = "0.22.4", features = ["extension-module", "abi3-py39"] }
pyo3 = { version = "0.27.1", features = ["extension-module", "abi3-py39"] }
"###
);
});
Expand Down
Loading