Repository navigation
331 lines (283 loc) · 11 KB
/
Copy pathpythonpackage.yml
File metadata and controls
331 lines (283 loc) · 11 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
name: build
on:
push:
branches: [ main ]
tags:
- '*'
# Run on every pull request, not only those targeting main, so each layer of
# a stacked PR series is built and tested against its own base branch.
pull_request:
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.14"
- name: Install Rust
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
with:
toolchain: stable
components: rustfmt
- name: Ruff
run: |
python -m pip install --upgrade pip
# Pinned so new ruff releases cannot change the rule set under a PR.
pip install ruff==0.16.8
ruff check .
ruff format --check .
- name: Rustfmt
run: cargo fmt --check
rust-tests:
name: Rust tests on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Rust
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
with:
toolchain: stable
# SIMD tests skip backends the runner cannot execute, so record which
# instruction sets were available for this run.
- name: Report CPU
shell: bash
run: |
case "$RUNNER_OS" in
Linux)
lscpu | grep 'Model name'
for flag in sse4_1 popcnt avx2 avx512bw avx512_bitalg avx512vbmi; do
if grep -qw "$flag" /proc/cpuinfo; then echo "$flag: yes"; else echo "$flag: no"; fi
done ;;
macOS) sysctl -n machdep.cpu.brand_string ;;
Windows) powershell -Command "(Get-CimInstance Win32_Processor).Name" ;;
esac
- name: Run Rust tests
run: cargo test --no-default-features --release
pool-sanitizers:
name: Thread pool under ThreadSanitizer and Miri
runs-on: ubuntu-latest
timeout-minutes: 45
env:
# Enough workers to exercise the pool on any runner.
HEXHAMMING_NUM_THREADS: 4
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Rust nightly
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
with:
toolchain: nightly
components: rust-src, miri
- name: ThreadSanitizer
env:
RUSTFLAGS: -Zsanitizer=thread
run: cargo test -Zbuild-std --target x86_64-unknown-linux-gnu --no-default-features 'par::'
- name: Miri
env:
# The pool's workers outlive the tests by design.
MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-ignore-leaks -Zmiri-env-forward=HEXHAMMING_NUM_THREADS
run: cargo miri test --no-default-features 'par::'
x86-emulated:
name: x86 tests under Intel SDE (${{ matrix.cpu }})
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
# Runner hardware decides which SIMD backend runs natively, so the
# SSE-only, AVX2-only and AVX-512 dispatch paths are exercised on
# emulated CPUs. `expect` makes the run fail if emulation did not
# expose (or hide) the listed features.
- cpu: nhm # Nehalem: SSE4.2 + POPCNT
expect: sse4.1,popcnt,!avx2,!avx512f
- cpu: hsw # Haswell: AVX2
expect: avx2,popcnt,!avx512f
- cpu: skx # Skylake-SP: AVX-512 F/BW without BITALG/VBMI/VPOPCNTDQ
expect: avx512f,avx512bw,!avx512bitalg,!avx512vbmi,!avx512vpopcntdq
- cpu: icl # Ice Lake: AVX-512 with BITALG, VBMI and VPOPCNTDQ
expect: avx512f,avx512bw,avx512bitalg,avx512vbmi,avx512vpopcntdq
env:
SDE_RELEASE: sde-external-10.13.1-2026-07-28-lin
SDE_SHA256: 94e97d623fec54385686e1e7ba65ebc9941748c05ee451423948334892bf2b50
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.14"
- name: Install Rust
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
with:
toolchain: stable
- name: Install Intel SDE
run: |
archive="$RUNNER_TEMP/sde.tar.xz"
curl -fsSL --retry 3 -o "$archive" "https://downloadmirror.intel.com/924984/$SDE_RELEASE.tar.xz" ||
curl -fsSL --retry 3 -o "$archive" "https://github.com/petarpetrovt/setup-sde/releases/download/binaries/$SDE_RELEASE.tar.xz"
echo "$SDE_SHA256 $archive" | sha256sum -c -
tar -xJf "$archive" -C "$RUNNER_TEMP"
echo "$RUNNER_TEMP/$SDE_RELEASE" >> "$GITHUB_PATH"
# SDE injects into the child process via ptrace.
sudo sysctl -w kernel.yama.ptrace_scope=0
- name: Build
run: |
cargo test --no-default-features --release --no-run
python -m pip install --upgrade pip
pip install maturin pytest
maturin build --release
pip install target/wheels/*.whl
- name: Rust tests
env:
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER: sde64 -${{ matrix.cpu }} --
HEXHAMMING_EXPECT_X86_FEATURES: ${{ matrix.expect }}
run: cargo test --no-default-features --release
- name: Python tests
# Emulation makes wall-clock assertions meaningless, so skip the one
# timing test along with the benchmarks, and SDE cannot follow the
# execve of the test that runs Python in a subprocess.
run: >-
sde64 -${{ matrix.cpu }} -- python -m pytest -q -p no:cacheprovider test/
-k "not bench and not test_check_hexstrings_within_dist_long_random_fast
and not test_num_threads_environment_variable"
build-and-test:
name: Testing on ${{ matrix.os }} with Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
include:
# Releases ship PyPy wheels for Linux, so PyPy must keep building.
- os: ubuntu-latest
python-version: "pypy3.11"
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.python-version }}
- name: Install Rust
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
with:
toolchain: stable
- name: Install maturin and test dependencies
run: |
python -m pip install --upgrade pip
pip install maturin pytest pytest-benchmark
- name: Build and install with maturin
shell: bash
run: |
maturin build --release
pip install target/wheels/*.whl
- name: Run tests
run: pytest -vls test/
sdist:
if: startsWith(github.ref, 'refs/tags')
needs: build-and-test
name: Source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Rust
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
with:
toolchain: stable
- name: Build sdist
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1
with:
command: sdist
args: --out dist
- name: Upload sdist
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: wheels-sdist
path: dist/*.tar.gz
# Wheels built natively on their runner (Linux x86_64, macOS arm64,
# Windows) are PGO builds; see pgo-wheels.yml.
wheels_pgo:
if: startsWith(github.ref, 'refs/tags')
needs: build-and-test
name: Build PGO wheels
uses: ./.github/workflows/pgo-wheels.yml
# Cross-built wheels cannot run the PGO training on the runner.
wheels_linux:
if: startsWith(github.ref, 'refs/tags')
needs: build-and-test
name: Build Linux ${{ matrix.target }} wheels
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
target: [aarch64]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up QEMU
if: matrix.target == 'aarch64'
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3
with:
platforms: arm64
- name: Build wheels
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter
manylinux: auto
before-script-linux: |
# Install Rust in manylinux container
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME/.cargo/env
- name: Upload wheels
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: wheels-linux-${{ matrix.target }}
path: dist/*.whl
if-no-files-found: error
wheels_macos:
if: startsWith(github.ref, 'refs/tags')
needs: build-and-test
name: Build macOS ${{ matrix.target }} wheels
runs-on: macos-latest
strategy:
fail-fast: true
matrix:
target: [x86_64]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Build wheels
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1
with:
target: x86_64-apple-darwin
args: --release --out dist
- name: Upload wheels
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: wheels-macos-${{ matrix.target }}
path: dist/*.whl
if-no-files-found: error
publish-wheels:
if: startsWith(github.ref, 'refs/tags')
needs: [sdist, wheels_pgo, wheels_linux, wheels_macos]
name: Publish wheels
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: dist
pattern: wheels-*
merge-multiple: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
with:
packages-dir: dist/