Skip to content

Commit 702e5ca

Browse files
committed
fixes #5202 -- treat the PYO3_BUILD_EXTENSION_MODULE env var the same as teh extension-module feature
1 parent 12a1792 commit 702e5ca

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
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.

0 commit comments

Comments
 (0)