diff --git a/CHANGELOG.md b/CHANGELOG.md index 04fb8611..e8268c73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Unreleased + + - Respect `CARGO_BUILD_TARGET` environment variable if set. [#90](https://github.com/PyO3/setuptools-rust/pull/90) + ## 0.11.5 (2020-11-10) - Fix support for Python 3.5. [#86](https://github.com/PyO3/setuptools-rust/pull/86) diff --git a/setuptools_rust/build.py b/setuptools_rust/build.py index 907fb609..e4528232 100644 --- a/setuptools_rust/build.py +++ b/setuptools_rust/build.py @@ -92,10 +92,14 @@ def build_extension(self, ext): # If we are on a 64-bit machine, but running a 32-bit Python, then # we'll target a 32-bit Rust build. + # Automatic target detection can be overridden via the CARGO_BUILD_TARGET + # environment variable. # TODO: include --target for all platforms so env vars can't break the build target_triple = None target_args = [] - if self.plat_name == "win32": + if os.getenv("CARGO_BUILD_TARGET"): + target_triple = os.environ["CARGO_BUILD_TARGET"] + elif self.plat_name == "win32": target_triple = "i686-pc-windows-msvc" elif self.plat_name == "win-amd64": target_triple = "x86_64-pc-windows-msvc"