Build Wheels #57
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Build Wheels | |
on: | |
workflow_dispatch: | |
jobs: | |
Standard: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [macos-11.0, windows-latest, ubuntu-latest] | |
architecture: [x64] | |
include: | |
- os: windows-latest | |
architecture: x86 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.9 | |
architecture: ${{ matrix.architecture }} | |
- name: Install clang | |
if: startsWith(matrix.os, 'windows') | |
uses: bwoodsend/setup-winlibs-action@v1 | |
with: | |
architecture: ${{ matrix.architecture }} | |
with_clang: true | |
# Compile with clang by default which produces faster binaries. | |
- run: echo CC=clang >> $GITHUB_ENV | |
# macOS needs special compiler flags to enable 'universal2' binaries. | |
- if: startsWith(matrix.os, 'macos') | |
run: echo CC_FLAGS='-arch x86_64 -arch arm64' >> $GITHUB_ENV | |
# Check the compiler. Don't fail if CC isn't set. | |
- run: ${CC:-echo} -v | |
shell: bash | |
- run: pip wheel --no-deps -w dist . | |
# Build a universal2 wheel for macOS to support both arm64 and x86_64. | |
# Hopefully I'll think of a better way to do this and add it to cslug. | |
- if: startsWith(matrix.os, 'macos') | |
run: | | |
mv dist/*.whl "dist/$(ls dist/ | sed 's/x86_64/universal2/')" | |
# Build a wheel for modern x86_64 Linux using clang (which produces | |
# a faster binary than gcc). | |
- if: startsWith(matrix.os, 'ubuntu') | |
run: | | |
pip install auditwheel | |
export OLD_WHEEL="$(echo dist/*.whl)" | |
# When glibc on CI updates, update the manylinux variant as needed. | |
auditwheel repair "$OLD_WHEEL" --plat=manylinux2014_x86_64 -w dist | |
rm $OLD_WHEEL | |
- name: Upload wheel(s) as build artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels-${{ matrix.os }}-${{ matrix.architecture }} | |
path: dist/*.whl | |
- name: Test Wheel | |
run: | | |
pip install "$(echo dist/*.whl)[test]" && | |
rm -rf hirola && | |
pytest --no-cov | |
shell: bash | |
Whacky-Linux: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
base: [ | |
manylinux1_x86_64, | |
manylinux1_i686, | |
manylinux2014_aarch64, | |
# Support these when NumPy provides wheels for them. | |
# manylinux2014_ppc64le, | |
# manylinux2014_s390x, | |
] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: crazy-max/[email protected] | |
- name: Build docker image | |
run: | | |
docker build -t bob-the-builder --build-arg BASE=${{ matrix.base }} . | |
- name: Build wheel | |
run: | | |
docker run -v "$(pwd):/io" bob-the-builder bash -c " | |
rm -rf build /tmp/dist | |
python setup.py -q bdist_wheel -d /tmp/dist | |
auditwheel repair /tmp/dist/*.whl -w dist | |
" | |
- name: Upload wheel(s) as build artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels-${{ matrix.base }} | |
path: dist/*.whl | |
- name: Install and test wheel | |
run: | | |
docker run -v "$(pwd)/tests:/tests" -v "$(pwd)/dist:/dist" \ | |
-t bob-the-builder bash -c " | |
cd ~ && | |
pip uninstall -y hirola && | |
# Note that this assumes that there is only one wheel in dist. | |
pip install /dist/hirola*manylinux*.whl && | |
pytest /tests | |
" |