Skip to content

Added CI for pre-built wheels #15

Added CI for pre-built wheels

Added CI for pre-built wheels #15

Workflow file for this run

name: Python wheels
on:
push:
branches:
- master
paths:
- ".github/workflows/build_python.yml"
- "**.cpp"
- "**.h"
- "**.c"
- "**.cu"
- "**.cmake"
- "**CMakeLists.txt"
- "**py"
pull_request:
branches:
- master
paths:
- ".github/workflows/build_python.yml"
- "**.cpp"
- "**.h"
- "**.c"
- "**.cu"
- "**.cmake"
- "**CMakeLists.txt"
- "**py"
defaults:
run:
shell: bash
jobs:
build_wheels_matrix:
runs-on: ubuntu-latest
outputs:
include: ${{ steps.set-matrix.outputs.include }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.x
- run: pip install cibuildwheel==2.17.0 # sync version with pypa/cibuildwheel below
- id: set-matrix
env:
CIBW_PROJECT_REQUIRES_PYTHON: '>=3.7' # it is missing in setup.py and needed to determine which wheels to build
run: |
MATRIX_INCLUDE=$(
{
cibuildwheel --print-build-identifiers --platform linux --arch x86_64,aarch64 | grep cp | jq -nRc '{"only": inputs, "os": "ubuntu-latest"}' \
&& cibuildwheel --print-build-identifiers --platform macos --arch x86_64 | grep cp | jq -nRc '{"only": inputs, "os": "macos-13"}' \
&& cibuildwheel --print-build-identifiers --platform macos --arch arm64 | grep cp | jq -nRc '{"only": inputs, "os": "macos-14"}' \
&& cibuildwheel --print-build-identifiers --platform windows --arch AMD64 | grep cp | jq -nRc '{"only": inputs, "os": "windows-latest"}'
} | jq -sc
)
echo "include=$MATRIX_INCLUDE" >> $GITHUB_OUTPUT
build_wheels:
needs: build_wheels_matrix
runs-on: ${{ matrix.os }}
name: Build ${{ matrix.only }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.build_wheels_matrix.outputs.include) }}
steps:
- uses: actions/checkout@v4
- name: Disable gui support
run: |
sed -i'' -e "s/_cmake_extra_options = \[\]/_cmake_extra_options = \['-DDLIB_NO_GUI_SUPPORT=ON'\]/" setup.py
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
- name: Build wheel
uses: pypa/cibuildwheel@v2.17.0 # sync version with pip install cibuildwheel above
with:
only: ${{ matrix.only }}
env:
CIBW_BUILD_VERBOSITY: 1
CIBW_TEST_REQUIRES: pytest numpy
CIBW_TEST_COMMAND: python -m pytest {project}/tools/python/test --ignore docs --ignore dlib
- name: Artifacts
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.only }}
path: wheelhouse/*.whl
# Disabled for now since something is going sideways with python packages on github actions
# MacOS:
# runs-on: 'macos-latest'
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-python@v4
# - name: Install python deps
# run: pip3 install pytest numpy
# - name: Build
# run: |
# python3 setup.py build
# python3 setup.py install --user
# - name: Test
# run: python3 -m pytest --ignore docs --ignore dlib