From d3d18e23760cad741ce41a528f024570df8d9529 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Mon, 6 Jul 2026 09:41:13 -0700 Subject: [PATCH] setup.py: honor CMAKE_GENERATOR_PLATFORM for the Windows -A flag The Windows build hardcoded the Visual Studio target architecture to x64 for any 64-bit interpreter (`if sys.maxsize > 2**32: -A x64`). On win-arm64 the interpreter is 64-bit but the architecture is ARM, so this mis-targeted the build and find_package(Python) then failed. Honor an explicit CMAKE_GENERATOR_PLATFORM (e.g. "ARM64") from the environment, falling back to the previous behavior otherwise. --- setup.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 9f349b5564..80cfa5e475 100644 --- a/setup.py +++ b/setup.py @@ -167,7 +167,10 @@ def build_extension(self, ext): cfg.upper(), os.path.join(extdir, "impactx") ), ] - if sys.maxsize > 2**32: + generator_platform = os.environ.get("CMAKE_GENERATOR_PLATFORM") + if generator_platform: + cmake_args += ["-A", generator_platform] + elif sys.maxsize > 2**32: cmake_args += ["-A", "x64"] else: cmake_args += ["-DCMAKE_BUILD_TYPE=" + cfg]