-
-
Notifications
You must be signed in to change notification settings - Fork 103
409 lines (388 loc) · 13.4 KB
/
ci.yml
File metadata and controls
409 lines (388 loc) · 13.4 KB
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
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
# This file is autogenerated by maturin v1.8.2
# To update, run
#
# maturin generate-ci github
#
name: CI
on:
push:
tags:
- "*"
pull_request:
paths-ignore:
- "docs/**"
- "bench/**"
- "*.pyi"
- "*.md"
- ".github/**"
- "python/**"
- "README.md"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
permissions:
contents: write
packages: write
env:
MATURIN_VERSION: ${{ vars.MATURIN_VERSION }}
jobs:
style:
name: style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy
override: true
- name: Style check
run: cargo fmt --all -- --check
- name: Clippy check
run: cargo clippy --all-targets -- -D warnings
tests:
runs-on: ubuntu-latest
services:
httpbin:
image: kennethreitz/httpbin
ports:
- 8080:80
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: 3.x
architecture: ${{ matrix.platform.target }}
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v7
- name: Set up virtual environment
run: |
uv venv
source .venv/bin/activate
- name: Install dependencies
run: |
uv pip install .[test]
uv pip install maturin
- name: Build wheels
run: |
source .venv/bin/activate
maturin develop --uv
- name: Run tests
run: |
source .venv/bin/activate
pytest
manylinux:
runs-on: ${{ matrix.platform.runner }}
strategy:
fail-fast: false
matrix:
build_type:
- name: standard
maturin_args: "--find-interpreter"
- name: free-threaded
maturin_args: "--interpreter 3.13t 3.14t"
platform:
- runner: ubuntu-latest
target: x86_64
allocator: jemalloc
apt_packages: ""
custom_env: {}
- runner: ubuntu-latest
target: x86
allocator: jemalloc
apt_packages: crossbuild-essential-i386
custom_env:
CC: i686-linux-gnu-gcc
CXX: i686-linux-gnu-g++
CFLAGS: -msse2
CXXFLAGS: -msse2
CFLAGS_i686_unknown_linux_gnu: -msse2
CXXFLAGS_i686_unknown_linux_gnu: -msse2
CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER: i686-linux-gnu-g++
- runner: ubuntu-latest
target: aarch64
allocator: jemalloc
apt_packages: crossbuild-essential-arm64
custom_env:
CC: aarch64-linux-gnu-gcc
CXX: aarch64-linux-gnu-g++
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-g++
- runner: ubuntu-latest
target: armv7
allocator: jemalloc
apt_packages: crossbuild-essential-armhf
custom_env:
CC: arm-linux-gnueabihf-gcc
CXX: arm-linux-gnueabihf-g++
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-g++
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: 3.x
- name: Install target-specific APT dependencies
if: "matrix.platform.apt_packages != ''"
run: sudo apt-get update && sudo apt-get install -y ${{ matrix.platform.apt_packages }}
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
maturin-version: ${{ env.MATURIN_VERSION }}
rust-toolchain: stable
target: ${{ matrix.platform.target }}
args: ${{ matrix.platform.target == 'x86_64' && '--release --out dist --zig' || '--release --out dist' }} ${{ matrix.build_type.maturin_args }} --features ${{ matrix.platform.allocator }}
sccache: "false"
manylinux: auto
container: "off"
env: ${{ matrix.platform.custom_env }}
- name: Upload wheels
uses: actions/upload-artifact@v7
with:
name: wheels-linux-${{ matrix.platform.target }}-${{ matrix.build_type.name }}
path: dist
musllinux:
runs-on: ${{ matrix.platform.runner }}
environment: MuslLinux
strategy:
matrix:
build_type:
- name: standard
maturin_args: "--find-interpreter"
- name: free-threaded
maturin_args: "--interpreter 3.13t 3.14t"
platform:
- runner: ubuntu-22.04
target: x86_64-unknown-linux-musl
allocator: jemalloc
- runner: ubuntu-22.04
target: aarch64-unknown-linux-musl
allocator: jemalloc
- runner: ubuntu-22.04
target: armv7-unknown-linux-musleabihf
allocator: jemalloc
- runner: ubuntu-22.04
target: i686-unknown-linux-musl
allocator: jemalloc
steps:
- uses: actions/checkout@v6
- name: Build wheels
env:
MATURIN_VERSION: ${{ env.MATURIN_VERSION }}
BORING_BSSL_RUST_CPPLIB: static=stdc++
run: |
export RUSTFLAGS="${RUSTFLAGS:+$RUSTFLAGS }-L native=/usr/local/musl/${{ matrix.platform.target }}/lib -L native=/usr/local/musl/lib/gcc/${{ matrix.platform.target }}/11.4.0 -C link-arg=-static-libgcc -l static=gcc"
if [ "${{ matrix.platform.target }}" = "i686-unknown-linux-musl" ]; then
export CFLAGS="${CFLAGS} -msse2"
export CXXFLAGS="${CXXFLAGS} -msse2"
fi
bash .github/musl_build.sh ${{ matrix.platform.target }} "${{ matrix.build_type.maturin_args }}" --features "${{ matrix.platform.allocator }}"
- name: Upload wheels
uses: actions/upload-artifact@v7
with:
name: wheels-musllinux-${{ matrix.platform.target }}-${{ matrix.build_type.name }}
path: dist
windows:
runs-on: windows-latest
environment: Windows
strategy:
matrix:
build_type:
- name: standard
maturin_args: ""
cargo_args: ""
- name: free-threaded
maturin_args: "--interpreter 3.13t 3.14t"
cargo_args: "--no-default-features"
platform:
- target: x64
allocator: mimalloc
python-architecture: x64
- target: x86
allocator: mimalloc
python-architecture: x86
- target: aarch64
allocator: mimalloc
python-architecture: x64
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: 3.x
architecture: ${{ matrix.platform.python-architecture || 'x64' }}
- name: Install NASM
run: |
choco install nasm -y
shell: cmd
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
maturin-version: ${{ env.MATURIN_VERSION }}
target: ${{ matrix.platform.target }}
args: --release --out dist ${{ matrix.build_type.maturin_args || '' }} ${{ matrix.build_type.cargo_args }} --features ${{ matrix.platform.allocator || '' }}
sccache: "false"
- name: Upload wheels
uses: actions/upload-artifact@v7
with:
name: wheels-windows-${{ matrix.platform.target }}-${{ matrix.build_type.name }}
path: dist
macos:
runs-on: ${{ matrix.platform.runner }}
environment: MacOS
strategy:
matrix:
build_type:
- name: standard
maturin_args: "--find-interpreter"
- name: free-threaded
maturin_args: "--interpreter 3.13t 3.14t"
platform:
- runner: macos-latest
target: x86_64
allocator: jemalloc
- runner: macos-latest
target: aarch64
allocator: jemalloc
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: 3.x
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
maturin-version: ${{ env.MATURIN_VERSION }}
target: ${{ matrix.platform.target }}
args: --release --out dist ${{ matrix.build_type.maturin_args }} --features ${{ matrix.platform.allocator || '' }}
sccache: "false"
- name: Upload wheels
uses: actions/upload-artifact@v7
with:
name: wheels-macos-${{ matrix.platform.target }}-${{ matrix.build_type.name }}
path: dist
android:
name: Android
runs-on: ubuntu-latest
strategy:
matrix:
include:
- thing: arm64-android
target: aarch64-linux-android
arch: aarch64
python_version: 3.14.0
features: abi3-py314
- thing: x86_64-android
target: x86_64-linux-android
arch: x86_64
python_version: 3.14.0
features: abi3-py314
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: 3.x
- name: Set Android Linker path
if: endsWith(matrix.thing, '-android')
run: |
LINKER_PATH="$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/$(echo ${{ matrix.target }} | sed s/armv7/armv7a/)21-clang++"
echo "CARGO_TARGET_$(echo ${{ matrix.target }} | tr \\-a-z _A-Z)_LINKER=$LINKER_PATH" >> "$GITHUB_ENV"
echo "$PATH:$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin" >> "$GITHUB_PATH"
env
- name: Download and setup Android Python
run: |
wget https://www.python.org/ftp/python/${{ matrix.python_version }}/python-${{ matrix.python_version }}-${{ matrix.arch }}-linux-android.tar.gz
mkdir -p /tmp/python-android
tar -xzf python-${{ matrix.python_version }}-${{ matrix.arch }}-linux-android.tar.gz -C /tmp/python-android --strip-components=1
mv /tmp/python-android/prefix/lib /tmp/python-android/
mv /tmp/python-android/prefix/include /tmp/python-android/
echo "RUSTFLAGS=-L native=/tmp/python-android/lib" >> "$GITHUB_ENV"
echo "=== Root directory after move ==="
ls -la /tmp/python-android/
echo "=== Lib directory ==="
ls -la /tmp/python-android/lib/ | head -10
echo "=== Include directory ==="
ls -la /tmp/python-android/include/
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
maturin-version: ${{ env.MATURIN_VERSION }}
rust-toolchain: stable
target: ${{ matrix.target }}
args: --release --out dist --no-default-features --features ${{ matrix.features }} --skip-auditwheel
sccache: "false"
container: "off"
- name: Fix Android wheel platform tags
run: |
cd dist
for wheel in *.whl; do
case "$wheel" in
*linux_aarch64*)
new_wheel=${wheel/linux_aarch64/android_21_arm64_v8a}
mv "$wheel" "$new_wheel"
echo "Renamed: $wheel -> $new_wheel"
;;
*linux_x86_64*)
new_wheel=${wheel/linux_x86_64/android_21_x86_64}
mv "$wheel" "$new_wheel"
echo "Renamed: $wheel -> $new_wheel"
;;
esac
done
- name: Upload wheels
uses: actions/upload-artifact@v7
with:
name: wheels-android-${{ matrix.target }}
path: dist
sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
maturin-version: ${{ env.MATURIN_VERSION }}
command: sdist
args: --out dist
- name: Upload sdist
uses: actions/upload-artifact@v7
with:
name: wheels-sdist
path: dist
release:
name: Release
runs-on: ubuntu-latest
needs: [manylinux, musllinux, windows, macos, android, sdist, tests, style]
permissions:
# Use to sign the release artifacts
id-token: write
# Used to upload release artifacts
contents: write
# Used to generate artifact attestation
attestations: write
steps:
- uses: actions/download-artifact@v8
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v7
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v4
with:
subject-path: "wheels-*/*"
- name: Dry-run publish to PyPI
env:
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: uv publish --dry-run wheels-*/*
- name: Publish to PyPI
if: ${{ startsWith(github.ref, 'refs/tags/') }}
env:
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: uv publish wheels-*/*
- name: Upload binaries to GitHub Release
uses: softprops/action-gh-release@v3
if: startsWith(github.ref, 'refs/tags/')
with:
token: ${{ secrets.GITHUB_TOKEN }}
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') }}
generate_release_notes: true