Skip to content

move to Cibuildwheel workflow #120

move to Cibuildwheel workflow

move to Cibuildwheel workflow #120

name: Python cibuildwheel
on:
push:
pull_request:
branches: [ master ]
workflow_dispatch:
jobs:
build_wheels:
name: Build wheels for ${{ matrix.os }} on ${{ matrix.arch }} (Linux target ${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, macos-12]
# separate archs, so they use individual caches
arch: [ 'x86_64', 'arm64' ]
# separate musl and many on linux, for mac we just skip one of those
target: [ 'many', 'musl' ]
exclude:
- os: macos-12
target: musl
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
if: ${{ (runner.os == 'Linux') && (matrix.arch == 'arm64') }}
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.target }}-python
- name: Sets env for x86_64
run: |
echo "CIBW_ARCHS_LINUX=auto64" >> $GITHUB_ENV
echo "CIBW_ARCHS_MACOS=x86_64" >> $GITHUB_ENV
if: matrix.arch == 'x86_64'
- name: Sets env for arm64
run: |
echo "CIBW_ARCHS_LINUX=aarch64" >> $GITHUB_ENV
echo "CIBW_ARCHS_MACOS=arm64" >> $GITHUB_ENV
if: matrix.arch == 'arm64'
- name: Skip manylinux for musllinux target
if: ${{ matrix.target == 'musl' }}
run: |
echo "CIBW_SKIP=*manylinux*" >> $GITHUB_ENV
- name: Skip musllinux for manylinux target
if: ${{ matrix.target == 'many' }}
run: |
echo "CIBW_SKIP=*musllinux*" >> $GITHUB_ENV
- name: install mac dependencies
if: ${{ runner.os == 'macOS' }}
run: |
brew update && \
brew install ccache
- name: install mac dependencies X86_64
if: ${{ (runner.os == 'macOS') && (matrix.arch == 'x86_64') }}
run: |
brew update && \
brew install zlib snappy boost
- name: install mac dependencies arm64
if: ${{ (runner.os == 'macOS') && (matrix.arch == 'arm64') }}
run: |
set -e
echo "_PYTHON_HOST_PLATFORM='macosx-12.0-arm64'" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET='12.0'" >> $GITHUB_ENV
echo "CIBW_CONFIG_SETTINGS='--build-option='--cmake-module-path=${{ github.workspace }}/arm64-homebrew'" >> $GITHUB_ENV
mkdir arm64-homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C arm64-homebrew
PACKAGES=( zlib snappy boost )
for PACKAGE in "${PACKAGES[@]}"
do
response=$(arm64-homebrew/bin/brew fetch --force --bottle-tag=arm64_monterey $PACKAGE | grep Downloaded )
download_path=$(echo $response | xargs -n 1 | tail -1)
arm64-homebrew/bin/brew reinstall -vd $download_path
done
arm64-homebrew/bin/brew config
- name: Build python wheels for ${{ matrix.os }} on ${{ matrix.arch }}
uses: pypa/[email protected]
env:
# Skip CPython 3.6 and CPython 3.7
CIBW_SKIP: ${{ env.CIBW_SKIP }} cp36-* cp37-*
# skip testing all python versions on linux arm, only test 3.12
# skip tests on pypy, currently fails for indexer tests
CIBW_TEST_SKIP: "*p{38,39,310,311}-m*linux_aarch64 pp*"
# (many)linux custom docker images
CIBW_MANYLINUX_X86_64_IMAGE: 'keyvidev/manylinux-builder-x86_64'
CIBW_MANYLINUX_AARCH64_IMAGE: 'keyvidev/manylinux-builder-aarch64'
CIBW_MUSLLINUX_X86_64_IMAGE: 'keyvidev/musllinux-builder-x86_64'
CIBW_MUSLLINUX_AARCH64_IMAGE: 'keyvidev/musllinux-builder-aarch64'
# ccache using path
CIBW_ENVIRONMENT_MACOS: PATH=/usr/local/opt/ccache/libexec:$PATH
CIBW_ENVIRONMENT_LINUX: PATH=/usr/local/bin:/usr/lib/ccache:$PATH CCACHE_DIR=/host${{ github.workspace }}/.ccache CCACHE_CONFIGPATH=/host/home/runner/.config/ccache/ccache.conf
# python dependencies
CIBW_BEFORE_BUILD: pip install -r python/requirements.txt
# testing
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: >
python -m pytest {package}/tests &&
python -m pytest {package}/integration-tests
# for debugging set this to 1,2 or 3
CIBW_BUILD_VERBOSITY: 2
with:
package-dir: python
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl