Skip to content

Commit 1a6e87a

Browse files
authored
Merge pull request #1 from Uzithei/macos
Macos
2 parents cdeeaf4 + ca31612 commit 1a6e87a

File tree

4 files changed

+410
-30
lines changed

4 files changed

+410
-30
lines changed
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
name: Build and Release dlib Wheels macOS
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-macos:
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
os: [macos-13, macos-14] # macos-13 = Intel (x86_64), macos-14 = Apple Silicon (arm64)
22+
python-version: ["3.10", "3.11", "3.12", "3.13"]
23+
timeout-minutes: 60
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Set up Python ${{ matrix.python-version }}
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: ${{ matrix.python-version }}
33+
34+
- name: Install Homebrew dependencies
35+
run: |
36+
brew update
37+
brew install cmake boost openblas
38+
39+
- name: Install Python build tools
40+
run: |
41+
python -m pip install --upgrade pip
42+
pip install build wheel setuptools delocate
43+
44+
- name: Clone dlib
45+
run: |
46+
git clone --depth 1 https://github.com/davisking/dlib.git dlib_src
47+
48+
- name: Build wheel
49+
run: |
50+
cd dlib_src
51+
python setup.py bdist_wheel
52+
53+
if [ ! -f dist/*.whl ]; then
54+
echo "Wheel build failed - no wheel found in dist/"
55+
ls -la dist/ || echo "dist/ directory not found"
56+
exit 1
57+
fi
58+
59+
- name: Repair wheel with delocate
60+
run: |
61+
cd dlib_src
62+
mkdir -p dist_repaired/
63+
64+
# Use delocate to bundle dependencies
65+
delocate-wheel -w dist_repaired/ -v dist/*.whl
66+
67+
echo "Repaired wheels:"
68+
ls -lh dist_repaired/
69+
70+
- name: Set architecture for artifact name
71+
id: arch
72+
run: |
73+
if [ "${{ matrix.os }}" = "macos-13" ]; then
74+
echo "arch=x86_64" >> $GITHUB_OUTPUT
75+
else
76+
echo "arch=arm64" >> $GITHUB_OUTPUT
77+
fi
78+
79+
- name: Upload build artifact
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: dlib-py${{ matrix.python-version }}-macos-${{ steps.arch.outputs.arch }}
83+
path: dlib_src/dist_repaired/*.whl
84+
retention-days: 30
85+
86+
release:
87+
runs-on: ubuntu-latest
88+
needs: [build-macos]
89+
if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.create_release == 'true'
90+
permissions:
91+
contents: write
92+
93+
steps:
94+
- name: Download all artifacts
95+
uses: actions/download-artifact@v4
96+
with:
97+
path: artifacts/
98+
99+
- name: Prepare wheels
100+
run: |
101+
mkdir -p wheels
102+
find artifacts -name "*.whl" -exec cp {} wheels/ \;
103+
echo "Built wheels:"
104+
ls -lh wheels/
105+
106+
# Count wheels by architecture
107+
x86_count=$(find wheels -name "*x86_64*.whl" | wc -l)
108+
arm64_count=$(find wheels -name "*arm64*.whl" | wc -l)
109+
echo "x86_64 (Intel) wheels: $x86_count"
110+
echo "arm64 (Apple Silicon) wheels: $arm64_count"
111+
112+
- name: Create Release
113+
uses: softprops/action-gh-release@v2
114+
with:
115+
name: Release ${{ github.event.inputs.create_release == 'true' && format('macOS Manual Release {0}', github.run_number) || github.ref_name }}
116+
tag_name: ${{ github.event.inputs.create_release == 'true' && format('macos-{0}', github.run_number) || github.ref_name }}
117+
body: |
118+
Prebuilt dlib wheels for macOS (Intel x86_64 and Apple Silicon arm64)
119+
120+
**Supported:**
121+
- **Architectures**: x86_64 (Intel), arm64 (Apple Silicon)
122+
- **Python versions**: 3.10, 3.11, 3.12, 3.13
123+
- **macOS versions**: 10.9+ (x86_64), 11.0+ (arm64)
124+
125+
**Installation:**
126+
```bash
127+
pip install dlib-*.whl
128+
```
129+
130+
Choose the wheel that matches your:
131+
- Python version (cp310, cp311, cp312, or cp313)
132+
- Architecture (x86_64 for Intel Macs, arm64 for Apple Silicon)
133+
134+
**System Requirements:**
135+
No additional dependencies needed - wheels are self-contained with bundled libraries.
136+
files: wheels/*.whl
137+
draft: false
138+
prerelease: false
139+
env:
140+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
1-
## dlib linux python wheels
1+
## dlib python wheels
22

3-
prebuilt python wheels for dlib on linux. fast installs, zero drama.
3+
prebuilt python wheels for dlib on linux and macOS. fast installs, zero drama.
44

55
### what is dlib
66

77
dlib is a modern c++ toolkit with machine learning and computer vision tools. python bindings let you use it without touching c++.
88

99
### supported platforms
1010

11-
- **architectures**: x86_64, aarch64
12-
- **python versions**: 3.11 to 3.14
13-
- **os**: linux
11+
#### linux
12+
13+
- **architectures**: x86_64, aarch64
14+
- **python versions**: 3.11 to 3.14
15+
16+
#### macOS
17+
18+
- **architectures**: x86_64 (Intel), arm64 (Apple Silicon)
19+
- **python versions**: 3.10 to 3.13
20+
- **macOS versions**: 10.9+ (Intel), 11.0+ (Apple Silicon)
1421

1522
### quick start
1623

1724
download a wheel from releases and install with pip:
1825

26+
#### linux
27+
1928
```bash
2029
# python 3.11 x86_64
2130
pip install dlib-19.24-cp311-cp311-linux_x86_64.whl
@@ -25,14 +34,30 @@ pip install dlib-19.24-cp312-cp312-linux_aarch64.whl
2534

2635
# python 3.13 x86_64
2736
pip install dlib-19.24-cp313-cp313-linux_x86_64.whl
28-
````
37+
```
38+
39+
#### macOS
40+
41+
```bash
42+
# python 3.12 intel mac
43+
pip install dlib-19.24-cp312-cp312-macosx_10_9_x86_64.whl
44+
45+
# python 3.12 apple silicon
46+
pip install dlib-19.24-cp312-cp312-macosx_11_0_arm64.whl
47+
```
2948

3049
install directly from a release url:
3150

3251
```bash
3352
pip install https://github.com/comethrusws/Dlib_linux_python_3.x/releases/download/manual-1/dlib-20.0.99-cp310-cp310-manylinux_2_39_x86_64.whl
3453
```
3554

55+
automated installer (macOS):
56+
57+
```bash
58+
curl -sSL https://raw.githubusercontent.com/comethrusws/Dlib_linux_python_3.x/main/scripts/install_wheel_macos.sh | bash
59+
```
60+
3661
### system requirements
3762

3863
install runtime deps before installing the wheel.
@@ -56,6 +81,18 @@ sudo yum install -y \
5681
ffmpeg-devel libjpeg-turbo-devel libpng-devel libtiff-devel atlas-devel
5782
```
5883

84+
#### macOS
85+
86+
```bash
87+
# install homebrew if not already installed
88+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
89+
90+
# install dependencies (optional - wheels are self-contained)
91+
brew install cmake boost openblas
92+
```
93+
94+
**Note:** macOS wheels are self-contained with bundled dependencies, so you may not need to install additional packages.
95+
5996
### verify the install
6097

6198
```python
@@ -68,18 +105,25 @@ print("dlib installed correctly")
68105

69106
### troubleshooting
70107

71-
* **import errors**: install runtime deps, then reinstall the wheel
72-
* **arch mismatch**: wheel must match `uname -m`
108+
- **import errors**: install runtime deps, then reinstall the wheel
109+
- **arch mismatch**: wheel must match your CPU architecture
73110

74111
```bash
112+
# check your architecture
75113
uname -m
114+
# x86_64 = Intel Mac or Linux x86_64
115+
# arm64 = Apple Silicon Mac
116+
# aarch64 = Linux ARM64
76117
```
77-
* **python mismatch**: wheel must match `python --version`
118+
119+
- **python mismatch**: wheel must match `python --version`
78120

79121
```bash
80122
python --version
81123
```
82124

125+
- **macOS platform error**: make sure you download the macOS wheel (macosx*\*), not linux wheel (linux*_ or manylinux\__)
126+
83127
### build from source (optional)
84128

85129
only needed if you require a custom build:
@@ -107,6 +151,6 @@ dlib is distributed under its original license. see the license here: [https://g
107151

108152
### links
109153

110-
* dlib repo: [https://github.com/davisking/dlib](https://github.com/davisking/dlib)
111-
* docs: [http://dlib.net/](http://dlib.net/)
112-
* python examples: [https://github.com/davisking/dlib/tree/master/python_examples](https://github.com/davisking/dlib/tree/master/python_examples)
154+
- dlib repo: [https://github.com/davisking/dlib](https://github.com/davisking/dlib)
155+
- docs: [http://dlib.net/](http://dlib.net/)
156+
- python examples: [https://github.com/davisking/dlib/tree/master/python_examples](https://github.com/davisking/dlib/tree/master/python_examples)

docs/usage.md

Lines changed: 55 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
# installation guide
22

3-
how to install prebuilt dlib wheels for linux.
3+
how to install prebuilt dlib wheels for linux and macOS.
44

55
## quick install
66

7-
### direct download from repo
7+
### macOS direct install
8+
9+
```bash
10+
# automated installer (recommended)
11+
curl -sSL https://raw.githubusercontent.com/EqualByte/Dlib_linux_python_3.x/main/scripts/install_wheel_macos.sh | bash
12+
13+
# or manual install for Intel Mac (x86_64)
14+
wget https://github.com/EqualByte/Dlib_linux_python_3.x/releases/download/v19.24/dlib-19.24-cp312-cp312-macosx_10_9_x86_64.whl
15+
pip install dlib-19.24-cp312-cp312-macosx_10_9_x86_64.whl
16+
17+
# or for Apple Silicon (arm64)
18+
wget https://github.com/EqualByte/Dlib_linux_python_3.x/releases/download/v19.24/dlib-19.24-cp312-cp312-macosx_11_0_arm64.whl
19+
pip install dlib-19.24-cp312-cp312-macosx_11_0_arm64.whl
20+
```
21+
22+
### linux direct install
823

924
grab the python 3.12 wheel directly from the repo:
1025

@@ -16,9 +31,9 @@ pip install dlib-19.24-cp312-cp312-linux_x86_64.whl
1631
# aarch64
1732
wget https://raw.githubusercontent.com/EqualByte/Dlib_linux_python_3.x/main/dlib-19.24-cp312-cp312-linux_aarch64.whl
1833
pip install dlib-19.24-cp312-cp312-linux_aarch64.whl
19-
````
34+
```
2035

21-
### installation script
36+
### installation script (linux)
2237

2338
use the automated installer:
2439

@@ -37,15 +52,29 @@ pip install https://github.com/EqualByte/Dlib_linux_python_3.x/releases/download
3752

3853
## supported platforms
3954

40-
| architecture | python versions | os |
41-
| ------------ | --------------- | ----- |
42-
| x86_64 | 3.11 - 3.14 | linux |
43-
| aarch64 | 3.11 - 3.14 | linux |
55+
| OS | Architecture | Python Versions | Notes |
56+
| ----- | --------------------- | --------------- | --------------------------- |
57+
| Linux | x86_64 | 3.11 - 3.14 | manylinux2014 compatible |
58+
| Linux | aarch64 | 3.11 - 3.14 | manylinux2014 compatible |
59+
| macOS | x86_64 (Intel) | 3.10 - 3.13 | macOS 10.9+ |
60+
| macOS | arm64 (Apple Silicon) | 3.10 - 3.13 | macOS 11.0+, self-contained |
4461

4562
## system requirements
4663

4764
make sure your system has the necessary dependencies.
4865

66+
### macOS
67+
68+
```bash
69+
# install homebrew if needed
70+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
71+
72+
# install dependencies (optional - wheels are self-contained)
73+
brew install cmake boost openblas
74+
```
75+
76+
**Note:** macOS wheels include bundled dependencies, so additional installations are usually not required.
77+
4978
### ubuntu/debian
5079

5180
```bash
@@ -84,21 +113,29 @@ print("dlib installed successfully")
84113

85114
## troubleshooting
86115

87-
* **import errors**: make sure system dependencies are installed, reinstall wheel if needed
88-
* **architecture mismatch**: check `uname -m` and download correct wheel
89-
* **python version mismatch**: check `python --version` matches the wheel
116+
- **import errors**: make sure system dependencies are installed, reinstall wheel if needed
117+
- **architecture mismatch**:
118+
- Linux: check `uname -m` (x86_64 or aarch64)
119+
- macOS: check `uname -m` (x86_64 for Intel, arm64 for Apple Silicon)
120+
- Download the correct wheel for your architecture
121+
- **python version mismatch**: check `python --version` matches the wheel (cp310, cp311, cp312, cp313)
122+
- **platform mismatch**:
123+
- macOS wheels have `macosx_*` in the filename
124+
- Linux wheels have `linux_*` or `manylinux_*` in the filename
125+
- Don't try to install a Linux wheel on macOS or vice versa
90126

91127
common errors:
92128

93-
* `no module named 'dlib'`: install system dependencies first
94-
* `importerror: libboost_python`: install boost development libraries
95-
* `undefined symbol`: wrong architecture, download correct wheel
129+
- `no module named 'dlib'`: install system dependencies first (Linux only)
130+
- `importerror: libboost_python`: install boost development libraries (Linux only)
131+
- `undefined symbol`: wrong architecture, download correct wheel
132+
- `is not a supported wheel on this platform`: downloaded wrong OS/architecture wheel
96133

97134
## examples
98135

99136
see `examples/` for working demos:
100137

101-
* `basic_face_detection.py` - simple face detection example
138+
- `basic_face_detection.py` - simple face detection example
102139

103140
## build from source
104141

@@ -114,6 +151,6 @@ python setup.py install
114151

115152
## support
116153

117-
* issues: [github issues](https://github.com/EqualByte/Dlib_linux_python_3.x/issues)
118-
* documentation: [dlib.net](http://dlib.net/)
119-
* original repo: [davisking/dlib](https://github.com/davisking/dlib)
154+
- issues: [github issues](https://github.com/EqualByte/Dlib_linux_python_3.x/issues)
155+
- documentation: [dlib.net](http://dlib.net/)
156+
- original repo: [davisking/dlib](https://github.com/davisking/dlib)

0 commit comments

Comments
 (0)