11name : Wheels
22
33on :
4+ # pull_request:
45 workflow_dispatch :
56 inputs :
67 release :
@@ -13,45 +14,68 @@ permissions:
1314 contents : read
1415
1516jobs :
17+ py-wheels-matrix :
18+ name : " generate build matrix"
19+ runs-on : ubuntu-latest
20+ outputs :
21+ matrix : ${{ steps.make-matrix.outputs.matrix }}
22+ steps :
23+ - id : make-matrix
24+ shell : python
25+ name : generate matrix
26+ run : |
27+ import itertools
28+ import json
29+ import os
30+ import pprint
31+
32+ builder = {
33+ ('linux', 'x86_64'): 'ubuntu-latest',
34+ ('linux', 'aarch64'): 'ubuntu-24.04-arm',
35+ ('musllinux', 'x86_64'): 'ubuntu-latest',
36+ ('musllinux', 'aarch64'): 'ubuntu-24.04-arm',
37+ ('macos', 'x86_64'): 'macos-13',
38+ ('macos', 'aarch64'): 'macos-latest',
39+ ('windows', 'x86_64'): 'windows-latest',
40+ ('windows', 'aarch64'): 'windows-11-arm',
41+ }
42+
43+ matrix = [
44+ d
45+ for d in map(dict, itertools.product(
46+ (('python-version', v) for v in ["3.x", "pypy-3.10", "pypy-3.11", "graalpy-24"]),
47+ (('arch', a) for a in ["x86_64", "aarch64"]),
48+ (('platform', p) for p in ["linux", "musllinux", "windows", "macos"])
49+ ))
50+ # on windows, only cpython has arm builds (?)
51+ if not (
52+ d['platform'] == 'windows'
53+ and d['arch'] == 'aarch64'
54+ and d['python-version'] != '3.x'
55+ )
56+ # windows and graal don't work
57+ if not (d['platform'] == 'windows' and d['python-version'] == 'graalpy-24')
58+ ]
59+ for job in matrix:
60+ match job['platform']:
61+ case 'linux':
62+ job['manylinux'] = 'auto'
63+ job['args'] = ' --zig'
64+ case 'mussllinux':
65+ job['manylinux'] = 'musllinux_1_2'
66+
67+ job['runs'] = builder[job['platform'], job['arch']]
68+
69+ with open(os.environ['GITHUB_OUTPUT'], 'w') as f:
70+ f.write("matrix=")
71+ json.dump({'include': matrix}, f)
72+ f.flush()
73+
1674 py-release-wheels :
75+ needs : [py-wheels-matrix]
1776 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
77+ fail-fast : false
78+ matrix : ${{fromJson(needs.py-wheels-matrix.outputs.matrix)}}
5579
5680 runs-on : ${{ matrix.runs }}
5781
@@ -62,11 +86,13 @@ jobs:
6286 - uses : actions/setup-python@v5
6387 with :
6488 python-version : ${{ matrix.python-version }}
89+ # windows/arm doesn't have a rust toolchain by default
90+ - if : matrix.platform == 'windows' && matrix.arch == 'aarch64'
91+ uses : actions-rust-lang/setup-rust-toolchain@9d7e65c320fdb52dcd45ffaa68deb6c02c8754d9 # 1.12.0
6592 - name : Build wheels
6693 uses : PyO3/maturin-action@v1
6794 with :
68- target : ${{ matrix.arch }}
69- args : ${{ matrix.args }}
95+ args : --release --out dist -m ua-parser-py/Cargo.toml -i python ${{ matrix.args }}
7096 sccache : ' true'
7197 manylinux : ${{ matrix.manylinux }}
7298 - name : Upload wheels
98124 needs : py-release-wheels
99125
100126 strategy :
127+ fail-fast : false
101128 matrix :
102129 python-version :
103130 - " 3.9"
@@ -106,38 +133,58 @@ jobs:
106133 - " 3.12"
107134 - " 3.13"
108135 - " pypy-3.10"
136+ - " pypy-3.11"
109137 - " graalpy-24"
110138 platform :
111139 - linux
112140 # probably requires a custom image of some sort
113141 # - musllinux
114142 - windows
115143 - macos
144+ arch :
145+ - x86_64
146+ - aarch64
116147
117148 exclude :
149+ - platform : windows
150+ arch : aarch64
151+ python-version : 3.9
152+ - platform : windows
153+ python-version : 3.10
154+ arch : aarch64
155+ - platform : windows
156+ arch : aarch64
157+ python-version : pypy-3.10
158+ - platform : windows
159+ arch : aarch64
160+ python-version : pypy-3.11
118161 - platform : windows
119162 python-version : graalpy-24
120163
121164 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-
128165 - wheel : " 3.x"
129166 - python-version : " pypy-3.10"
130167 wheel : " pypy-3.10"
168+ - python-version : " pypy-3.11"
169+ wheel : " pypy-3.11"
131170 - python-version : " graalpy-24"
132171 wheel : " graalpy-24"
133172
134- - runs : ubuntu-latest
173+ - runner : ubuntu-latest
174+ - arch : aarch64
175+ runner : ubuntu-24.04-arm
176+ - platform : windows
177+ runner : windows-latest
135178 - platform : windows
136- runs : windows-latest
179+ arch : aarch64
180+ runner : windows-11-arm
137181 - platform : macos
138- runs : macos-latest
182+ runner : macos-latest
183+ - platform : macos
184+ arch : x86_64
185+ runner : macos-13
139186
140- runs-on : ${{ matrix.runs }}
187+ runs-on : ${{ matrix.runner }}
141188
142189 steps :
143190 - name : Checkout working copy
@@ -158,7 +205,7 @@ jobs:
158205 - name : Update pip
159206 run : python -mpip install --upgrade pip
160207 - name : Maybe install libyaml-dev
161- if : matrix.runs == 'ubuntu-latest'
208+ if : startsWith( matrix.runs, 'ubuntu-latest')
162209 run : |
163210 # if binary wheels are not available for the current
164211 # package install libyaml-dev so we can install pyyaml
@@ -169,15 +216,15 @@ jobs:
169216 - name : Install test dependencies
170217 run : python -mpip install pytest pyyaml
171218 - name : Install wheel
172- run : pip install --find-links dist ua_parser_rs
219+ run : python -mpip install --only-binary ':all:' --no-index --find-links dist ua_parser_rs
173220 - name : Run tests
174- run : pytest -v -Werror -ra ua-parser-py
221+ run : python -mpytest -v -Werror -ra ua-parser-py
175222
176223 py-release :
177224 name : Release
178225 runs-on : ubuntu-latest
179226 needs : [py-release-tests, py-release-sdist]
180- if : ${{ inputs.release }}
227+ if : github.event == 'workflow_dispatch' && inputs.release
181228 permissions :
182229 # Use to sign the release artifacts
183230 id-token : write
0 commit comments