forked from davisking/dlib
-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (96 loc) · 3.17 KB
/
build_python.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
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