Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cibuildwheel: Add macOS arm64 support #7727

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 45 additions & 25 deletions .github/workflows/cibuildwheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: cibuildwheel
# 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
# https://github.com/pypa/cibuildwheel/blob/v2.21.3/cibuildwheel/resources/build-platforms.toml

# Notes on build targets we (don't) support:
# - pypy: libtorrent doesn't build with pypy as of writing
Expand Down Expand Up @@ -45,22 +45,31 @@ jobs:
MATRIX_PULL_REQUEST: |
{
"include": [
{"os": "ubuntu-latest", "CIBW_BUILD": "cp39-manylinux_*", "CIBW_ARCHS": "x86_64"},
{"os": "ubuntu-latest", "CIBW_BUILD": "cp39-musllinux_*", "CIBW_ARCHS": "x86_64"},
{"os": "macos-12", "CIBW_BUILD": "cp39-*", "CIBW_ARCHS": "x86_64"},
{"os": "windows-2022", "CIBW_BUILD": "cp39-*", "CIBW_ARCHS": "AMD64"}
{"os": "ubuntu-latest", "CIBW_BUILD": "cp39-manylinux_x86_64", "CIBW_ARCHS_LINUX": "x86_64"},
{"os": "ubuntu-latest", "CIBW_BUILD": "cp39-manylinux_aarch64", "CIBW_ARCHS_LINUX": "aarch64"},
{"os": "ubuntu-latest", "CIBW_BUILD": "cp39-musllinux_x86_64", "CIBW_ARCHS_LINUX": "x86_64"},
{"os": "ubuntu-latest", "CIBW_BUILD": "cp39-musllinux_aarch64", "CIBW_ARCHS_LINUX": "aarch64"},
{"os": "macos-12", "CIBW_BUILD": "cp39-macosx_x86_64", "CIBW_ARCHS_MACOS": "x86_64", "MACOSX_DEPLOYMENT_TARGET": "12"},
{"os": "macos-13", "CIBW_BUILD": "cp39-macosx_x86_64", "CIBW_ARCHS_MACOS": "x86_64", "MACOSX_DEPLOYMENT_TARGET": "13"},
{"os": "macos-14", "CIBW_BUILD": "cp39-macosx_arm64", "CIBW_ARCHS_MACOS": "arm64", "MACOSX_DEPLOYMENT_TARGET": "14"},
{"os": "macos-15", "CIBW_BUILD": "cp39-macosx_arm64", "CIBW_ARCHS_MACOS": "arm64", "MACOSX_DEPLOYMENT_TARGET": "15"},
{"os": "windows-latest", "CIBW_BUILD": "cp39-win32", "CIBW_ARCHS_WINDOWS": "x86"},
{"os": "windows-latest", "CIBW_BUILD": "cp39-win_amd64", "CIBW_ARCHS_WINDOWS": "AMD64"}
]
}
MATRIX_WORKFLOW_DISPATCH: |
{
"include": [
{"os": "ubuntu-latest", "CIBW_BUILD": "cp*-manylinux_*", "CIBW_ARCHS": "x86_64"},
{"os": "ubuntu-latest", "CIBW_BUILD": "cp*-manylinux_*", "CIBW_ARCHS": "aarch64"},
{"os": "ubuntu-latest", "CIBW_BUILD": "cp*-musllinux_*", "CIBW_ARCHS": "x86_64"},
{"os": "ubuntu-latest", "CIBW_BUILD": "cp*-musllinux_*", "CIBW_ARCHS": "aarch64"},
{"os": "macos-12", "CIBW_BUILD": "cp*", "CIBW_ARCHS": "x86_64"},
{"os": "windows-2022", "CIBW_BUILD": "cp*", "CIBW_ARCHS": "x86"},
{"os": "windows-2022", "CIBW_BUILD": "cp*", "CIBW_ARCHS": "AMD64"}
{"os": "ubuntu-latest", "CIBW_BUILD": "cp*-manylinux_x86_64", "CIBW_ARCHS_LINUX": "x86_64"},
{"os": "ubuntu-latest", "CIBW_BUILD": "cp*-manylinux_aarch64", "CIBW_ARCHS_LINUX": "aarch64"},
{"os": "ubuntu-latest", "CIBW_BUILD": "cp*-musllinux_x86_64", "CIBW_ARCHS_LINUX": "x86_64"},
{"os": "ubuntu-latest", "CIBW_BUILD": "cp*-musllinux_aarch64", "CIBW_ARCHS_LINUX": "aarch64"},
{"os": "macos-12", "CIBW_BUILD": "cp*-macosx_x86_64", "CIBW_ARCHS_MACOS": "x86_64", "MACOSX_DEPLOYMENT_TARGET": "12"},
{"os": "macos-13", "CIBW_BUILD": "cp*-macosx_x86_64", "CIBW_ARCHS_MACOS": "x86_64", "MACOSX_DEPLOYMENT_TARGET": "13"},
{"os": "macos-14", "CIBW_BUILD": "cp*-macosx_arm64", "CIBW_ARCHS_MACOS": "arm64", "MACOSX_DEPLOYMENT_TARGET": "14"},
{"os": "macos-15", "CIBW_BUILD": "cp*-macosx_arm64", "CIBW_ARCHS_MACOS": "arm64", "MACOSX_DEPLOYMENT_TARGET": "15"},
{"os": "windows-latest", "CIBW_BUILD": "cp*-win32", "CIBW_ARCHS_WINDOWS": "x86"},
{"os": "windows-latest", "CIBW_BUILD": "cp*-win_amd64", "CIBW_ARCHS_WINDOWS": "AMD64"}
]
}

Expand All @@ -87,7 +96,11 @@ jobs:
env:
CIBW_BUILD_VERBOSITY: 1
CIBW_BUILD: ${{ matrix.CIBW_BUILD }}
CIBW_ARCHS: ${{ matrix.CIBW_ARCHS }}
CIBW_ARCHS_LINUX: ${{ matrix.CIBW_ARCHS_LINUX }}
CIBW_ARCHS_WINDOWS: ${{ matrix.CIBW_ARCHS_WINDOWS }}
CIBW_ARCHS_MACOS: ${{ matrix.CIBW_ARCHS_MACOS }}
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.MACOSX_DEPLOYMENT_TARGET }}
CIBW_SKIP: pp*
CIBW_TEST_SKIP: "*-win32"

steps:
Expand All @@ -101,50 +114,57 @@ jobs:
id: cache-wheel
with:
path: wheelhouse
key: wheel-${{ matrix.CIBW_BUILD }}-${{ matrix.CIBW_ARCHS }}-${{ github.sha }}
key: wheel-${{ matrix.os }}-${{ matrix.CIBW_BUILD }}

- uses: docker/setup-qemu-action@v3
if: steps.cache-wheel.outputs.cache-hit != 'true' && runner.os == 'Linux'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, maybe a separate PR is overkill. This is all you need:

Suggested change
- name: Install OpenSSL (win32)
if: ${{ endsWith(matrix.CIBW_BUILD, 'win32') }}
run: |
Remove-Item -Path "C:\Program Files\OpenSSL" -Force -Recurse
vcpkg install openssl:x86-windows
New-Item -Path "C:\Program Files\OpenSSL" -ItemType SymbolicLink -Value "C:\vcpkg\packages\openssl_x86-windows\"

There's a mini build here: https://github.com/qstokkink/libtorrent/actions/runs/11439039359

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qstokkink Thank you!, added your change now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qstokkink Do you think we should use the same vcpkg method for x64? (consistency)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion: absolutely not. This is much slower (it adds 6~7 minutes to the job). That is way too much added time just for the sake of consistency.

- uses: pypa/cibuildwheel@v2.19.2
- name: Install OpenSSL (win32)
if: ${{ endsWith(matrix.CIBW_BUILD, 'win32') }}
run: |
Remove-Item -Path "C:\Program Files\OpenSSL" -Force -Recurse
vcpkg install openssl:x86-windows
New-Item -Path "C:\Program Files\OpenSSL" -ItemType SymbolicLink -Value "C:\vcpkg\packages\openssl_x86-windows\"

- uses: pypa/cibuildwheel@v2.21.3
if: steps.cache-wheel.outputs.cache-hit != 'true'

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
path: wheelhouse/*.whl
name: wheels
name: wheels-${{ matrix.os }}-${{ matrix.CIBW_BUILD }}

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@v3
- uses: actions/download-artifact@v4
with:
name: wheels
name: wheels-${{ matrix.os }}-${{ matrix.CIBW_BUILD }}
path: wheelhouse

- uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: wheelhouse
skip_existing: true
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@v3
- uses: actions/download-artifact@v4
with:
name: wheels
name: wheels-${{ matrix.os }}-${{ matrix.CIBW_BUILD }}
path: wheelhouse

- uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
packages_dir: wheelhouse
skip_existing: true
packages-dir: wheelhouse
skip-existing: true
repository_url: https://test.pypi.org/legacy/
11 changes: 5 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[project]
requires-python = ">=3.7"
requires-python = ">=3.9"

[tool.cibuildwheel]
skip = "{pp*,}"
Expand All @@ -17,8 +17,7 @@ test-command = [
[tool.cibuildwheel.macos.environment]
BOOST_BUILD_PATH = "/tmp/boost/tools/build"
BOOST_ROOT = "/tmp/boost"
BOOST_VERSION = "1.81.0"
MACOSX_DEPLOYMENT_TARGET = "12"
BOOST_VERSION = "1.83.0"
PATH = "/tmp/boost:$PATH"

[[tool.cibuildwheel.overrides]]
Expand All @@ -38,7 +37,7 @@ test-command = [
[tool.cibuildwheel.overrides.environment] # sub-table of previous block!
BOOST_BUILD_PATH = "/tmp/boost/tools/build"
BOOST_ROOT = "/tmp/boost"
BOOST_VERSION = "1.81.0"
BOOST_VERSION = "1.83.0"
PATH = "/usr/local/ccache/bin:/tmp/boost:$PATH"

[[tool.cibuildwheel.overrides]]
Expand All @@ -57,7 +56,7 @@ test-command = [
[tool.cibuildwheel.overrides.environment] # sub-table of previous block!
BOOST_BUILD_PATH = "/tmp/boost/tools/build"
BOOST_ROOT = "/tmp/boost"
BOOST_VERSION = "1.81.0"
BOOST_VERSION = "1.83.0"
PATH = "/usr/lib/ccache/bin:/tmp/boost:$PATH"

[[tool.cibuildwheel.overrides]]
Expand All @@ -78,7 +77,7 @@ test-command = '''bash -c "cd '{project}/bindings/python' && python test.py"'''
[tool.cibuildwheel.windows.environment]
BOOST_BUILD_PATH = 'c:/boost/tools/build'
BOOST_ROOT = 'c:/boost'
BOOST_VERSION = "1.81.0"
BOOST_VERSION = "1.83.0"
PATH = 'c:/boost;$PATH'

[tool.isort]
Expand Down
Loading