1+ name : Build and Release dlib Wheels Compatible
2+
3+ on :
4+ push :
5+ tags :
6+ - ' v*'
7+ workflow_dispatch :
8+ inputs :
9+ create_release :
10+ description : ' Create a release'
11+ required : false
12+ type : boolean
13+ default : false
14+
15+ jobs :
16+ build-x86_64 :
17+ 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 : Build wheel in manylinux container
29+ run : |
30+ docker run --rm \
31+ -v ${{ github.workspace }}:/workspace \
32+ -w /workspace \
33+ quay.io/pypa/manylinux2014_x86_64 \
34+ bash -c '
35+ export PYTHON_VERSION=${{ matrix.python-version }}
36+
37+ # Install system dependencies
38+ yum install -y \
39+ cmake3 boost-devel openblas-devel lapack-devel \
40+ libX11-devel gtk3-devel \
41+ libpng-devel libjpeg-devel libtiff-devel git \
42+ gcc gcc-c++ make atlas-devel
43+
44+ # Set up Python based on version
45+ if [ "$PYTHON_VERSION" = "3.10" ]; then
46+ PYBIN=/opt/python/cp310-cp310/bin
47+ elif [ "$PYTHON_VERSION" = "3.11" ]; then
48+ PYBIN=/opt/python/cp311-cp311/bin
49+ elif [ "$PYTHON_VERSION" = "3.12" ]; then
50+ PYBIN=/opt/python/cp312-cp312/bin
51+ else
52+ echo "Unsupported Python version: $PYTHON_VERSION"
53+ exit 1
54+ fi
55+
56+ $PYBIN/pip install --upgrade pip wheel setuptools auditwheel
57+
58+ # Clone dlib
59+ git clone --depth 1 https://github.com/davisking/dlib.git dlib_src
60+ cd dlib_src
61+
62+ # Build wheel
63+ $PYBIN/python setup.py bdist_wheel
64+
65+ if [ ! -f dist/*.whl ]; then
66+ echo "Wheel build failed - no wheel found in dist/"
67+ ls -la dist/ || echo "dist/ directory not found"
68+ exit 1
69+ fi
70+
71+ # Repair wheel with manylinux2014 policy (glibc 2.17)
72+ mkdir -p /workspace/dist_final/
73+ $PYBIN/auditwheel repair dist/*.whl -w /workspace/dist_final/ --plat manylinux2014_x86_64
74+ '
75+
76+ - name : Upload build artifact
77+ uses : actions/upload-artifact@v4
78+ with :
79+ name : dlib-py${{ matrix.python-version }}-linux-x86_64
80+ path : dist_final/*.whl
81+ retention-days : 30
82+
83+ build-aarch64 :
84+ runs-on : ubuntu-latest
85+ strategy :
86+ fail-fast : false
87+ matrix :
88+ python-version : ['3.10', '3.11', '3.12']
89+ timeout-minutes : 180
90+ continue-on-error : true
91+
92+ steps :
93+ - name : Checkout repository
94+ uses : actions/checkout@v4
95+
96+ - name : Set up QEMU
97+ uses : docker/setup-qemu-action@v3
98+ with :
99+ platforms : arm64
100+
101+ - name : Build wheel in Docker
102+ run : |
103+ docker run --rm --platform linux/arm64 \
104+ -v ${{ github.workspace }}:/workspace \
105+ -w /workspace \
106+ quay.io/pypa/manylinux2014_aarch64 \
107+ bash -c '
108+ export PYTHON_VERSION=${{ matrix.python-version }}
109+
110+ # Install system dependencies
111+ yum install -y \
112+ cmake3 boost-devel openblas-devel lapack-devel \
113+ libX11-devel \
114+ libpng-devel libjpeg-devel libtiff-devel git \
115+ gcc gcc-c++ make atlas-devel
116+
117+ # Set up Python based on version
118+ if [ "$PYTHON_VERSION" = "3.10" ]; then
119+ PYBIN=/opt/python/cp310-cp310/bin
120+ elif [ "$PYTHON_VERSION" = "3.11" ]; then
121+ PYBIN=/opt/python/cp311-cp311/bin
122+ elif [ "$PYTHON_VERSION" = "3.12" ]; then
123+ PYBIN=/opt/python/cp312-cp312/bin
124+ else
125+ echo "Unsupported Python version: $PYTHON_VERSION"
126+ exit 1
127+ fi
128+
129+ $PYBIN/pip install --upgrade pip wheel setuptools auditwheel
130+
131+ # Clone dlib master
132+ git clone --depth 1 https://github.com/davisking/dlib.git dlib_src
133+ cd dlib_src
134+
135+ # Reduce optimization for faster builds
136+ export CXXFLAGS="-O2 -g0"
137+
138+ # Build wheel
139+ $PYBIN/python setup.py bdist_wheel
140+
141+ # Create output directory and repair wheel with manylinux2014
142+ mkdir -p /workspace/dist_final/
143+ if [ -f dist/*.whl ]; then
144+ $PYBIN/auditwheel repair dist/*.whl -w /workspace/dist_final/ --plat manylinux2014_aarch64
145+ else
146+ echo "No wheel found to repair"
147+ ls -la dist/
148+ exit 1
149+ fi
150+ '
151+
152+ - name : Upload build artifact
153+ uses : actions/upload-artifact@v4
154+ if : success()
155+ with :
156+ name : dlib-py${{ matrix.python-version }}-linux-aarch64
157+ path : dist_final/*.whl
158+ retention-days : 30
159+
160+ release :
161+ runs-on : ubuntu-latest
162+ needs : [build-x86_64, build-aarch64]
163+ if : always() && (startsWith(github.ref, 'refs/tags/') || github.event.inputs.create_release == 'true') && needs.build-x86_64.result == 'success'
164+ permissions :
165+ contents : write
166+
167+ steps :
168+ - name : Download all artifacts
169+ uses : actions/download-artifact@v4
170+ with :
171+ path : artifacts/
172+
173+ - name : Prepare wheels
174+ run : |
175+ mkdir -p wheels
176+ find artifacts -name "*.whl" -exec cp {} wheels/ \;
177+ echo "Built wheels:"
178+ ls -lh wheels/
179+
180+ # Count wheels by architecture
181+ x86_count=$(find wheels -name "*x86_64*.whl" | wc -l)
182+ aarch64_count=$(find wheels -name "*aarch64*.whl" | wc -l)
183+ echo "x86_64 wheels: $x86_count"
184+ echo "aarch64 wheels: $aarch64_count"
185+
186+ - name : Create Release
187+ uses : softprops/action-gh-release@v2
188+ with :
189+ name : Release ${{ github.event.inputs.create_release == 'true' && format('Manual Release {0}', github.run_number) || github.ref_name }}
190+ tag_name : ${{ github.event.inputs.create_release == 'true' && format('manual-{0}', github.run_number) || github.ref_name }}
191+ body : |
192+ Prebuilt dlib wheels for Linux (x86_64 and aarch64) on Python 3.10, 3.11, and 3.12
193+
194+ **Compatible with most Linux distributions** (manylinux2014 - glibc 2.17+)
195+ - Ubuntu 14.04+, Debian 8+, CentOS 7+, RHEL 7+, and most modern distros
196+
197+ **Installation:**
198+ ```bash
199+ pip install dlib-*.whl
200+ ```
201+
202+ Choose the wheel that matches your:
203+ - Python version (cp310, cp311, or cp312)
204+ - Architecture (x86_64 or aarch64)
205+
206+ Note: aarch64 wheels may not be available if builds timed out.
207+ files : wheels/*.whl
208+ draft : false
209+ prerelease : false
210+ env :
211+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments