Skip to content

Add macOS arm64 support for cibuildwheel #158

Add macOS arm64 support for cibuildwheel

Add macOS arm64 support for cibuildwheel #158

Workflow file for this run

name: cibuildwheel
# Note: We use a dynamic matrix to build different sets of wheels under
# different conditions. On workflow_dispatch, we build the full suite of
# wheels. This takes hours, so on pull_request, we just build a representative
# sample.
# The full list of cibuildwheel's build targets can be found here:
# https://github.com/pypa/cibuildwheel/blob/v2.16.5/cibuildwheel/resources/build-platforms.toml
# Notes on build targets we (don't) support:
# - pypy: libtorrent doesn't build with pypy as of writing
# - macos_arm64: can be cross-compiled from x86_64, but not run, so can't be
# tested. Build output indicates it isn't building correctly
# - macos_universal2: b2 / setup.py doesn't have a straightforward way to build
# this as of writing
# - abi3: Not supported by boost-python (or pybind11) or cibuildwheel as of
# writing
on:
workflow_dispatch:
inputs:
publish:
description: Write 'PUBLISH' to publish to pypi. BEWARE! ARTIFACTS ARE IMMUTABLE AND CANNOT BE REPLACED ONCE PUBLISHED!
publish_test:
description: Write 'PUBLISH_TEST' to publish to test-pypi. BEWARE! ARTIFACTS ARE IMMUTABLE AND CANNOT BE REPLACED ONCE PUBLISHED!
pull_request:
paths:
- .github/workflows/cibuildwheel.yml
- tools/cibuildwheel/**
- pyproject.toml
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}
cancel-in-progress: true
jobs:
configure_matrix:
runs-on: ubuntu-latest
env:
# github actions syntax doesn't allow us to have yaml structures as
# an input to a job. These environment variables are literal json strings
MATRIX_PULL_REQUEST: |
os: ["windows-latest", "ubuntu-latest", "macos-14"]
python: "312"
platform_id:
- win_amd64
- win32
- manylinux_x86_64
- manylinux_aarch64
- musllinux_x86_64
- musllinux_aarch64
- macosx_x86_64
exclude:
# Skip certain Python, Linux and Mac builds on Windows
- os: windows-latest
platform_id: manylinux_aarch64
platform_id: manylinux_x86_64
platform_id: macosx_x86_64
platform_id: musllinux_x86_64
platform_id: musllinux_aarch64
# Skip certain Python, Mac and Windows builds on Linux
- os: ubuntu-latest
platform_id: macosx_x86_64
platform_id: win_amd64
platform_id: win32
# Skip certain Python, Linux and Windows builds on Mac
- os: macos-14
platform_id: win_amd64
platform_id: win32
platform_id: manylinux_x86_64
platform_id: manylinux_aarch64
platform_id: musllinux_x86_64
platform_id: musllinux_aarch64
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- id: set-matrix
run: |
if [ $GITHUB_EVENT_NAME == "pull_request" ]; then
echo "matrix=$(echo $MATRIX_PULL_REQUEST | jq -c)" >> "$GITHUB_OUTPUT"
else
echo "matrix=$(echo $MATRIX_WORKFLOW_DISPATCH | jq -c)" >> "$GITHUB_OUTPUT"
fi
build_wheels:
needs: configure_matrix
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix: ${{ outputs.matrix }}

Check failure on line 96 in .github/workflows/cibuildwheel.yml

View workflow run for this annotation

GitHub Actions / cibuildwheel

Invalid workflow file

The workflow is not valid. .github/workflows/cibuildwheel.yml (Line: 96, Col: 15): Unrecognized named-value: 'outputs'. Located at position 1 within expression: outputs.matrix .github/workflows/cibuildwheel.yml (Line: 96, Col: 15): Unexpected value '${{ outputs.matrix }}'
env:
CIBW_BUILD_VERBOSITY: 1
CIBW_ARCHS_LINUX: "x86_64, aarch64"
CIBW_ARCHS_MACOS: "x86_64, arm64"
CIBW_ARCHS_WINDOWS: "AMD64, x86"
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }}
CIBW_TEST_SKIP: "*-win32"
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/cache@v4
id: cache-wheel
with:
path: wheelhouse
key: wheel-${{ matrix.os }}-${{ matrix.platform_id }}-${{ github.sha }}
- uses: docker/setup-qemu-action@v3
if: steps.cache-wheel.outputs.cache-hit != 'true' && runner.os == 'Linux'
- uses: pypa/[email protected]
if: steps.cache-wheel.outputs.cache-hit != 'true'
- uses: actions/upload-artifact@v4
with:
path: wheelhouse/*.whl
name: wheels-${{ matrix.os }}-${{ matrix.platform_id }}
upload_pypi:
needs: build_wheels
runs-on: ubuntu-latest
if: needs.build_wheels.result == 'success' && github.event.inputs.publish == 'PUBLISH'
steps:
- uses: actions/download-artifact@v4
with:
pattern: wheels-*
path: wheelhouse
- uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: wheelhouse
skip-existing: true
upload_pypi_test:
needs: build_wheels
runs-on: ubuntu-latest
if: needs.build_wheels.result == 'success' && github.event.inputs.publish_test == 'PUBLISH_TEST'
steps:
- uses: actions/download-artifact@v4
with:
pattern: wheels-*
path: wheelhouse
- uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
packages-dir: wheelhouse
skip-existing: true
repository_url: https://test.pypi.org/legacy/