Skip to content

Commit

Permalink
build: macOS arm64 and musllinux wheels
Browse files Browse the repository at this point in the history
* Build macOS arm64 wheels

- use macOS 11 to build wheels
- update cibuildwheel version
- add universal2 tag to the macOS architectures

* Use PEP 517 build system

- switch to PEP 517 build system
- switch CI to use `pip install .` rather than `setup.py install`

* Switch to macos-11 in test.yml workflow as well

* Fix musl linux build

* Migrate cibuildwheel configuration to pyproject.toml

* Keep pre-release build *only* for builds that won't go to to PyPI

* Simplify list of builds to build
  • Loading branch information
Jackenmen authored Aug 9, 2022
1 parent 8a13692 commit 1f59aff
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 15 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ jobs:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-2019, macos-10.15]
os: [ubuntu-20.04, windows-2019, macos-11]

steps:
- uses: actions/checkout@v2
Expand All @@ -20,11 +21,8 @@ jobs:
with:
platforms: all
- name: Build wheels
uses: pypa/cibuildwheel@v2.0.1
uses: pypa/cibuildwheel@v2.8.1
with:
output-dir: ./wheelhouse
env:
CIBW_BUILD: "cp36-* cp37-* cp38-* cp39-* cp310-*"
CIBW_ARCHS_LINUX: auto aarch64
CIBW_PRERELEASE_PYTHONS: True
CIBW_BEFORE_ALL_LINUX: yum install -y libffi-devel
9 changes: 2 additions & 7 deletions .github/workflows/release-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2019, macos-10.15]
os: [ubuntu-20.04, windows-2019, macos-11]

steps:
- uses: actions/checkout@v2
Expand All @@ -23,14 +23,9 @@ jobs:
with:
platforms: all
- name: Build wheels
uses: pypa/cibuildwheel@v2.0.1
uses: pypa/cibuildwheel@v2.8.1
with:
output-dir: ./wheelhouse
env:
CIBW_BUILD: "cp36-* cp37-* cp38-* cp39-* cp310-*"
CIBW_ARCHS_LINUX: auto aarch64
CIBW_PRERELEASE_PYTHONS: True
CIBW_BEFORE_ALL_LINUX: yum install -y libffi-devel
- uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-2019, macos-10.15]
os: [ubuntu-20.04, windows-2019, macos-11]
python-version: [ '3.6', '3.7', '3.8', '3.9', '3.10']
steps:
- uses: actions/checkout@v2
Expand All @@ -22,6 +22,6 @@ jobs:
- name: Install dependencies
run: python -m pip install -U setuptools wheel
- name: Build package
run: python setup.py install
run: python -m pip install .
- name: Run tests
run: python tests/tests.py
27 changes: 27 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[build-system]
requires = ["setuptools", "wheel", "cffi>=1.5.0"]
build-backend = "setuptools.build_meta"

[tool.cibuildwheel]
build = "cp3*"

[tool.cibuildwheel.linux]
archs = ["auto", "aarch64"]
before-all = """
set -eux
# musllinux_*
if command -v apk; then
apk add libffi-dev
fi
# manylinux_2_24
if command -v apt; then
apt install libffi-dev
fi
# manylinux_*
if command -v yum; then
yum install -y libffi-devel
fi
"""

[tool.cibuildwheel.macos]
archs = ["x86_64", "universal2"]
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
# -*- coding: utf-8 -*-

import codecs
import os
import re
import sys

# we have to import setup_cares.py which is in project's root folder
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))

from setuptools import setup

Expand Down Expand Up @@ -40,7 +45,6 @@ def get_version():
'Programming Language :: Python :: Implementation :: PyPy',
],
cmdclass = {'build_ext': cares_build_ext},
setup_requires = ['cffi>=1.5.0'],
install_requires = ['cffi>=1.5.0'],
extras_require = {'idna': ['idna >= 2.1']},
cffi_modules = ['src/_cffi_src/build_cares.py:ffi'],
Expand Down

0 comments on commit 1f59aff

Please sign in to comment.