Merge pull request #1 from Uzithei/macos #2
Workflow file for this run
This file contains hidden or 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
| name: Build and Release dlib Wheels Compatible | |
| 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: Build wheel in manylinux container | |
| run: | | |
| docker run --rm \ | |
| -v ${{ github.workspace }}:/workspace \ | |
| -w /workspace \ | |
| quay.io/pypa/manylinux2014_x86_64 \ | |
| bash -c ' | |
| export PYTHON_VERSION=${{ matrix.python-version }} | |
| # Install system dependencies | |
| yum install -y \ | |
| cmake3 boost-devel openblas-devel lapack-devel \ | |
| libX11-devel gtk3-devel \ | |
| libpng-devel libjpeg-devel libtiff-devel git \ | |
| gcc gcc-c++ make atlas-devel | |
| # Set up Python based on version | |
| if [ "$PYTHON_VERSION" = "3.10" ]; then | |
| PYBIN=/opt/python/cp310-cp310/bin | |
| elif [ "$PYTHON_VERSION" = "3.11" ]; then | |
| PYBIN=/opt/python/cp311-cp311/bin | |
| elif [ "$PYTHON_VERSION" = "3.12" ]; then | |
| PYBIN=/opt/python/cp312-cp312/bin | |
| else | |
| echo "Unsupported Python version: $PYTHON_VERSION" | |
| exit 1 | |
| fi | |
| $PYBIN/pip install --upgrade pip wheel setuptools auditwheel | |
| # Clone dlib | |
| git clone --depth 1 https://github.com/davisking/dlib.git dlib_src | |
| cd dlib_src | |
| # Build wheel | |
| $PYBIN/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 | |
| # Repair wheel with manylinux2014 policy (glibc 2.17) | |
| mkdir -p /workspace/dist_final/ | |
| $PYBIN/auditwheel repair dist/*.whl -w /workspace/dist_final/ --plat manylinux2014_x86_64 | |
| ' | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dlib-py${{ matrix.python-version }}-linux-x86_64 | |
| path: dist_final/*.whl | |
| retention-days: 30 | |
| build-aarch64: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ['3.10', '3.11', '3.12'] | |
| timeout-minutes: 180 | |
| continue-on-error: true | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| with: | |
| platforms: arm64 | |
| - name: Build wheel in Docker | |
| run: | | |
| docker run --rm --platform linux/arm64 \ | |
| -v ${{ github.workspace }}:/workspace \ | |
| -w /workspace \ | |
| quay.io/pypa/manylinux2014_aarch64 \ | |
| bash -c ' | |
| export PYTHON_VERSION=${{ matrix.python-version }} | |
| # Install system dependencies | |
| yum install -y \ | |
| cmake3 boost-devel openblas-devel lapack-devel \ | |
| libX11-devel \ | |
| libpng-devel libjpeg-devel libtiff-devel git \ | |
| gcc gcc-c++ make atlas-devel | |
| # Set up Python based on version | |
| if [ "$PYTHON_VERSION" = "3.10" ]; then | |
| PYBIN=/opt/python/cp310-cp310/bin | |
| elif [ "$PYTHON_VERSION" = "3.11" ]; then | |
| PYBIN=/opt/python/cp311-cp311/bin | |
| elif [ "$PYTHON_VERSION" = "3.12" ]; then | |
| PYBIN=/opt/python/cp312-cp312/bin | |
| else | |
| echo "Unsupported Python version: $PYTHON_VERSION" | |
| exit 1 | |
| fi | |
| $PYBIN/pip install --upgrade pip wheel setuptools auditwheel | |
| # Clone dlib master | |
| git clone --depth 1 https://github.com/davisking/dlib.git dlib_src | |
| cd dlib_src | |
| # Reduce optimization for faster builds | |
| export CXXFLAGS="-O2 -g0" | |
| # Build wheel | |
| $PYBIN/python setup.py bdist_wheel | |
| # Create output directory and repair wheel with manylinux2014 | |
| mkdir -p /workspace/dist_final/ | |
| if [ -f dist/*.whl ]; then | |
| $PYBIN/auditwheel repair dist/*.whl -w /workspace/dist_final/ --plat manylinux2014_aarch64 | |
| else | |
| echo "No wheel found to repair" | |
| ls -la dist/ | |
| exit 1 | |
| fi | |
| ' | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| if: success() | |
| with: | |
| name: dlib-py${{ matrix.python-version }}-linux-aarch64 | |
| path: dist_final/*.whl | |
| retention-days: 30 | |
| release: | |
| runs-on: ubuntu-latest | |
| needs: [build-x86_64, build-aarch64] | |
| if: always() && (startsWith(github.ref, 'refs/tags/') || github.event.inputs.create_release == 'true') && needs.build-x86_64.result == 'success' | |
| 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/ | |
| # Count wheels by architecture | |
| x86_count=$(find wheels -name "*x86_64*.whl" | wc -l) | |
| aarch64_count=$(find wheels -name "*aarch64*.whl" | wc -l) | |
| echo "x86_64 wheels: $x86_count" | |
| echo "aarch64 wheels: $aarch64_count" | |
| - 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 and aarch64) on Python 3.10, 3.11, and 3.12 | |
| **Compatible with most Linux distributions** (manylinux2014 - glibc 2.17+) | |
| - Ubuntu 14.04+, Debian 8+, CentOS 7+, RHEL 7+, and most modern distros | |
| **Installation:** | |
| ```bash | |
| pip install dlib-*.whl | |
| ``` | |
| Choose the wheel that matches your: | |
| - Python version (cp310, cp311, or cp312) | |
| - Architecture (x86_64 or aarch64) | |
| Note: aarch64 wheels may not be available if builds timed out. | |
| files: wheels/*.whl | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |