Skip to content

Commit ed030a7

Browse files
authored
fixes #5202 -- treat the PYO3_BUILD_EXTENSION_MODULE env var the same as teh extension-module feature (#5343)
1 parent 1775baf commit ed030a7

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

newsfragments/5343.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
When building pyo3, setting the `PYO3_BUILD_EXTENSION_MODULE` causes the same effect as the `extension-module` feature. Eventually we expect maturin and setuptools-rust to set this environment variable automatically. Users with their own build systems will need to do the same.

pyo3-build-config/src/impl_.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,9 +862,14 @@ pub fn get_abi3_version() -> Option<PythonVersion> {
862862

863863
/// Checks if the `extension-module` feature is enabled for the PyO3 crate.
864864
///
865+
/// This can be triggered either by:
866+
/// - The `extension-module` Cargo feature
867+
/// - Setting the `PYO3_BUILD_EXTENSION_MODULE` environment variable
868+
///
865869
/// Must be called from a PyO3 crate build script.
866870
pub fn is_extension_module() -> bool {
867871
cargo_env_var("CARGO_FEATURE_EXTENSION_MODULE").is_some()
872+
|| env_var("PYO3_BUILD_EXTENSION_MODULE").is_some()
868873
}
869874

870875
/// Checks if we need to link to `libpython` for the current build target.

pytests/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ publish = false
88
rust-version = "1.74"
99

1010
[dependencies]
11-
pyo3 = { path = "../", features = ["extension-module", "experimental-inspect"] }
11+
pyo3 = { path = "../", features = ["experimental-inspect"] }
1212

1313
[build-dependencies]
1414
pyo3-build-config = { path = "../pyo3-build-config" }

pytests/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["maturin>=1,<2"]
2+
requires = ["maturin>=1.9.4,<2"]
33
build-backend = "maturin"
44

55
[tool.pytest.ini_options]

0 commit comments

Comments
 (0)