Skip to content

Commit 7a34eda

Browse files
committed
Stop cross-compiling wheels, add pypi 3.11
With the Windows and ARM runners, we should generally not have to cross-compile wheels anymore, and also should be able to test them all (kinda, tests currently not testing musl). - Ensure the wheels we test are the ones we built: previously pip could download previous releases from pypi which misses the point. - Remove caches, building releases is not super common and the caching keys to not retrieve stuff cached for an other archi seems a pain. - Also caching `.cargo/bin` might not be a great idea as apparently some OS end up with rustc in there (?) - Build the test matrix in Python because I'm fed up with trying to get the garbage fire that is GHA declarative matrixes right. That it's possible to do that means it should be possible to generate matrixes from tox tho, something to think about. Also a bunch of targets need to be excluded: - There's currently no graal on windows period. - No pypy on windows/arm. - No 3.9 or 3.10 on windows/arm. Fixes #12
1 parent 1450fe4 commit 7a34eda

File tree

1 file changed

+99
-53
lines changed

1 file changed

+99
-53
lines changed

.github/workflows/pyo3-wheels.yml

Lines changed: 99 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,68 @@ permissions:
1313
contents: read
1414

1515
jobs:
16+
py-wheels-matrix:
17+
name: "generate build matrix"
18+
runs-on: ubuntu-latest
19+
outputs:
20+
matrix: ${{ steps.make-matrix.outputs.matrix }}
21+
steps:
22+
- id: make-matrix
23+
shell: python
24+
name: generate matrix
25+
run: |
26+
import itertools
27+
import json
28+
import os
29+
import pprint
30+
31+
builder = {
32+
('linux', 'x86_64'): 'ubuntu-latest',
33+
('linux', 'aarch64'): 'ubuntu-24.04-arm',
34+
('musllinux', 'x86_64'): 'ubuntu-latest',
35+
('musllinux', 'aarch64'): 'ubuntu-24.04-arm',
36+
('macos', 'x86_64'): 'macos-13',
37+
('macos', 'aarch64'): 'macos-latest',
38+
('windows', 'x86_64'): 'windows-latest',
39+
('windows', 'aarch64'): 'windows-11-arm',
40+
}
41+
42+
matrix = [
43+
d
44+
for d in map(dict, itertools.product(
45+
(('python-version', v) for v in ["3.x", "pypy-3.10", "pypy-3.11", "graalpy-24"]),
46+
(('arch', a) for a in ["x86_64", "aarch64"]),
47+
(('platform', p) for p in ["linux", "musllinux", "windows", "macos"])
48+
))
49+
# on windows, only cpython has arm builds (?)
50+
if not (
51+
d['platform'] == 'windows'
52+
and d['arch'] == 'aarch64'
53+
and d['python-version'] != '3.x'
54+
)
55+
# windows and graal don't work
56+
if not (d['platform'] == 'windows' and d['python-version'] == 'graalpy-24')
57+
]
58+
for job in matrix:
59+
match job['platform']:
60+
case 'linux':
61+
job['manylinux'] = 'auto'
62+
job['args'] = ' --zig'
63+
case 'mussllinux':
64+
job['manylinux'] = 'musllinux_1_2'
65+
66+
job['runs'] = builder[job['platform'], job['arch']]
67+
68+
with open(os.environ['GITHUB_OUTPUT'], 'w') as f:
69+
f.write("matrix=")
70+
json.dump({'include': matrix}, f)
71+
f.flush()
72+
1673
py-release-wheels:
74+
needs: [py-wheels-matrix]
1775
strategy:
18-
matrix:
19-
python-version:
20-
- "3.x"
21-
- "pypy-3.10"
22-
- "graalpy-24"
23-
arch:
24-
- x86_64
25-
- aarch64
26-
platform:
27-
- linux
28-
- musllinux
29-
- windows
30-
- macos
31-
32-
exclude:
33-
- platform: windows
34-
arch: aarch64
35-
- platform: windows
36-
python-version: graalpy-24
37-
38-
include:
39-
- platform: linux
40-
manylinux: auto
41-
- platform: musllinux
42-
manylinux: musllinux_1_2
43-
44-
- args: --release --out dist -m ua-parser-py/Cargo.toml -i python
45-
- platform: linux
46-
args: --release --out dist -m ua-parser-py/Cargo.toml -i python --zig
47-
- platform: musllinux
48-
args: --release --out dist -m ua-parser-py/Cargo.toml
49-
50-
- runs: ubuntu-latest
51-
- platform: windows
52-
runs: windows-latest
53-
- platform: macos
54-
runs: macos-latest
76+
fail-fast: false
77+
matrix: ${{fromJson(needs.py-wheels-matrix.outputs.matrix)}}
5578

5679
runs-on: ${{ matrix.runs }}
5780

@@ -62,11 +85,13 @@ jobs:
6285
- uses: actions/setup-python@v5
6386
with:
6487
python-version: ${{ matrix.python-version }}
88+
# windows/arm doesn't have a rust toolchain by default
89+
- if: matrix.platform == 'windows' && matrix.arch == 'aarch64'
90+
uses: actions-rust-lang/setup-rust-toolchain@9d7e65c320fdb52dcd45ffaa68deb6c02c8754d9 # 1.12.0
6591
- name: Build wheels
6692
uses: PyO3/maturin-action@v1
6793
with:
68-
target: ${{ matrix.arch }}
69-
args: ${{ matrix.args }}
94+
args: --release --out dist -m ua-parser-py/Cargo.toml -i python ${{ matrix.args }}
7095
sccache: 'true'
7196
manylinux: ${{ matrix.manylinux }}
7297
- name: Upload wheels
@@ -98,6 +123,7 @@ jobs:
98123
needs: py-release-wheels
99124

100125
strategy:
126+
fail-fast: false
101127
matrix:
102128
python-version:
103129
- "3.9"
@@ -106,38 +132,58 @@ jobs:
106132
- "3.12"
107133
- "3.13"
108134
- "pypy-3.10"
135+
- "pypy-3.11"
109136
- "graalpy-24"
110137
platform:
111138
- linux
112139
# probably requires a custom image of some sort
113140
# - musllinux
114141
- windows
115142
- macos
143+
arch:
144+
- x86_64
145+
- aarch64
116146

117147
exclude:
148+
- platform: windows
149+
arch: aarch64
150+
python-version: 3.9
151+
- platform: windows
152+
python-version: 3.10
153+
arch: aarch64
154+
- platform: windows
155+
arch: aarch64
156+
python-version: pypy-3.10
157+
- platform: windows
158+
arch: aarch64
159+
python-version: pypy-3.11
118160
- platform: windows
119161
python-version: graalpy-24
120162

121163
include:
122-
# would probably need to run qemu inside the thing to full
123-
# test the archs...
124-
- arch: x86_64
125-
- platform: macos
126-
arch: aarch64
127-
128164
- wheel: "3.x"
129165
- python-version: "pypy-3.10"
130166
wheel: "pypy-3.10"
167+
- python-version: "pypy-3.11"
168+
wheel: "pypy-3.11"
131169
- python-version: "graalpy-24"
132170
wheel: "graalpy-24"
133171

134-
- runs: ubuntu-latest
172+
- runner: ubuntu-latest
173+
- arch: aarch64
174+
runner: ubuntu-24.04-arm
175+
- platform: windows
176+
runner: windows-latest
135177
- platform: windows
136-
runs: windows-latest
178+
arch: aarch64
179+
runner: windows-11-arm
137180
- platform: macos
138-
runs: macos-latest
181+
runner: macos-latest
182+
- platform: macos
183+
arch: x86_64
184+
runner: macos-13
139185

140-
runs-on: ${{ matrix.runs }}
186+
runs-on: ${{ matrix.runner }}
141187

142188
steps:
143189
- name: Checkout working copy
@@ -158,7 +204,7 @@ jobs:
158204
- name: Update pip
159205
run: python -mpip install --upgrade pip
160206
- name: Maybe install libyaml-dev
161-
if: matrix.runs == 'ubuntu-latest'
207+
if: startsWith(matrix.runs, 'ubuntu-latest')
162208
run: |
163209
# if binary wheels are not available for the current
164210
# package install libyaml-dev so we can install pyyaml
@@ -169,15 +215,15 @@ jobs:
169215
- name: Install test dependencies
170216
run: python -mpip install pytest pyyaml
171217
- name: Install wheel
172-
run: pip install --find-links dist ua_parser_rs
218+
run: python -mpip install --only-binary ':all:' --no-index --find-links dist ua_parser_rs
173219
- name: Run tests
174-
run: pytest -v -Werror -ra ua-parser-py
220+
run: python -mpytest -v -Werror -ra ua-parser-py
175221

176222
py-release:
177223
name: Release
178224
runs-on: ubuntu-latest
179225
needs: [py-release-tests, py-release-sdist]
180-
if: ${{ inputs.release }}
226+
if: github.event == 'workflow_dispatch' && inputs.release
181227
permissions:
182228
# Use to sign the release artifacts
183229
id-token: write

0 commit comments

Comments
 (0)