Skip to content

Commit b21ea50

Browse files
authored
Merge pull request #90 from Anthchirp/cargo_build_target
Use target CARGO_BUILD_TARGET if specified
2 parents 48ab782 + 3cd83ec commit b21ea50

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CHANGELOG.md

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

3+
## Unreleased
4+
5+
- Respect `CARGO_BUILD_TARGET` environment variable if set. [#90](https://github.com/PyO3/setuptools-rust/pull/90)
6+
37
## 0.11.5 (2020-11-10)
48

59
- Fix support for Python 3.5. [#86](https://github.com/PyO3/setuptools-rust/pull/86)

setuptools_rust/build.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,14 @@ def build_extension(self, ext):
9292

9393
# If we are on a 64-bit machine, but running a 32-bit Python, then
9494
# we'll target a 32-bit Rust build.
95+
# Automatic target detection can be overridden via the CARGO_BUILD_TARGET
96+
# environment variable.
9597
# TODO: include --target for all platforms so env vars can't break the build
9698
target_triple = None
9799
target_args = []
98-
if self.plat_name == "win32":
100+
if os.getenv("CARGO_BUILD_TARGET"):
101+
target_triple = os.environ["CARGO_BUILD_TARGET"]
102+
elif self.plat_name == "win32":
99103
target_triple = "i686-pc-windows-msvc"
100104
elif self.plat_name == "win-amd64":
101105
target_triple = "x86_64-pc-windows-msvc"

0 commit comments

Comments
 (0)