Skip to content

Commit

Permalink
Added CI for pre-built wheels
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Stiborek committed Sep 9, 2024
1 parent fafdac3 commit c219fb4
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 2 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,3 @@ jobs:
# python3 setup.py install --user
# - name: Test
# run: python3 -m pytest --ignore docs --ignore dlib

100 changes: 100 additions & 0 deletions .github/workflows/build_python_wheel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Python

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.20.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

- uses: pypa/cibuildwheel@v2.20.0 # sync version with pip install cibuildwheel above
with:
only: ${{ matrix.only }}
env:
CIBW_BUILD_VERBOSITY: 1
CIBW_TEST_COMMAND: python -c "import dlib"

# 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

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build-system]
requires = ["setuptools", "wheel"]
requires = ["setuptools", "wheel", "cmake==3.24.0"]
build-backend = "setuptools.build_meta"

0 comments on commit c219fb4

Please sign in to comment.