From dce589f81c35f877d5fade59d4cac455fdba83ce Mon Sep 17 00:00:00 2001 From: Dsssyc Date: Mon, 15 Dec 2025 14:31:09 +0800 Subject: [PATCH] feat: Add macOS architecture flags support in CMake build for cibuildwheel compatibility --- setup.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/setup.py b/setup.py index 773e187..38fb520 100644 --- a/setup.py +++ b/setup.py @@ -31,6 +31,18 @@ def build_extension(self, ext): '-DBUILD_TOOLS=OFF', ] + if sys.platform == 'darwin': + # Handle macOS architecture flags set by cibuildwheel (e.g. ARCHFLAGS="-arch x86_64") + archflags = os.environ.get("ARCHFLAGS", "") + if archflags: + archs = [] + if "arm64" in archflags: + archs.append("arm64") + if "x86_64" in archflags: + archs.append("x86_64") + if archs: + cmake_args.append(f'-DCMAKE_OSX_ARCHITECTURES={";".join(archs)}') + # Limit parallel jobs to avoid OOM on Docker with limited memory # Default to 4 or CPU count, whichever is smaller, to be safe import multiprocessing