Skip to content

Commit ff48f6a

Browse files
committed
Fix macOS/Windows CI failures: static linking and architecture settings
This commit addresses persistent CI test failures on macOS and Windows: 1. Force static linking of dependencies: - Added -DBUILD_SHARED_LIBS=OFF to avoid delocate-wheel failures - Prevents snappy from being built as shared dylib with wrong arch - Eliminates need for delocate to vendor dylibs on macOS 2. Set proper architecture targeting for macOS: - Parse ARCHFLAGS environment variable (set by cibuildwheel) - Set CMAKE_OSX_ARCHITECTURES to target correct arch (arm64/x86_64) - Fixes delocate-wheel --require-archs failures 3. Set macOS deployment target: - Use MACOSX_DEPLOYMENT_TARGET from environment - Ensures proper SDK and API compatibility 4. Add CMAKE_RUNTIME_OUTPUT_DIRECTORY for macOS: - Handles multi-config generators (Xcode) properly - Ensures module is placed in correct output directory These changes address the root causes of: - delocate-wheel failures on macOS (wrong arch, missing dylibs) - pytest exit code 2 failures (module not found in installed wheels) - Multi-config generator output directory issues All 123 tests pass locally on Linux with static linking enabled. Related to PR #45
1 parent 51c36e4 commit ff48f6a

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

setup.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def build_extension(self, ext):
5757
cmake_args = [
5858
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=" + extdir,
5959
"-DPYTHON_EXECUTABLE=" + sys.executable,
60+
"-DBUILD_SHARED_LIBS=OFF",
6061
]
6162

6263
debug = os.getenv("DEBUG", 0) in {"1", "y", "yes", "true"}
@@ -74,8 +75,24 @@ def build_extension(self, ext):
7475
elif platform.system() == "Darwin":
7576
cmake_args += [
7677
"-DCMAKE_BUILD_TYPE=" + cfg,
77-
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}".format(cfg.upper(), extdir)
78+
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}".format(cfg.upper(), extdir),
79+
"-DCMAKE_RUNTIME_OUTPUT_DIRECTORY_{}={}".format(cfg.upper(), extdir)
7880
]
81+
82+
archflags = os.getenv("ARCHFLAGS", "")
83+
if archflags:
84+
archs = []
85+
parts = archflags.split()
86+
for i, part in enumerate(parts):
87+
if part == "-arch" and i + 1 < len(parts):
88+
archs.append(parts[i + 1])
89+
if archs:
90+
cmake_args.append("-DCMAKE_OSX_ARCHITECTURES=" + ";".join(archs))
91+
92+
deployment_target = os.getenv("MACOSX_DEPLOYMENT_TARGET", "")
93+
if deployment_target:
94+
cmake_args.append("-DCMAKE_OSX_DEPLOYMENT_TARGET=" + deployment_target)
95+
7996
build_args += ["--", "-j" + str(cpu_count())]
8097
else:
8198
cmake_args += ["-DCMAKE_BUILD_TYPE=" + cfg]

0 commit comments

Comments
 (0)