Skip to content

Commit 72c014d

Browse files
authored
build universal2 package in CI (onnx#127)
Signed-off-by: daquexian <[email protected]>
1 parent 807cff7 commit 72c014d

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

.github/workflows/build-and-test.yml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on: [push, pull_request]
55
jobs:
66
build_wheels:
77
env:
8+
CIBW_ARCHS_MACOS: x86_64 universal2
89
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
910
CIBW_BEFORE_ALL_LINUX: WD=`pwd` && /opt/python/cp38-cp38/bin/python -m pip install --target tmp_cmake cmake && cp tmp_cmake/bin/cmake /usr/local/bin/cmake && rm -rf tmp_cmake && /opt/python/cp38-cp38/bin/python -m pip install cmake && cmake --version && whereis cmake
1011
CIBW_BEFORE_ALL_MACOS: WD=`pwd` && pip install cmake

setup.py

+7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import subprocess
2121
import sys
2222
import platform
23+
import re
2324
from textwrap import dedent
2425
import multiprocessing
2526

@@ -29,6 +30,7 @@
2930
CMAKE_BUILD_DIR = os.path.join(TOP_DIR, '.setuptools-cmake-build')
3031

3132
WINDOWS = (os.name == 'nt')
33+
MACOS = sys.platform.startswith("darwin")
3234

3335
CMAKE = find_executable('cmake')
3436

@@ -186,6 +188,11 @@ def run(self):
186188
cmake_args.extend(['-A', 'x64', '-T', 'host=x64'])
187189
else:
188190
cmake_args.extend(['-A', 'Win32', '-T', 'host=x86'])
191+
if MACOS:
192+
# Cross-compile support for macOS - respect ARCHFLAGS if set
193+
archs = re.findall(r"-arch (\S+)", os.environ.get("ARCHFLAGS", ""))
194+
if archs:
195+
cmake_args += ["-DCMAKE_OSX_ARCHITECTURES={}".format(";".join(archs))]
189196
if ONNX_ML:
190197
cmake_args.append('-DONNX_ML=1')
191198
if ONNX_VERIFY_PROTO3:

0 commit comments

Comments
 (0)