Skip to content

Commit 060d8b4

Browse files
committed
Use target CARGO_BUILD_TARGET if specified
rust will pick up the environment variable anyway, but if we don't pick up on it, too, then we won't find the build artifacts.
1 parent 48ab782 commit 060d8b4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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)