1- name : Build and Release dlib Wheels Parallel
1+ name : Build and Release dlib Wheels Parallel
22
33on :
44 push :
55 tags :
66 - ' v*'
77 workflow_dispatch :
8+ inputs :
9+ create_release :
10+ description : ' Create a release'
11+ required : false
12+ type : boolean
13+ default : false
814
915jobs :
10- build_wheels :
11- name : Build wheels
16+ build-x86_64 :
1217 runs-on : ubuntu-latest
18+ strategy :
19+ fail-fast : false
20+ matrix :
21+ python-version : ['3.10', '3.11', '3.12']
22+ timeout-minutes : 60
23+
24+ steps :
25+ - name : Checkout repository
26+ uses : actions/checkout@v4
27+
28+ - name : Set up Python ${{ matrix.python-version }}
29+ uses : actions/setup-python@v5
30+ with :
31+ python-version : ${{ matrix.python-version }}
32+
33+ - name : Install system dependencies
34+ run : |
35+ sudo apt-get update -qq
36+ sudo apt-get install -y --no-install-recommends \
37+ build-essential cmake libboost-dev libopenblas-dev liblapack-dev \
38+ libx11-dev libgtk-3-dev libjpeg-dev libpng-dev libtiff-dev \
39+ libatlas-base-dev pkg-config
40+
41+ - name : Install Python build tools
42+ run : |
43+ python -m pip install --upgrade pip
44+ pip install build wheel setuptools auditwheel
45+
46+ - name : Clone dlib
47+ run : |
48+ git clone --depth 1 https://github.com/davisking/dlib.git dlib_src
49+
50+ - name : Build wheel
51+ run : |
52+ cd dlib_src
53+ python setup.py bdist_wheel
54+
55+ if [ ! -f dist/*.whl ]; then
56+ echo "Wheel build failed - no wheel found in dist/"
57+ ls -la dist/ || echo "dist/ directory not found"
58+ exit 1
59+ fi
60+
61+ - name : Repair wheel (manylinux)
62+ run : |
63+ cd dlib_src
64+ mkdir -p dist_repaired/
65+ auditwheel repair dist/*.whl -w dist_repaired/ || cp dist/*.whl dist_repaired/
66+
67+ - name : Upload build artifact
68+ uses : actions/upload-artifact@v4
69+ with :
70+ name : dlib-py${{ matrix.python-version }}-linux-x86_64
71+ path : dlib_src/dist_repaired/*.whl
72+ retention-days : 30
73+
74+ build-aarch64 :
75+ runs-on : ubuntu-latest
76+ strategy :
77+ fail-fast : false
78+ matrix :
79+ python-version : ['3.10', '3.11', '3.12']
1380 timeout-minutes : 180
81+ continue-on-error : true
1482
1583 steps :
1684 - name : Checkout repository
@@ -21,33 +89,69 @@ jobs:
2189 with :
2290 platforms : arm64
2391
24- - name : Clone dlib
92+ - name : Build wheel in Docker
2593 run : |
26- git clone --depth 1 https://github.com/davisking/dlib.git dlib_src
94+ docker run --rm --platform linux/arm64 \
95+ -v ${{ github.workspace }}:/workspace \
96+ -w /workspace \
97+ quay.io/pypa/manylinux2014_aarch64 \
98+ bash -c '
99+ export PYTHON_VERSION=${{ matrix.python-version }}
100+
101+ # Install system dependencies
102+ yum install -y \
103+ cmake3 boost-devel openblas-devel lapack-devel \
104+ libX11-devel \
105+ libpng-devel libjpeg-devel libtiff-devel git \
106+ gcc gcc-c++ make atlas-devel
107+
108+ # Set up Python based on version
109+ if [ "$PYTHON_VERSION" = "3.10" ]; then
110+ PYBIN=/opt/python/cp310-cp310/bin
111+ elif [ "$PYTHON_VERSION" = "3.11" ]; then
112+ PYBIN=/opt/python/cp311-cp311/bin
113+ elif [ "$PYTHON_VERSION" = "3.12" ]; then
114+ PYBIN=/opt/python/cp312-cp312/bin
115+ else
116+ echo "Unsupported Python version: $PYTHON_VERSION"
117+ exit 1
118+ fi
119+
120+ $PYBIN/pip install --upgrade pip wheel setuptools auditwheel
121+
122+ # Clone dlib master
123+ git clone --depth 1 https://github.com/davisking/dlib.git dlib_src
124+ cd dlib_src
125+
126+ # Reduce optimization for faster builds
127+ export CXXFLAGS="-O2 -g0"
128+
129+ # Build wheel
130+ $PYBIN/python setup.py bdist_wheel
131+
132+ # Create output directory and repair wheel
133+ mkdir -p /workspace/dist_final/
134+ if [ -f dist/*.whl ]; then
135+ $PYBIN/auditwheel repair dist/*.whl -w /workspace/dist_final/
136+ else
137+ echo "No wheel found to repair"
138+ ls -la dist/
139+ exit 1
140+ fi
141+ '
27142
28- - name : Build wheels
29- uses : pypa/cibuildwheel@v2.21.0
30- with :
31- package-dir : dlib_src
32- env :
33- CIBW_BUILD : cp311-* cp312-*
34- CIBW_ARCHS_LINUX : x86_64 aarch64
35- CIBW_BEFORE_ALL_LINUX : >
36- yum install -y cmake3 boost-devel openblas-devel
37- lapack-devel git gcc gcc-c++ make
38- CIBW_ENVIRONMENT : " CXXFLAGS='-O2 -g0'"
39-
40- - name : Upload artifacts
143+ - name : Upload build artifact
41144 uses : actions/upload-artifact@v4
145+ if : success()
42146 with :
43- name : wheels
44- path : ./wheelhouse /*.whl
147+ name : dlib-py${{ matrix.python-version }}-linux-aarch64
148+ path : dist_final /*.whl
45149 retention-days : 30
46150
47151 release :
48152 runs-on : ubuntu-latest
49- needs : [build_wheels ]
50- if : startsWith(github.ref, 'refs/tags/')
153+ needs : [build-x86_64, build-aarch64 ]
154+ if : always() && ( startsWith(github.ref, 'refs/tags/') || github.event.inputs.create_release == 'true') && needs.build-x86_64.result == 'success'
51155 permissions :
52156 contents : write
53157
@@ -63,20 +167,29 @@ jobs:
63167 find artifacts -name "*.whl" -exec cp {} wheels/ \;
64168 echo "Built wheels:"
65169 ls -lh wheels/
170+
171+ # Count wheels by architecture
172+ x86_count=$(find wheels -name "*x86_64*.whl" | wc -l)
173+ aarch64_count=$(find wheels -name "*aarch64*.whl" | wc -l)
174+ echo "x86_64 wheels: $x86_count"
175+ echo "aarch64 wheels: $aarch64_count"
66176
67177 - name : Create Release
68178 uses : softprops/action-gh-release@v2
69179 with :
70- name : Release ${{ github.ref_name }}
180+ name : Release ${{ github.event.inputs.create_release == 'true' && format('Manual Release {0}', github.run_number) || github.ref_name }}
181+ tag_name : ${{ github.event.inputs.create_release == 'true' && format('manual-{0}', github.run_number) || github.ref_name }}
71182 body : |
72- Prebuilt dlib wheels for Linux (x86_64 and aarch64) on Python 3.11 and 3.12
183+ Prebuilt dlib wheels for Linux (x86_64 and aarch64) on Python 3.10, 3.11, and 3.12
73184
74185 **Installation:**
75- pip install dlib-*.whl
186+ ``` pip install dlib-*.whl```
76187
77188 Choose the wheel that matches your:
78- - Python version (cp311 or cp312)
189+ - Python version (cp310, cp311, or cp312)
79190 - Architecture (x86_64 or aarch64)
191+
192+ Note: aarch64 wheels may not be available if builds timed out.
80193 files : wheels/*.whl
81194 draft : false
82195 prerelease : false
0 commit comments