Skip to content

Commit

Permalink
gh-actions cibuildwheel: build for macos x86-64 & aarch64
Browse files Browse the repository at this point in the history
and generally simplify the configuration
  • Loading branch information
mr-c committed Mar 12, 2024
1 parent 5546aea commit 8ee8c9f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 30 deletions.
8 changes: 0 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ jobs:
command: |
python3 -m pip install --upgrade pip setuptools setuptools_scm[toml]
python3 -m pip install -rcibw-requirements.txt
python3 ./setup.py --version
- run:
name: pip freeze
Expand All @@ -55,14 +54,7 @@ jobs:
- run:
name: cibuildwheel
command: |
source .github/workflows/wheel-prep.sh
export CIBW_ENVIRONMENT="SCHEMA_SALAD_USE_MYPYC=1 MYPYPATH=/project/mypy-stubs SETUPTOOLS_SCM_PRETEND_VERSION=${SETUPTOOLS_SCM_PRETEND_VERSION}"
python3 -m cibuildwheel .
# "/project" is the project path inside the cibuildwheel container itself
- run:
name: move tests results out of the wheelhouse
command: mv wheelhouse/test-results ./
- store_test_results:
path: test-results/
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/wheel-prep.sh

This file was deleted.

44 changes: 27 additions & 17 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,15 @@ jobs:
fetch-depth: 0 # slow, but gets all the tags
ref: ${{ github.event.client_payload.ref }}

# Used to host cibuildwheel
- uses: actions/setup-python@v5

# - name: Set up QEMU
# if: runner.os == 'Linux'
# uses: docker/setup-qemu-action@v2
# with:
# platforms: all

- name: Install cibuildwheel
run: python -m pip install -rcibw-requirements.txt

- name: set version
run: pip install setuptools_scm[toml] wheel && python setup.py --version

- name: Build wheels
run: |
source .github/workflows/wheel-prep.sh
export CIBW_ENVIRONMENT="SCHEMA_SALAD_USE_MYPYC=1 MYPYPATH=/project/mypy-stubs SETUPTOOLS_SCM_PRETEND_VERSION=${SETUPTOOLS_SCM_PRETEND_VERSION}"
python -m cibuildwheel --output-dir wheelhouse
uses: pypa/cibuildwheel@v2.17.0
env:
CIBW_ARCHS_MACOS: x86_64 arm64
CIBW_BUILD: ${{ matrix.build }}
CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/${{ matrix.image }}
CIBW_MUSLLINUX_X86_64_IMAGE: quay.io/pypa/${{ matrix.image }}
Expand Down Expand Up @@ -84,9 +71,6 @@ jobs:
fetch-depth: 0 # slow, but gets all the tags
ref: ${{ github.event.client_payload.ref }}

- name: set version
run: pip install setuptools_scm[toml] wheel && python setup.py --version

- name: Build sdist
run: pipx run build --sdist

Expand All @@ -95,6 +79,32 @@ jobs:
name: artifact-source
path: dist/*.tar.gz

build_wheels_macos:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# macos-13 is an intel runner, macos-14 is apple silicon
os: [macos-13, macos-14]
steps:
- uses: actions/checkout@v4
if: ${{ github.event_name != 'repository_dispatch' }}
with:
fetch-depth: 0 # slow, but gets all the tags
- uses: actions/checkout@v4
if: ${{ github.event_name == 'repository_dispatch' }}
with:
fetch-depth: 0 # slow, but gets all the tags
ref: ${{ github.event.client_payload.ref }}

- name: Build wheels
uses: pypa/cibuildwheel@v2.17.0

- uses: actions/upload-artifact@v4
with:
name: artifact-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ build-backend = "setuptools.build_meta"
write_to = "schema_salad/_version.py"

[tool.cibuildwheel]
before-build = "python -m pip install -r requirements.txt -r mypy-requirements.txt"
test-command = "python -m pytest -n 2 --junitxml=/output/test-results/junit_$(python -V | awk '{print $2}')_${AUDITWHEEL_PLAT}.xml --pyargs schema_salad"
test-command = "python -m pytest -n 2 --junitxml={project}/test-results/junit_$(python -V | awk '{print $2}')_${AUDITWHEEL_PLAT}.xml --pyargs schema_salad"
test-requires = "-r test-requirements.txt"
test-extras = "pycodegen"
skip = "pp*"
# ^ skip building wheels on PyPy (any version)
build-verbosity = "1"
environment = { SCHEMA_SALAD_USE_MYPYC="1", MYPYPATH="$(pwd)/mypy-stubs" }

[tool.black]
line-length = 100
Expand Down

0 comments on commit 8ee8c9f

Please sign in to comment.