Skip to content

Merge pull request #1 from Uzithei/macos #1

Merge pull request #1 from Uzithei/macos

Merge pull request #1 from Uzithei/macos #1

name: Build and Release dlib Wheels macOS
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
create_release:
description: "Create a release"
required: false
type: boolean
default: false
jobs:
build-macos:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-13, macos-14] # macos-13 = Intel (x86_64), macos-14 = Apple Silicon (arm64)
python-version: ["3.10", "3.11", "3.12", "3.13"]
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 Homebrew dependencies
run: |
brew update
brew install cmake boost openblas
- name: Install Python build tools
run: |
python -m pip install --upgrade pip
pip install build wheel setuptools delocate
- 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 with delocate
run: |
cd dlib_src
mkdir -p dist_repaired/
# Use delocate to bundle dependencies
delocate-wheel -w dist_repaired/ -v dist/*.whl
echo "Repaired wheels:"
ls -lh dist_repaired/
- name: Set architecture for artifact name
id: arch
run: |
if [ "${{ matrix.os }}" = "macos-13" ]; then
echo "arch=x86_64" >> $GITHUB_OUTPUT
else
echo "arch=arm64" >> $GITHUB_OUTPUT
fi
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: dlib-py${{ matrix.python-version }}-macos-${{ steps.arch.outputs.arch }}
path: dlib_src/dist_repaired/*.whl
retention-days: 30
release:
runs-on: ubuntu-latest
needs: [build-macos]
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/
# Count wheels by architecture
x86_count=$(find wheels -name "*x86_64*.whl" | wc -l)
arm64_count=$(find wheels -name "*arm64*.whl" | wc -l)
echo "x86_64 (Intel) wheels: $x86_count"
echo "arm64 (Apple Silicon) wheels: $arm64_count"
- name: Create Release
uses: softprops/action-gh-release@v2
with:
name: Release ${{ github.event.inputs.create_release == 'true' && format('macOS Manual Release {0}', github.run_number) || github.ref_name }}
tag_name: ${{ github.event.inputs.create_release == 'true' && format('macos-{0}', github.run_number) || github.ref_name }}
body: |
Prebuilt dlib wheels for macOS (Intel x86_64 and Apple Silicon arm64)
**Supported:**
- **Architectures**: x86_64 (Intel), arm64 (Apple Silicon)
- **Python versions**: 3.10, 3.11, 3.12, 3.13
- **macOS versions**: 10.9+ (x86_64), 11.0+ (arm64)
**Installation:**
```bash
pip install dlib-*.whl
```
Choose the wheel that matches your:
- Python version (cp310, cp311, cp312, or cp313)
- Architecture (x86_64 for Intel Macs, arm64 for Apple Silicon)
**System Requirements:**
No additional dependencies needed - wheels are self-contained with bundled libraries.
files: wheels/*.whl
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}