File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44# https://github.com/pybind/cmake_example
55
66import os
7- import platform
87from pathlib import Path
9- import re
108import subprocess
119import sys
1210from pathlib import Path
1311
14- import setuptools
1512from setuptools import Extension , setup
1613from 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.
You can’t perform that action at this time.
0 commit comments