-
Notifications
You must be signed in to change notification settings - Fork 9
366 lines (333 loc) · 11.2 KB
/
build_wheels.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
name: Build wheels
on:
push:
paths:
- ".github/workflows/build_wheels.yml"
- "MANIFEST.in"
- "pyproject.toml"
- "setup.py"
branches:
- main
tags:
- "v*"
pull_request:
paths:
- ".github/workflows/build_wheels.yml"
- "MANIFEST.in"
- "pyproject.toml"
- "setup.py"
workflow_dispatch:
env:
BUILD_TEMP_DIR: "build"
MACOSX_DEPLOYMENT_TARGET: "12"
jobs:
build_wheels:
name: BLD ${{ matrix.os }} ${{ matrix.platform }} (Python ${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- "ubuntu-24.04"
- "ubuntu-22.04"
- "ubuntu-20.04"
- "macos-14"
include:
- os: "ubuntu-24.04"
platform: "x86_64"
wheel: pymgl-wheel-ubuntu-24.04-x86_64
- os: "ubuntu-22.04"
platform: "x86_64"
wheel: pymgl-wheel-ubuntu-22.04-x86_64
- os: "ubuntu-20.04"
platform: "x86_64"
wheel: pymgl-wheel-ubuntu-20.04-x86_64
- os: "macos-14"
platform: "arm64"
wheel: pymgl-wheel-macos-arm64
- os: "macos-13"
platform: "x86_64"
wheel: pymgl-wheel-macos-x86_64
python-version: ["3.9", "3.10", "3.11", "3.12"]
env:
PLATFORM_OS: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout submodules
run: |
git submodule update --init
cd vendor/nanobind && \
git submodule update --init --recursive
cd ../maplibre-native && \
git submodule update --init --recursive \
vendor/boost \
vendor/cpp-httplib \
vendor/earcut.hpp \
vendor/eternal \
vendor/googletest \
vendor/polylabel \
vendor/protozero \
vendor/mapbox-base \
vendor/unique_resource \
vendor/unordered_dense \
vendor/vector-tile \
vendor/wagyu \
vendor/zip-archive
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get -y install software-properties-common
sudo add-apt-repository -y ppa:deadsnakes/ppa
sudo apt-get -y install \
curl \
build-essential \
cmake \
ccache \
pkg-config \
libcurl4-openssl-dev \
libicu-dev \
libjpeg-turbo8-dev \
libpng-dev \
libwebp-dev \
libprotobuf-dev \
libuv1-dev \
libx11-dev \
libegl-dev \
libopengl-dev \
libgles2-mesa-dev \
xvfb
sudo /usr/sbin/update-ccache-symlinks
- name: fix Ubuntu 20.04 GCC
if: ${{ matrix.os == 'ubuntu-20.04' }}
run: |
sudo add-apt-repository --update -y ppa:ubuntu-toolchain-r/test && \
sudo apt-get -y --fix-broken install gcc-11 g++-11
- name: Install MacOS dependencies
if: runner.os == 'macOS'
env:
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
run: |
brew install ccache
- name: Install python & dependencies
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh && \
. $HOME/.cargo/env && \
uv python install ${{ matrix.python-version }} && \
uv venv .venv
echo "VIRTUAL_ENV=.venv" >> $GITHUB_ENV
echo "$PWD/.venv/bin" >> $GITHUB_PATH
uv pip install versioneer[toml]==0.29 tomli setuptools ninja
- name: Prepare ccache
run: ccache --clear --set-config cache_dir=~/.ccache
- name: Cache ccache
uses: actions/cache@v4
env:
cache-name: ccache-v1
with:
path: ~/.ccache
key: ${{ env.cache-name }}-${{ matrix.os }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }}-${{ github.head_ref }}
restore-keys: |
${{ env.cache-name }}-${{ matrix.os }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }}
${{ env.cache-name }}-${{ matrix.os }}-${{ github.job }}-${{ github.ref }}
${{ env.cache-name }}-${{ matrix.os }}-${{ github.job }}
- name: Clear ccache statistics
run: |
ccache --zero-stats --set-config cache_dir=~/.ccache
ccache --max-size=2G --set-config cache_dir=~/.ccache
ccache --show-stats --set-config cache_dir=~/.ccache
- name: Set platform tag for Ubuntu 24.04
if: matrix.os == 'ubuntu-24.04'
run: echo "PLATFORM_TAG=ubuntu24_04_x86_64" >> $GITHUB_ENV
- name: Set platform tag for Ubuntu 22.04
if: matrix.os == 'ubuntu-22.04'
run: echo "PLATFORM_TAG=ubuntu22_04_x86_64" >> $GITHUB_ENV
- name: Set platform tag for Ubuntu 20.04
if: matrix.os == 'ubuntu-20.04'
run: echo "PLATFORM_TAG=ubuntu20_04_x86_64">> $GITHUB_ENV
- name: Build package for Ubuntu
if: runner.os == 'Linux'
env:
CMAKE_CXX_COMPILER_LAUNCHER: ccache
run: |
sudo mkdir -p $BUILD_TEMP_DIR
sudo chown -R $(id -u):$(id -g) $BUILD_TEMP_DIR
uv build --wheel
echo "List wheels"
ls ./dist
find ./dist -type f -name '*.whl' -exec mv {} {}.$PLATFORM_OS \;
echo "Renamed with $PLATFORM_OS suffix"
ls ./dist
- name: Build package for MacOS
if: runner.os == 'macOS'
env:
CMAKE_CXX_COMPILER_LAUNCHER: ccache
run: |
sudo mkdir -p $BUILD_TEMP_DIR
sudo chown -R $(id -u):$(id -g) $BUILD_TEMP_DIR
uv build --wheel
- name: "Upload artifacts"
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.wheel }}-${{ matrix.python-version }}
path: ./dist/*
test-wheels:
name: TST ${{ matrix.os }} ${{ matrix.platform }} (Python ${{ matrix.python-version }})
needs: [build_wheels]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- "ubuntu-24.04"
- "ubuntu-22.04"
- "ubuntu-20.04"
- "macos-14"
- "macos-13"
- "macos-12"
include:
- os: "ubuntu-24.04"
platform: "x86_64"
wheel: pymgl-wheel-ubuntu-24.04-x86_64
- os: "ubuntu-22.04"
platform: "x86_64"
wheel: pymgl-wheel-ubuntu-22.04-x86_64
- os: "ubuntu-20.04"
platform: "x86_64"
wheel: pymgl-wheel-ubuntu-20.04-x86_64
- os: "macos-14"
platform: "arm64"
wheel: pymgl-wheel-macos-arm64
- os: "macos-13"
platform: "x86_64"
wheel: pymgl-wheel-macos-x86_64
- os: "macos-12"
platform: "x86_64"
wheel: pymgl-wheel-macos-x86_64
python-version: ["3.9", "3.10", "3.11", "3.12"]
env:
PLATFORM_OS: ${{ matrix.os }}
LIBGL_ALWAYS_SOFTWARE: 1
steps:
- name: Download wheels from artifacts
uses: actions/download-artifact@v4
with:
pattern: ${{ matrix.wheel }}-${{ matrix.python-version }}
path: wheelhouse
merge-multiple: true
- name: Install Ubuntu 24.04 runtime dependencies
if: matrix.os == 'ubuntu-24.04'
run: |
sudo apt-get update
sudo apt-get -y install \
libicu74 \
libcurl4 \
libjpeg-turbo8 \
libpng16-16 \
libwebp7 \
libprotobuf32 \
libuv1 \
libx11-6 \
libegl1 \
libopengl0 \
libgles2 \
xvfb && \
# upgrade Mesa packages
sudo apt-get install -y software-properties-common && \
sudo add-apt-repository -y ppa:kisak/kisak-mesa && \
sudo apt-get update && \
sudo apt-get install -y libglx-mesa0
- name: Install Ubuntu 22.04 runtime dependencies
if: matrix.os == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get -y install \
libicu70 \
libcurl4 \
libjpeg-turbo8 \
libpng16-16 \
libwebp7 \
libprotobuf23 \
libuv1 \
libx11-6 \
libegl1 \
libopengl0 \
libgles2 \
xvfb
- name: Install Ubuntu 20.04 runtime dependencies
if: matrix.os == 'ubuntu-20.04'
run: |
sudo apt-get update
sudo apt-get -y install \
libicu66 \
libcurl4 \
libjpeg-turbo8 \
libpng16-16 \
libwebp6 \
libprotobuf17 \
libuv1 \
libx11-6 \
libegl1 \
libopengl0 \
libgles2 \
xvfb
- name: Install python & dependencies
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh && \
. $HOME/.cargo/env && \
uv python install ${{ matrix.python-version }} && \
uv venv .venv
echo "VIRTUAL_ENV=.venv" >> $GITHUB_ENV
echo "$PWD/.venv/bin" >> $GITHUB_PATH
uv pip install pytest Pillow numpy pixelmatch python-dotenv
- name: Install and test wheels on Ubuntu
if: runner.os == 'Linux'
run: |
find ./wheelhouse -type f -name "*.whl.$PLATFORM_OS" -print0 -exec bash -c 'mv "${0}" "${0//.$PLATFORM_OS/}"' {} \;
uv pip install --no-cache --pre --no-index --find-links wheelhouse pymgl
uv pip list
xvfb-run -a --server-args="-screen 0 1024x768x24 -ac +render -noreset" pytest --pyargs pymgl -v
- name: Install and test wheels on MacOS
if: runner.os == 'macOS'
run: |
uv pip install --no-cache --pre --no-index --find-links wheelhouse pymgl
uv pip list
cd ..
pytest --pyargs pymgl -v
# NOTE: publish is limited to MacOS wheels because Linux wheels are not accepted
# for only Ubuntu, must be manylinux
publish:
name: Publish to GitHub / PyPI
needs: [test-wheels]
runs-on: ubuntu-latest
# only publish on tags
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v4
with:
pattern: pymgl-wheel-*
path: wheelhouse
merge-multiple: true
# NOTE: MacOS wheel are the only ones that can be published to PyPI
- name: Copy MacOS wheel
run: |
mkdir wheelhouse/dist
cp wheelhouse/*macos*.whl wheelhouse/dist
- name: Publish MacOS wheel to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: wheelhouse/dist/
- name: Release
uses: softprops/action-gh-release@v2
with:
name: Version ${{ github.ref_name }}
tag_name: ${{ github.ref }}
draft: false
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}
files: |
./wheelhouse/*