Skip to content

Commit d0a546b

Browse files
committed
Support ARCHFLAGS
1 parent e76c920 commit d0a546b

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

setup.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import re
23
import sys
34
import subprocess
45
from pathlib import Path
@@ -28,6 +29,12 @@ def build_extension(self, ext: CMakeExtension) -> None:
2829

2930
build_args = ["--config", "Release"]
3031

32+
# On macOS, respect ARCHFLAGS for cross-compilation (e.g. x86_64 on arm64)
33+
archflags = os.environ.get("ARCHFLAGS", "")
34+
archs = re.findall(r"-arch (\S+)", archflags)
35+
if archs:
36+
cmake_args.append(f"-DCMAKE_OSX_ARCHITECTURES={';'.join(archs)}")
37+
3138
# On Windows, use Ninja if no generator is specified to avoid
3239
# Visual Studio multi-config generator issues with pybind11
3340
if sys.platform == "win32" and not cmake_generator:

0 commit comments

Comments
 (0)