Skip to content

Build arm64 wheels for macOS #261

Build arm64 wheels for macOS

Build arm64 wheels for macOS #261

Workflow file for this run

name: build
on:
push:
branches:
- main
pull_request:
release:
types:
- published
jobs:
source:
name: Build source package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pip install build && python -m build --sdist
- uses: actions/upload-artifact@v3
with:
path: dist/*
wheels:
name: Build binary packages
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest]
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
# See https://docs.scipy.org/doc/scipy/building/index.html
- name: Install MinGW
if: runner.os == 'Windows'
run: |
choco install rtools -y --no-progress --force --version=4.0.0.20220206
echo "c:\rtools40\ucrt64\bin;" >> $env:GITHUB_PATH
# Adapted from https://github.com/scipy/scipy/blob/main/tools/wheels/cibw_before_build_macos.sh
- name: Install GFortran for macOS arm64
if: runner.os == 'macOS'
run: |
curl -L https://github.com/isuruf/gcc/releases/download/gcc-11.3.0-2/gfortran-darwin-x86_64-native.tar.gz -o gfortran.tar.gz
shasum -c <(echo '981367dd0ad4335613e91bbee453d60b6669f5d7e976d18c7bdb7f1966f26ae4 gfortran.tar.gz')
sudo tar -xv -C /usr/local -f gfortran.tar.gz
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_BUILD_VERBOSITY: 1
CIBW_ARCHS_LINUX: auto aarch64
CIBW_ARCHS_WINDOWS: AMD64
CIBW_ENVIRONMENT_MACOS: FC=/usr/local/bin/gfortran
CIBW_ARCHS_MACOS: arm64
# Skip musllinux wheels, which take a long time to build because Numpy must be built from source
# Skip PyPy wheels
# Skip 32-bit Intel wheels
CIBW_SKIP: '*musllinux* pp* *_i686'
- uses: actions/upload-artifact@v3
with:
path: wheelhouse/*
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
permissions:
id-token: write
needs: [source, wheels]
if: github.event_name == 'release'
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1