diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 40da845d..c017edbe 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,7 +1,7 @@ [bumpversion] commit = True tag = False -current_version = 1.11.1 +current_version = 1.12.0 message = release: {new_version} [bumpversion:file:pyproject.toml] diff --git a/CHANGELOG.md b/CHANGELOG.md index 09c3382b..4c65c251 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 1.12.0 (2025-08-29) +- Set `PYO3_BUILD_EXTENSION_MODULE` environment variable when building PyO3 extensions. [#540](https://github.com/PyO3/setuptools-rust/pull/540) + ## 1.11.1 (2025-04-04) ### Fixed - Fix finding cargo artifacts when filenames are empty. [#521](https://github.com/PyO3/setuptools-rust/pull/521) diff --git a/pyproject.toml b/pyproject.toml index c0d4a971..79be14ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "setuptools-rust" -version = "1.11.1" +version = "1.12.0" description = "Setuptools Rust extension plugin" readme = "README.md" requires-python = ">=3.9" diff --git a/setuptools_rust/build.py b/setuptools_rust/build.py index 4f6d2932..0462564b 100644 --- a/setuptools_rust/build.py +++ b/setuptools_rust/build.py @@ -147,7 +147,7 @@ def build_extension( target_triple = self._detect_rust_target(forced_target_triple, ext.env) rustc_cfgs = get_rustc_cfgs(target_triple, ext.env) - env = _prepare_build_environment(ext.env) + env = _prepare_build_environment(ext.env, ext) if not os.path.exists(ext.path): raise FileError( @@ -609,7 +609,7 @@ def _replace_vendor_with_unknown(target: str) -> Optional[str]: return "-".join(components) -def _prepare_build_environment(env: Env) -> Dict[str, str]: +def _prepare_build_environment(env: Env, ext: RustExtension) -> Dict[str, str]: """Prepares environment variables to use when executing cargo build.""" base_executable = None @@ -636,6 +636,10 @@ def _prepare_build_environment(env: Env) -> Dict[str, str]: "PYO3_PYTHON": env_vars.get("PYO3_PYTHON", executable), } ) + + if ext.binding == Binding.PyO3: + env_vars.setdefault("PYO3_BUILD_EXTENSION_MODULE", "1") + return env_vars diff --git a/setuptools_rust/version.py b/setuptools_rust/version.py index 1229fa4e..7f2ff1f3 100644 --- a/setuptools_rust/version.py +++ b/setuptools_rust/version.py @@ -1,4 +1,4 @@ -__version__ = version = "1.11.1" +__version__ = version = "1.12.0" __version_tuple__ = version_tuple = tuple( map(lambda x: int(x[1]) if x[0] < 3 else x[1], enumerate(__version__.split("."))) )