Skip to content

Build and Release dlib Wheels Gracefully #4

Build and Release dlib Wheels Gracefully

Build and Release dlib Wheels Gracefully #4

name: Build and Release dlib Wheels Gracefully
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
create_release:
description: 'Create a release'
required: false
type: boolean
default: false
jobs:
build-x86_64:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11', '3.12']
timeout-minutes: 60
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install system dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends \
build-essential cmake libboost-dev libopenblas-dev liblapack-dev \
libx11-dev libgtk-3-dev libjpeg-dev libpng-dev libtiff-dev \
libatlas-base-dev pkg-config
- name: Install Python build tools
run: |
python -m pip install --upgrade pip
pip install build wheel setuptools auditwheel
- name: Clone dlib
run: |
git clone --depth 1 https://github.com/davisking/dlib.git dlib_src
- name: Build wheel
run: |
cd dlib_src
python setup.py bdist_wheel
if [ ! -f dist/*.whl ]; then
echo "Wheel build failed - no wheel found in dist/"
ls -la dist/ || echo "dist/ directory not found"
exit 1
fi
- name: Repair wheel (manylinux)
run: |
cd dlib_src
mkdir -p dist_repaired/
auditwheel repair dist/*.whl -w dist_repaired/ || cp dist/*.whl dist_repaired/
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: dlib-py${{ matrix.python-version }}-linux-x86_64
path: dlib_src/dist_repaired/*.whl
retention-days: 30
release:
runs-on: ubuntu-latest
needs: [build-x86_64]
if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.create_release == 'true'
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts/
- name: Prepare wheels
run: |
mkdir -p wheels
find artifacts -name "*.whl" -exec cp {} wheels/ \;
echo "Built wheels:"
ls -lh wheels/
- name: Create Release
uses: softprops/action-gh-release@v2
with:
name: Release ${{ github.event.inputs.create_release == 'true' && format('Manual Release {0}', github.run_number) || github.ref_name }}
tag_name: ${{ github.event.inputs.create_release == 'true' && format('manual-{0}', github.run_number) || github.ref_name }}
body: |
Prebuilt dlib wheels for Linux x86_64 on Python 3.10, 3.11, and 3.12
**Installation:**
```pip install dlib-*.whl```
Choose the wheel that matches your Python version (cp310, cp311, or cp312)
files: wheels/*.whl
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}