Repository navigation
393 lines (360 loc) · 14.8 KB
/
Copy pathpython-dist.yml
File metadata and controls
393 lines (360 loc) · 14.8 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
name: Python Distributions
# The release's Python build: every wheel leg and the sdist, then each baseline
# wheel and the sdist installed and smoke-tested. release.yml calls this on a
# tag and uploads what it built; release-rehearsal.yml calls it and publishes
# nothing. Build steps live only here, so the two cannot drift apart.
on:
workflow_call:
inputs:
sccache:
description: Cache compiler output with sccache
type: boolean
default: true
permissions:
contents: read
env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUST_BACKTRACE: short
RUSTUP_MAX_RETRIES: 10
jobs:
python-interpreters:
name: Python Interpreter Contract
runs-on: ubuntu-latest
outputs:
setup-versions: ${{ steps.contract.outputs.setup-versions }}
steps:
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@v7
with:
python-version: '3.14'
- name: Validate metadata and generate build interpreters
id: contract
run: python .github/scripts/wheel_interpreters.py --github-output "$GITHUB_OUTPUT"
# Build Python wheels for the base public package API.
python-wheels:
name: Build Python Wheels (${{ matrix.os }}-${{ matrix.target }}-${{ matrix.cpu_profile }})
runs-on: ${{ matrix.os }}
needs: python-interpreters
strategy:
# One runner failing (sccache server startup on macos-15-intel timed out
# during the first v0.9.0 attempt) must not cancel the other eight wheels.
# Let them finish so a re-run only has to retry the one that broke.
fail-fast: false
matrix:
include:
# Baseline compatibility builds (maximum compatibility)
- os: ubuntu-latest
target: x86_64
cpu_profile: baseline
rustflags: "-C target-cpu=x86-64 -C target-feature=-avx,-avx2,-avx512f -C opt-level=2"
- os: ubuntu-latest
target: aarch64
cpu_profile: baseline
rustflags: "-C target-cpu=generic -C opt-level=2"
# manylinux2014's aarch64 cross image ships GCC 4.8.5, which does
# not define __ARM_ARCH; ring's assembly refuses to build without
# it and upstream closed that WONTFIX (briansmith/ring#1728).
# 2_28 ships GCC 7.5. Raises this arch's glibc floor 2.17 -> 2.28.
manylinux: '2_28'
- os: windows-latest
target: x64
cpu_profile: baseline
rustflags: "-C target-cpu=x86-64 -C target-feature=-avx,-avx2,-avx512f -C opt-level=2"
- os: macos-15-intel
target: x86_64
cpu_profile: baseline
rustflags: "-C target-cpu=x86-64 -C target-feature=-avx,-avx2,-avx512f -C opt-level=2"
- os: macos-latest
target: aarch64
cpu_profile: baseline
# No -C target-cpu: `generic` strips neon/aes/sha2/pmull, which
# ring asserts are statically present on aarch64-apple-darwin
# (src/cpu/arm/darwin.rs). Every arm64 Mac has them, so `generic`
# bought no compatibility and cost performance.
rustflags: "-C opt-level=2"
# Optimized builds (performance optimized)
- os: ubuntu-latest
target: x86_64
cpu_profile: optimized
rustflags: "-C target-cpu=native"
- os: windows-latest
target: x64
cpu_profile: optimized
rustflags: "-C target-cpu=native"
- os: macos-15-intel
target: x86_64
cpu_profile: optimized
rustflags: "-C target-cpu=native"
- os: macos-latest
target: aarch64
cpu_profile: optimized
# The same ring constraint as the baseline leg above, from the
# other side. ring asserts `CAPS_STATIC == MIN_STATIC_FEATURES`
# exactly on aarch64-apple-darwin (src/cpu/arm/darwin.rs), so
# `native` fails on a current Apple Silicon runner by enabling
# more than that baseline, just as `generic` failed by enabling
# less. rustc already defaults this target to apple-m1, which is
# what `native` was reaching for, so dropping it costs nothing.
rustflags: "-C opt-level=3"
steps:
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@v7
with:
# Install every declared version on Windows/macOS. Linux builds run
# inside manylinux, where maturin selects the explicit names below.
python-version: ${{ needs.python-interpreters.outputs.setup-versions }}
- name: Install uv for host interpreter discovery
if: runner.os != 'Linux'
uses: astral-sh/setup-uv@v7
- name: Select build interpreters
id: build-interpreters
# Linux needs names inside manylinux; Windows/macOS use installed host paths.
run: python .github/scripts/wheel_interpreters.py --github-output "$GITHUB_OUTPUT" ${{ runner.os != 'Linux' && '--resolve-interpreters' || '' }}
shell: bash
- name: Read the pinned toolchain
id: toolchain
shell: bash
run: |
channel=$(sed -n 's/^channel *= *"\(.*\)"$/\1/p' rust-toolchain.toml)
if [ -z "$channel" ]; then
echo "::error::no channel in rust-toolchain.toml"
exit 1
fi
echo "channel=$channel" >> "$GITHUB_OUTPUT"
- name: Build wheels (${{ matrix.cpu_profile }})
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
# The shipped feature set is declared once, in `[tool.maturin] features`
# in pyproject.toml; building without --features keeps the wheel and the
# PEP 517 sdist build from silently diverging (see issue #589).
args: --release --out dist --interpreter ${{ steps.build-interpreters.outputs.interpreters }}
sccache: ${{ inputs.sccache }}
manylinux: ${{ matrix.manylinux || 'auto' }}
# Ensure compatibility flags are properly set
rust-toolchain: ${{ steps.toolchain.outputs.channel }}
env:
RUSTFLAGS: ${{ matrix.rustflags }}
# Additional environment variables to ensure compatibility for all targets
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS: ${{ matrix.rustflags }}
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS: ${{ matrix.rustflags }}
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUSTFLAGS: ${{ matrix.rustflags }}
CARGO_TARGET_X86_64_APPLE_DARWIN_RUSTFLAGS: ${{ matrix.rustflags }}
CARGO_TARGET_AARCH64_APPLE_DARWIN_RUSTFLAGS: ${{ matrix.rustflags }}
# Disable CPU-specific optimizations in C dependencies (Linux/macOS x86_64 only)
CFLAGS: ${{ matrix.target == 'x86_64' && '-march=x86-64' || '' }}
CXXFLAGS: ${{ matrix.target == 'x86_64' && '-march=x86-64' || '' }}
- name: Verify published interpreter and ABI set
run: python .github/scripts/wheel_interpreters.py --wheels dist
shell: bash
- name: Verify wheel compatibility (baseline only)
if: matrix.cpu_profile == 'baseline'
run: |
# Install objdump/readelf for analysis (Linux only for now)
if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
echo "Verifying baseline wheel has no advanced CPU instructions..."
cd dist
for wheel in *.whl; do
if [ -f "$wheel" ]; then
echo "Analyzing wheel: $wheel"
# Extract wheel and find .so files
python -m zipfile -e "$wheel" wheel_extracted/
# Check for advanced CPU instructions in shared libraries
find wheel_extracted/ -name "*.so" -exec sh -c '
echo "Checking $1 for advanced CPU instructions..."
if objdump -d "$1" 2>/dev/null | grep -E "(vzeroupper|vmovdqu|vpor|vpaddd)" >/dev/null; then
echo "WARNING: Found AVX instructions in $1"
echo "This wheel may not be compatible with older CPUs"
else
echo "OK: No advanced CPU instructions found in $1"
fi
' _ {} \;
rm -rf wheel_extracted/
fi
done
else
echo "Skipping compatibility check on ${{ matrix.os }}"
fi
shell: bash
- name: Rename wheels with CPU profile suffix
run: |
cd dist
for wheel in *.whl; do
if [ -f "$wheel" ]; then
# Only rename optimized wheels - baseline wheels keep standard names for PyPI
if [ "${{ matrix.cpu_profile }}" = "optimized" ]; then
base_name="${wheel%.whl}"
new_name="${base_name}-optimized.whl"
mv "$wheel" "$new_name"
echo "Renamed optimized wheel: $wheel -> $new_name"
else
echo "Keeping baseline wheel name: $wheel"
fi
fi
done
shell: bash
- name: Upload wheels as artifacts
uses: actions/upload-artifact@v7
with:
name: wheels-${{ matrix.os }}-${{ matrix.target }}-${{ matrix.cpu_profile }}
path: dist
# Build an sdist so unsupported environments still have an install path.
python-sdist:
name: Build Python sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@v7
with:
python-version: '3.11'
- name: Read the pinned toolchain
id: toolchain
shell: bash
run: |
channel=$(sed -n 's/^channel *= *"\(.*\)"$/\1/p' rust-toolchain.toml)
if [ -z "$channel" ]; then
echo "::error::no channel in rust-toolchain.toml"
exit 1
fi
echo "channel=$channel" >> "$GITHUB_OUTPUT"
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
manylinux: auto
rust-toolchain: ${{ steps.toolchain.outputs.channel }}
- name: Upload sdist as artifact
uses: actions/upload-artifact@v7
with:
name: python-sdist
path: dist/*.tar.gz
# A wheel that builds can still fail to install or import where it runs, and
# the aarch64 Linux leg is cross-compiled, so before this job nothing ran its
# wheels before users did. Each baseline wheel goes into a bare venv on its
# own platform, one interpreter at a time, and runs the wheel smoke test,
# which also checks the wheel names the commit it was built from. Optimized
# wheels target the build runner's CPU, which another runner need not share,
# so they are not installed here.
wheel-install:
name: Install Wheels (${{ matrix.runner }})
runs-on: ${{ matrix.runner }}
needs: [python-interpreters, python-wheels]
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
artifact: wheels-ubuntu-latest-x86_64-baseline
- runner: ubuntu-24.04-arm
artifact: wheels-ubuntu-latest-aarch64-baseline
- runner: windows-latest
artifact: wheels-windows-latest-x64-baseline
- runner: macos-15-intel
artifact: wheels-macos-15-intel-x86_64-baseline
- runner: macos-latest
artifact: wheels-macos-latest-aarch64-baseline
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@v7
with:
python-version: ${{ needs.python-interpreters.outputs.setup-versions }}
- name: Install uv for interpreter discovery
uses: astral-sh/setup-uv@v7
- name: Download this platform's baseline wheels
uses: actions/download-artifact@v8
with:
name: ${{ matrix.artifact }}
path: dist
- name: Install and smoke-test each interpreter's wheel
env:
# Every job of a run checks out the same commit, so each wheel must
# name it.
DATAPROF_EXPECTED_COMMIT: ${{ github.sha }}
# One minor version per line.
VERSIONS: ${{ needs.python-interpreters.outputs.setup-versions }}
run: |
cp .github/scripts/wheel_smoke.py "$RUNNER_TEMP/wheel_smoke.py"
failed=0
{
echo "### ${{ matrix.artifact }}"
echo ""
echo "| Interpreter | Wheel | Installs | Smoke test |"
echo "|---|---|---|---|"
} >> "$GITHUB_STEP_SUMMARY"
for version in $VERSIONS; do
tag="cp${version/./}"
wheel=$(find dist -maxdepth 1 -name "dataprof-*-${tag}-${tag}-*.whl" | head -n 1)
built="missing"
installs="not run"
smoke="not run"
if [ -n "$wheel" ]; then
built="$(basename "$wheel")"
python=$(uv python find --system --no-python-downloads "$version")
venv="$RUNNER_TEMP/venv-$tag"
"$python" -m venv "$venv"
venv_python="$venv/bin/python"
[ -x "$venv_python" ] || venv_python="$venv/Scripts/python.exe"
echo "::group::CPython $version: $built"
# --no-index: the base wheel declares no dependencies.
if "$venv_python" -m pip install --no-index "$wheel"; then
installs="yes"
# From outside the checkout, so the import cannot resolve to python/.
if (cd "$RUNNER_TEMP" && "$venv_python" wheel_smoke.py); then
smoke="passed"
else
smoke="failed"
fi
else
installs="failed"
fi
echo "::endgroup::"
fi
echo "| $version | $built | $installs | $smoke |" >> "$GITHUB_STEP_SUMMARY"
if [ "$smoke" != "passed" ]; then
echo "::error::CPython $version on ${{ matrix.runner }}: wheel $built, installs $installs, smoke test $smoke"
failed=1
fi
done
exit "$failed"
# The sdist is the install path everywhere no wheel fits. Build and install
# it the way pip does there, then run the same smoke test. It carries no git
# metadata, so the package built from it records no commit.
sdist-install:
name: Install sdist
runs-on: ubuntu-latest
needs: python-sdist
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@v7
with:
python-version: '3.11'
- name: Download sdist
uses: actions/download-artifact@v8
with:
name: python-sdist
path: dist
- name: Build, install and smoke-test the sdist
run: |
python -m venv "$RUNNER_TEMP/venv"
"$RUNNER_TEMP/venv/bin/python" -m pip install dist/*.tar.gz
cp .github/scripts/wheel_smoke.py "$RUNNER_TEMP/wheel_smoke.py"
cd "$RUNNER_TEMP"
"$RUNNER_TEMP/venv/bin/python" wheel_smoke.py