-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parallelize and add more wheel builds (#9)
* Build arm64 / aarch64 wheels * Add PYTHON_REQUIRES * Update to actions/upload-artifact@v4 * Add WORKING_DIRECTORY * Add git fetch --all * Disable win32 * Fix repair command for macos * Separate macos versions * Correct mac version * Remove sed * Bump setup-python
- Loading branch information
Showing
1 changed file
with
78 additions
and
44 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,69 +2,103 @@ name: Build | |
|
||
on: [push] | ||
|
||
env: | ||
WORKING_DIRECTORY: 'dlib' | ||
BUILD_COMMIT: 'v19.24.2' | ||
DLIB_BIN_VERSION: '19.24.2' | ||
PYTHON_REQUIRES: '>=3.7' | ||
|
||
jobs: | ||
build_wheels_matrix: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
include: ${{ steps.set-matrix.outputs.include }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
|
||
- uses: actions/setup-python@v5 | ||
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 | ||
working-directory: ${{ env.WORKING_DIRECTORY }} | ||
|
||
build_wheels: | ||
name: Build wheels on ${{ matrix.os }} | ||
needs: build_wheels_matrix | ||
runs-on: ${{ matrix.os }} | ||
name: Build ${{ matrix.only }} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
env: | ||
REPO_DIR: 'dlib' | ||
BUILD_COMMIT: 'v19.24.2' | ||
DLIB_BIN_VERSION: '19.24.2' | ||
CIBUILDWHEEL_VERSION: '2.17.0' | ||
CIBW_BEFORE_BUILD: 'pip install cmake' | ||
CIBW_BUILD: 'cp37-* cp38-* cp39-* cp310-* cp311-*' | ||
CIBW_SKIP: '*musllinux*' | ||
CIBW_ARCHS: 'auto64' | ||
include: ${{ fromJson(needs.build_wheels_matrix.outputs.include) }} | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Checkout submodules | ||
defaults: | ||
run: | ||
shell: bash | ||
run: | | ||
git submodule update --init --recursive | ||
git -C dlib checkout $BUILD_COMMIT | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
|
||
- name: Fix setup.py | ||
shell: bash | ||
run: | | ||
sed -i'' -e "s/name='dlib'/name='dlib-bin'/" $REPO_DIR/setup.py | ||
sed -i'' -e "s/version=read_version_from_cmakelists('dlib\/CMakeLists.txt')/version='$DLIB_BIN_VERSION'/" $REPO_DIR/setup.py | ||
sed -i'' -e "s/url='https:\/\/github\.com\/davisking\/dlib'/url='https:\/\/github\.com\/alesanfra\/dlib-wheels'/" $REPO_DIR/setup.py | ||
sed -i'' -e "s/_cmake_extra_options = \[\]/_cmake_extra_options = \['-DDLIB_NO_GUI_SUPPORT=ON'\]/" $REPO_DIR/setup.py | ||
- name: Checkout build commit | ||
run: git fetch --all && git checkout $BUILD_COMMIT | ||
working-directory: ${{ env.WORKING_DIRECTORY }} | ||
|
||
- name: Install cibuildwheel | ||
shell: bash | ||
run: python -m pip install cibuildwheel==$CIBUILDWHEEL_VERSION | ||
|
||
- name: Build wheels | ||
shell: bash | ||
run: python3 -m cibuildwheel $REPO_DIR --output-dir wheelhouse | ||
- name: Fix setup.py | ||
run: | | ||
sed -i'' -e "s/name='dlib'/name='dlib-bin'/" setup.py | ||
sed -i'' -e "s/version=read_version_from_cmakelists('dlib\/CMakeLists.txt')/version='$DLIB_BIN_VERSION'/" setup.py | ||
sed -i'' -e "s/url='https:\/\/github\.com\/davisking\/dlib'/url='https:\/\/github\.com\/alesanfra\/dlib-wheels'/" setup.py | ||
sed -i'' -e "s/_cmake_extra_options = \[\]/_cmake_extra_options = \['-DDLIB_NO_GUI_SUPPORT=ON'\]/" setup.py | ||
working-directory: ${{ env.WORKING_DIRECTORY }} | ||
|
||
- name: Set up QEMU | ||
if: runner.os == 'Linux' | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Save wheels | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
path: ./wheelhouse/*.whl | ||
- uses: pypa/[email protected] # sync version with pip install cibuildwheel above | ||
with: | ||
only: ${{ matrix.only }} | ||
package-dir: ${{ env.WORKING_DIRECTORY }} | ||
env: | ||
CIBW_BUILD_VERBOSITY: 1 | ||
CIBW_BEFORE_BUILD: pip install cmake | ||
CIBW_TEST_COMMAND: python -c "import dlib" | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: dist-${{ matrix.only }} | ||
path: wheelhouse/*.whl | ||
|
||
upload_pypi: | ||
needs: [build_wheels] | ||
runs-on: ubuntu-latest | ||
# upload to PyPI on master | ||
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | ||
steps: | ||
- uses: actions/download-artifact@v3 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: artifact | ||
path: dist | ||
path: dist/ | ||
pattern: dist-* | ||
merge-multiple: true | ||
|
||
- uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
|