Repository navigation
Expand file tree
/
Copy pathpython-native-qualification.yml
More file actions
260 lines (252 loc) · 14.2 KB
/
Copy pathpython-native-qualification.yml
File metadata and controls
260 lines (252 loc) · 14.2 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
name: Python native qualification
on:
workflow_dispatch:
pull_request:
paths:
- "bindings/python/**"
- "src/**"
- "Cargo.toml"
- "Cargo.lock"
- "deny.toml"
- ".github/workflows/python-native-qualification.yml"
push:
branches:
- main
- plan/python-native-library
paths:
- "bindings/python/**"
- "src/**"
- "Cargo.toml"
- "Cargo.lock"
- "deny.toml"
- ".github/workflows/python-native-qualification.yml"
permissions:
contents: read
jobs:
build-wheel:
name: Build ${{ matrix.target }} CPython ${{ matrix.python }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- { id: linux-x86_64, runner: ubuntu-24.04, target: x86_64-unknown-linux-gnu, python: "3.11", linux: true }
- { id: linux-aarch64, runner: ubuntu-24.04-arm, target: aarch64-unknown-linux-gnu, python: "3.11", linux: true }
- { id: macos-x86_64, runner: macos-15-intel, target: x86_64-apple-darwin, python: "3.11", linux: false }
- { id: macos-arm64, runner: macos-15, target: aarch64-apple-darwin, python: "3.11", linux: false }
- { id: windows-x86_64, runner: windows-2022, target: x86_64-pc-windows-msvc, python: "3.11", linux: false }
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
python-version: ${{ matrix.python }}
- name: Check candidate package metadata
run: |
python -c "import tomllib; from pathlib import Path; project=tomllib.loads(Path('bindings/python/pyproject.toml').read_text())['project']; binding=tomllib.loads(Path('bindings/python/Cargo.toml').read_text())['package']; root=tomllib.loads(Path('Cargo.toml').read_text())['package']; assert project['name'] == 'eggsearch'; assert project['license'] == 'MIT'; assert project['version'] == binding['version'] == root['version']; assert project['requires-python'] == '>=3.11,<3.16'; assert all(f'Programming Language :: Python :: 3.{minor}' in project['classifiers'] for minor in range(11,16)); assert 'abi3-py311' in Path('bindings/python/Cargo.toml').read_text(); print(project['name'], project['version'], project['requires-python'], project['license'])"
- if: matrix.linux
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b
with:
maturin-version: v1.15.0
rust-toolchain: 1.89.0
manylinux: "2014"
args: --manifest-path bindings/python/Cargo.toml --release --locked --out dist -i python${{ matrix.python }}
- if: ${{ !matrix.linux }}
uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87
with:
toolchain: 1.89.0
targets: ${{ matrix.target }}
- if: ${{ !matrix.linux }}
run: python -m pip install maturin==1.15.0
- if: ${{ !matrix.linux }}
run: maturin build --manifest-path bindings/python/Cargo.toml --release --locked --out dist --interpreter python
- name: Record wheel metadata and digest
shell: bash
run: |
python -m pip install packaging==26.0
python -m pip install --no-index --no-deps --only-binary=:all: dist/*.whl
python -c "from importlib.metadata import distribution; from packaging.utils import parse_wheel_filename; from pathlib import Path; d=distribution('eggsearch'); wheels=list(Path('dist').glob('*.whl')); assert len(wheels) == 1; name, version, build, tags=parse_wheel_filename(wheels[0].name); assert name == 'eggsearch' and str(version) == d.version; assert all(tag.abi == 'abi3' and tag.interpreter == 'cp311' for tag in tags); print(d.metadata['Name'], d.version, d.metadata['Requires-Python']); print(*d.files, sep='\\n')" > dist/metadata.txt
sha256sum dist/*.whl | tee dist/SHA256SUMS
cat dist/SHA256SUMS >> "$GITHUB_STEP_SUMMARY"
- id: upload
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: wheel-${{ matrix.id }}
path: dist/
if-no-files-found: error
retention-days: 14
- env:
ARTIFACT_DIGEST: ${{ steps.upload.outputs.artifact-digest }}
run: |
python -c "import os; open(os.environ['GITHUB_STEP_SUMMARY'], 'a').write('GitHub artifact digest: ' + os.environ['ARTIFACT_DIGEST'] + '\\n')"
wheel-smoke:
name: Smoke ${{ matrix.target }} CPython ${{ matrix.python }}
needs: build-wheel
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- { id: linux-x86_64, runner: ubuntu-24.04, target: x86_64-unknown-linux-gnu, python: "3.11" }
- { id: linux-x86_64, runner: ubuntu-24.04, target: x86_64-unknown-linux-gnu, python: "3.12" }
- { id: linux-x86_64, runner: ubuntu-24.04, target: x86_64-unknown-linux-gnu, python: "3.13" }
- { id: linux-x86_64, runner: ubuntu-24.04, target: x86_64-unknown-linux-gnu, python: "3.14" }
- { id: linux-x86_64, runner: ubuntu-24.04, target: x86_64-unknown-linux-gnu, python: "3.15" }
- { id: linux-aarch64, runner: ubuntu-24.04-arm, target: aarch64-unknown-linux-gnu, python: "3.11" }
- { id: linux-aarch64, runner: ubuntu-24.04-arm, target: aarch64-unknown-linux-gnu, python: "3.12" }
- { id: linux-aarch64, runner: ubuntu-24.04-arm, target: aarch64-unknown-linux-gnu, python: "3.13" }
- { id: linux-aarch64, runner: ubuntu-24.04-arm, target: aarch64-unknown-linux-gnu, python: "3.14" }
- { id: linux-aarch64, runner: ubuntu-24.04-arm, target: aarch64-unknown-linux-gnu, python: "3.15" }
- { id: macos-x86_64, runner: macos-15-intel, target: x86_64-apple-darwin, python: "3.11" }
- { id: macos-x86_64, runner: macos-15-intel, target: x86_64-apple-darwin, python: "3.12" }
- { id: macos-x86_64, runner: macos-15-intel, target: x86_64-apple-darwin, python: "3.13" }
- { id: macos-x86_64, runner: macos-15-intel, target: x86_64-apple-darwin, python: "3.14" }
- { id: macos-x86_64, runner: macos-15-intel, target: x86_64-apple-darwin, python: "3.15" }
- { id: macos-arm64, runner: macos-15, target: aarch64-apple-darwin, python: "3.11" }
- { id: macos-arm64, runner: macos-15, target: aarch64-apple-darwin, python: "3.12" }
- { id: macos-arm64, runner: macos-15, target: aarch64-apple-darwin, python: "3.13" }
- { id: macos-arm64, runner: macos-15, target: aarch64-apple-darwin, python: "3.14" }
- { id: macos-arm64, runner: macos-15, target: aarch64-apple-darwin, python: "3.15" }
- { id: windows-x86_64, runner: windows-2022, target: x86_64-pc-windows-msvc, python: "3.11" }
- { id: windows-x86_64, runner: windows-2022, target: x86_64-pc-windows-msvc, python: "3.12" }
- { id: windows-x86_64, runner: windows-2022, target: x86_64-pc-windows-msvc, python: "3.13" }
- { id: windows-x86_64, runner: windows-2022, target: x86_64-pc-windows-msvc, python: "3.14" }
- { id: windows-x86_64, runner: windows-2022, target: x86_64-pc-windows-msvc, python: "3.15" }
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
python-version: ${{ matrix.python }}
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
with:
name: wheel-${{ matrix.id }}
path: ${{ runner.temp }}/wheelhouse
- name: Create a clean consumer environment
run: python -m venv "$RUNNER_TEMP/.venv"
shell: bash
- name: Test installed wheel outside checkout
run: |
if [ "$RUNNER_OS" = "Windows" ]; then
python_bin="$(cygpath -u "$RUNNER_TEMP")/.venv/Scripts/python.exe"
else
python_bin="$RUNNER_TEMP/.venv/bin/python"
fi
"$python_bin" -m pip install --no-index --no-deps --only-binary=:all: wheelhouse/*.whl
"$python_bin" -m pip install pytest==8.4.2
"$python_bin" -m pytest -q "$GITHUB_WORKSPACE/bindings/python/tests"
shell: bash
working-directory: ${{ runner.temp }}
armv7-build:
name: Build ARMv7 hard-float wheel
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b
with:
maturin-version: v1.15.0
rust-toolchain: 1.89.0
target: armv7-unknown-linux-gnueabihf
manylinux: "2_28"
container: ghcr.io/rust-cross/manylinux_2_28-cross@sha256:b1f069c62f7744faa6db5f1ab28b11d59f72e161d8f03f6b0a388fe1cecc065d
args: --manifest-path bindings/python/Cargo.toml --release --locked --out dist -i python3.11 --compatibility pypi
- name: Verify ARMv7 wheel metadata
run: |
python -m pip install packaging==26.0
python bindings/python/scripts/audit_armv7_wheel.py dist/*.whl | tee dist/armv7-audit.txt
sha256sum dist/*.whl | tee dist/SHA256SUMS
cat dist/armv7-audit.txt >> "$GITHUB_STEP_SUMMARY"
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: wheel-linux-armv7l
path: dist/
if-no-files-found: error
retention-days: 14
armv7-wheel-smoke:
name: Emulated ARMv7 installed-wheel smoke
needs: armv7-build
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a
with:
platforms: arm
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
with:
name: wheel-linux-armv7l
path: ${{ runner.temp }}/wheelhouse
- name: Install and test only the prebuilt wheel in matching ARMv7 Linux
shell: bash
run: |
docker run --rm --platform linux/arm/v7 \
-v "$RUNNER_TEMP/wheelhouse:/wheelhouse:ro" \
-v "$GITHUB_WORKSPACE:/source:ro" \
quay.io/pypa/manylinux_2_31_armv7l@sha256:ff4a72812594311c071eebce43efcaa9061bd1205649d864c1054d4e56e6bdae \
/bin/bash -euxo pipefail -c '
for tag in cp311 cp315; do
python_bin="/opt/python/$tag-$tag/bin/python"
test -x "$python_bin"
venv="/tmp/eggsearch-$tag-venv"
"$python_bin" -m venv "$venv"
"$venv/bin/python" -m pip install --no-index --no-deps --only-binary=:all: /wheelhouse/*.whl
"$venv/bin/python" -m pip install pytest==8.4.2
cd /tmp
"$venv/bin/python" -m pytest -q /source/bindings/python/tests
"$venv/bin/python" /source/bindings/python/scripts/smoke_installed_wheel.py
"$venv/bin/python" -c "import platform,sys; from importlib.metadata import distribution; import eggsearch; assert platform.machine() in (\"armv7l\", \"armv8l\"); assert sys.version_info[:2] == (3, int(\"$tag\"[3:])); assert len(eggsearch.tool_names()) == 10; print(platform.machine(), sys.version, distribution(\"eggsearch\").version)"
done
'
source-distribution:
name: Rebuild and smoke extracted sdist
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87
with:
toolchain: 1.89.0
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
python-version: "3.15"
- run: python -m pip install maturin==1.15.0
- name: Build sdist, prefetch locked crates, and rebuild offline
shell: bash
run: |
maturin build --manifest-path bindings/python/Cargo.toml --release --sdist --locked --out dist
cargo fetch --locked --manifest-path bindings/python/Cargo.toml
mkdir extracted
tar -xzf dist/*.tar.gz -C extracted
source_dir="$(find extracted -mindepth 1 -maxdepth 1 -type d)"
source_dir="$(cd "$source_dir" && pwd)"
(cd "$source_dir" && CARGO_NET_OFFLINE=true maturin build --release --locked --out "$GITHUB_WORKSPACE/extracted-wheel")
python -m venv "$RUNNER_TEMP/runtime-venv"
"$RUNNER_TEMP/runtime-venv/bin/python" -m pip install --no-index --no-deps extracted-wheel/*.whl
"$RUNNER_TEMP/runtime-venv/bin/python" -m pip install pytest==8.4.2
cd "$RUNNER_TEMP"
"$RUNNER_TEMP/runtime-venv/bin/python" -m pytest -q "$source_dir/bindings/python/tests"
"$RUNNER_TEMP/runtime-venv/bin/python" -c "import tomllib; from pathlib import Path; import eggsearch; from importlib.metadata import distribution; expected=tomllib.loads(Path('$GITHUB_WORKSPACE/bindings/python/pyproject.toml').read_text())['project']['version']; assert len(eggsearch.tool_names()) == 10; assert distribution('eggsearch').version == expected"
sha256sum "$GITHUB_WORKSPACE"/dist/* "$GITHUB_WORKSPACE"/extracted-wheel/* | tee "$GITHUB_WORKSPACE/dist/SHA256SUMS"
cat "$GITHUB_WORKSPACE/dist/SHA256SUMS" >> "$GITHUB_STEP_SUMMARY"
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: python-sdist-qualification
path: |
dist/*.tar.gz
dist/SHA256SUMS
if-no-files-found: error
retention-days: 14
dependency-audit:
name: Audit binding dependency graph
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87
with:
toolchain: 1.89.0
- run: cargo install cargo-deny --version 0.20.2 --locked
- run: cargo deny check
- run: cargo deny check
working-directory: bindings/python
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
python-version: "3.14"
- run: python -m pip install --upgrade pip==26.2.1
- run: python -m pip install pip-audit==2.10.1 maturin==1.15.0
- run: pip-audit --local --progress-spinner off