Skip to content

Commit

Permalink
Don't build all wheels all the time
Browse files Browse the repository at this point in the history
Building wheels, specially on macOS and aarch64, takes a long time.
Instead of building all wheels all the time, let's instead build a
subset of wheels during normal pushes, and all wheels only when we push
a tag.

Signed-off-by: Rodrigo Tobar <rtobar@icrar.org>
  • Loading branch information
rtobar committed Nov 15, 2023
1 parent d4ae771 commit 0037c31
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions .github/workflows/deploy-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,28 @@ name: Build distributions and upload to PyPI
on: [push, pull_request]

jobs:

calculate_wheels_to_build:
name: Calculate OS/archs to build wheels on
runs-on: ubuntu-20.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
macos_archs: ${{ startsWith(github.event.ref, 'refs/tags/v') && 'x86_64 arm64 universal2' || 'auto' }}
steps:
- name: Calculate strategy matrix
id: set-matrix
env:
MATRIX_INCLUDES: ${{ startsWith(github.event.ref, 'refs/tags/v') && '[{\"os\": \"ubuntu-20.04\", \"arch_linux\": \"aarch64\"}]' || '[]' }}
run: echo "matrix={\"os\": [\"ubuntu-20.04\", \"windows-2019\", \"macos-12\"], \"arch_linux\": [\"auto\"], \"include\": $MATRIX_INCLUDES}" >> "$GITHUB_OUTPUT"

build_wheels:
name: Build wheels on ${{matrix.arch}} for ${{ matrix.os }}
needs: calculate_wheels_to_build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2019, macos-12]
arch: [auto]
include:
- os: ubuntu-20.04
arch: aarch64
matrix: ${{ fromJson(needs.calculate_wheels_to_build.outputs.matrix) }}
env:
ARCHS_MACOS: ${{ needs.calculate_wheels_to_build.outputs.macos_archs }}

steps:
- uses: actions/checkout@v3
Expand All @@ -37,8 +49,8 @@ jobs:
run: |
python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_ARCHS_LINUX: ${{matrix.arch}}
CIBW_ARCHS_MACOS: "x86_64 arm64 universal2"
CIBW_ARCHS_LINUX: ${{ matrix.arch_linux }}
CIBW_ARCHS_MACOS: ${{ env.ARCHS_MACOS }}
CIBW_BEFORE_ALL: "bash -c 'cd \"{project}\"; sh .github/tools/install_yajl.sh'"
CIBW_BUILD_VERBOSITY: 1
CIBW_ENVIRONMENT_MACOS: "IJSON_EMBED_YAJL=1"
Expand Down

0 comments on commit 0037c31

Please sign in to comment.