Skip to content

Commit e55dc11

Browse files
committed
Fix build of universal2 wheels
When building universal2 wheels, we need to set the architectures for CMake. This was not detected properly before.
1 parent b6d87cd commit e55dc11

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

setup.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@
44
# https://github.com/pybind/cmake_example
55

66
import os
7-
import platform
87
from pathlib import Path
9-
import re
108
import subprocess
119
import sys
1210
from pathlib import Path
1311

14-
import setuptools
1512
from setuptools import Extension, setup
1613
from setuptools.command.build_ext import build_ext
1714

@@ -104,11 +101,9 @@ def build_extension(self, ext: CMakeExtension) -> None:
104101
]
105102
build_args += ["--config", cfg]
106103

107-
if sys.platform.startswith("darwin"):
108-
# Cross-compile support for macOS - respect ARCHFLAGS if set
109-
archs = re.findall(r"-arch (\S+)", os.environ.get("ARCHFLAGS", ""))
110-
if archs:
111-
cmake_args += ["-DCMAKE_OSX_ARCHITECTURES={}".format(";".join(archs))]
104+
# When building universal2 wheels, we need to set the architectures for CMake.
105+
if "universal2" in self.plat_name:
106+
cmake_args += ["-DCMAKE_OSX_ARCHITECTURES=arm64;x86_64"]
112107

113108
# Set CMAKE_BUILD_PARALLEL_LEVEL to control the parallel build level
114109
# across all generators.

0 commit comments

Comments
 (0)