Skip to content

Commit

Permalink
Fix build of universal2 wheels
Browse files Browse the repository at this point in the history
When building universal2 wheels, we need to set the architectures for
CMake. This was not detected properly before.
  • Loading branch information
tuxu committed Jan 23, 2024
1 parent b6d87cd commit e55dc11
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
# https://github.com/pybind/cmake_example

import os
import platform
from pathlib import Path
import re
import subprocess
import sys
from pathlib import Path

import setuptools
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext

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

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

# Set CMAKE_BUILD_PARALLEL_LEVEL to control the parallel build level
# across all generators.
Expand Down

0 comments on commit e55dc11

Please sign in to comment.