Skip to content

Commit d92876b

Browse files
alexdavidhewitt
andauthored
Set PYO3_BUILD_EXTENSION_MODULE env var when building pyo3 extension … (#540)
* Set PYO3_BUILD_EXTENSION_MODULE env var when building pyo3 extension modules See PyO3/pyo3#5202 for context * add `CHANGELOG` entry * release: 1.12.0 --------- Co-authored-by: David Hewitt <[email protected]>
1 parent 9847bdf commit d92876b

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[bumpversion]
22
commit = True
33
tag = False
4-
current_version = 1.11.1
4+
current_version = 1.12.0
55
message = release: {new_version}
66

77
[bumpversion:file:pyproject.toml]

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 1.12.0 (2025-08-29)
4+
- Set `PYO3_BUILD_EXTENSION_MODULE` environment variable when building PyO3 extensions. [#540](https://github.com/PyO3/setuptools-rust/pull/540)
5+
36
## 1.11.1 (2025-04-04)
47
### Fixed
58
- Fix finding cargo artifacts when filenames are empty. [#521](https://github.com/PyO3/setuptools-rust/pull/521)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "setuptools-rust"
3-
version = "1.11.1"
3+
version = "1.12.0"
44
description = "Setuptools Rust extension plugin"
55
readme = "README.md"
66
requires-python = ">=3.9"

setuptools_rust/build.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def build_extension(
147147
target_triple = self._detect_rust_target(forced_target_triple, ext.env)
148148
rustc_cfgs = get_rustc_cfgs(target_triple, ext.env)
149149

150-
env = _prepare_build_environment(ext.env)
150+
env = _prepare_build_environment(ext.env, ext)
151151

152152
if not os.path.exists(ext.path):
153153
raise FileError(
@@ -609,7 +609,7 @@ def _replace_vendor_with_unknown(target: str) -> Optional[str]:
609609
return "-".join(components)
610610

611611

612-
def _prepare_build_environment(env: Env) -> Dict[str, str]:
612+
def _prepare_build_environment(env: Env, ext: RustExtension) -> Dict[str, str]:
613613
"""Prepares environment variables to use when executing cargo build."""
614614

615615
base_executable = None
@@ -636,6 +636,10 @@ def _prepare_build_environment(env: Env) -> Dict[str, str]:
636636
"PYO3_PYTHON": env_vars.get("PYO3_PYTHON", executable),
637637
}
638638
)
639+
640+
if ext.binding == Binding.PyO3:
641+
env_vars.setdefault("PYO3_BUILD_EXTENSION_MODULE", "1")
642+
639643
return env_vars
640644

641645

setuptools_rust/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = version = "1.11.1"
1+
__version__ = version = "1.12.0"
22
__version_tuple__ = version_tuple = tuple(
33
map(lambda x: int(x[1]) if x[0] < 3 else x[1], enumerate(__version__.split(".")))
44
)

0 commit comments

Comments
 (0)