Skip to content

Commit

Permalink
chore: enable ARM64 build for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
XuehaiPan committed Oct 31, 2022
1 parent 7979053 commit 0ec46c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ jobs:
uses: pypa/[email protected]
env:
CIBW_BUILD: ${{ env.CIBW_BUILD }}
CIBW_ARCHS_MACOS: x86_64 arm64 universal2
with:
package-dir: .
output-dir: wheelhouse
Expand Down Expand Up @@ -168,6 +169,7 @@ jobs:
uses: pypa/[email protected]
env:
CIBW_BUILD: ${{ env.CIBW_BUILD }}
CIBW_ARCHS_MACOS: x86_64 arm64 universal2
with:
package-dir: .
output-dir: wheelhouse
Expand Down
7 changes: 7 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import pathlib
import platform
import shutil
import sys
import sysconfig
Expand Down Expand Up @@ -53,6 +54,12 @@ def build_extension(self, ext):
f'-DPYTHON_INCLUDE_DIR={sysconfig.get_path("platinclude")}',
]

if platform.system() == 'Darwin':
# Cross-compile support for macOS - respect ARCHFLAGS if set
archs = re.findall(r'-arch (\S+)', os.environ.get('ARCHFLAGS', ''))
if archs:
cmake_args.append('-DCMAKE_OSX_ARCHITECTURES={}'.format(';'.join(archs)))

try:
import pybind11

Expand Down

0 comments on commit 0ec46c2

Please sign in to comment.