Skip to content

Commit f337191

Browse files
committed
Separate building wheels workflow
1 parent ae160e4 commit f337191

File tree

2 files changed

+214
-233
lines changed

2 files changed

+214
-233
lines changed

.github/workflows/build_wheels.yml

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
name: Build Wheels
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
linux:
8+
name: Build ${{ matrix.platform.runner}} ${{ matrix.platform.target }}
9+
runs-on: ${{ matrix.platform.runner }}
10+
strategy:
11+
matrix:
12+
platform:
13+
# older ubuntu to avoid messing with glibc version
14+
- runner: ubuntu-22.04
15+
target: x86_64
16+
manylinux: auto
17+
interpreter: "3.9 3.10 3.11 3.12 3.13"
18+
- runner: ubuntu-22.04
19+
target: aarch64
20+
manylinux: manylinux_2_28
21+
interpreter: "3.9 3.10 3.11 3.12 3.13"
22+
23+
steps:
24+
- uses: actions/checkout@v3
25+
26+
- name: Set up Python
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: "3.13"
30+
31+
- run: pip install -U twine
32+
33+
- name: Install required packages
34+
run: |
35+
sudo apt update
36+
sudo apt install pkg-config gcc-aarch64-linux-gnu g++-aarch64-linux-gnu -qy
37+
38+
- uses: dtolnay/rust-toolchain@master
39+
with:
40+
toolchain: stable
41+
target: ${{ matrix.platform.target}}-unknown-linux-gnu
42+
- uses: Swatinem/rust-cache@v2
43+
44+
- name: Build wheels
45+
uses: PyO3/maturin-action@v1
46+
with:
47+
target: ${{ matrix.platform.target }}
48+
args: --release --out dist --interpreter ${{ matrix.platform.interpreter }}
49+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
50+
manylinux: ${{ matrix.platform.manylinux }}
51+
52+
- name: Validate Python package distributions
53+
run: twine check --strict dist/*
54+
55+
- name: Install built wheel
56+
if: matrix.platform.target == 'x86_64'
57+
run: |
58+
pip install outlines_core --no-index --find-links dist --force-reinstall
59+
python -c "import outlines_core"
60+
61+
- uses: actions/upload-artifact@v4
62+
with:
63+
path: dist/*.whl
64+
name: wheels-linux-${{ matrix.platform.target }}
65+
66+
windows:
67+
name: Build ${{ matrix.platform.runner}} ${{ matrix.platform.target }}
68+
runs-on: ${{ matrix.platform.runner }}
69+
strategy:
70+
matrix:
71+
platform:
72+
- runner: windows-latest
73+
target: x86
74+
alias-target: i686-pc-windows-msvc
75+
interpreter: "3.9 3.10 3.11 3.12 3.13"
76+
- runner: windows-latest
77+
target: x64
78+
alias-target: x86_64-pc-windows-msvc
79+
interpreter: "3.9 3.10 3.11 3.12 3.13"
80+
81+
steps:
82+
- uses: actions/checkout@v3
83+
84+
- name: Set up Python
85+
uses: actions/setup-python@v5
86+
with:
87+
python-version: "3.13"
88+
architecture: ${{ matrix.platform.target }}
89+
90+
- run: pip install -U twine
91+
92+
- name: Install required packages
93+
# rustls requires aws-lc-sys, which FFI bindings to AWS-LC (AWS Libcrypto)
94+
# aws-lc-sys requires nasm for compilation on windows
95+
run: |
96+
choco install nasm
97+
98+
- uses: dtolnay/rust-toolchain@master
99+
with:
100+
toolchain: stable
101+
target: ${{ matrix.platform.alias-target}}
102+
- uses: Swatinem/rust-cache@v2
103+
104+
- name: Build wheels
105+
uses: PyO3/maturin-action@v1
106+
with:
107+
target: ${{ matrix.platform.target }}
108+
args: --release --out dist --interpreter ${{ matrix.platform.interpreter }}
109+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
110+
manylinux: auto
111+
112+
- name: Validate Python package distributions
113+
run: twine check --strict dist/*
114+
115+
- name: Install built wheel
116+
run: |
117+
pip install outlines_core --no-index --find-links dist --force-reinstall
118+
python -c "import outlines_core"
119+
120+
- uses: actions/upload-artifact@v4
121+
with:
122+
path: dist/*.whl
123+
name: wheels-windows-${{ matrix.platform.target }}
124+
125+
macos:
126+
name: Build ${{ matrix.platform.runner}} ${{ matrix.platform.target }}
127+
runs-on: ${{ matrix.platform.runner }}
128+
strategy:
129+
matrix:
130+
platform:
131+
- runner: macos-14
132+
target: x86_64
133+
macos_version: "14.0"
134+
interpreter: "3.9 3.10 3.11 3.12 3.13"
135+
- runner: macos-14
136+
target: aarch64
137+
macos_version: "14.0"
138+
interpreter: "3.9 3.10 3.11 3.12 3.13"
139+
- runner: macos-15
140+
target: x86_64
141+
macos_version: "15.0"
142+
interpreter: "3.9 3.10 3.11 3.12 3.13"
143+
- runner: macos-15
144+
target: aarch64
145+
macos_version: "15.0"
146+
interpreter: "3.9 3.10 3.11 3.12 3.13"
147+
148+
steps:
149+
- uses: actions/checkout@v3
150+
151+
- name: Set up Python
152+
uses: actions/setup-python@v5
153+
with:
154+
python-version: "3.13"
155+
156+
- run: pip install -U twine
157+
158+
- name: Set macOS version
159+
run: echo "MACOSX_DEPLOYMENT_TARGET=${{ matrix.platform.macos_version }}" >> $GITHUB_ENV
160+
161+
- uses: dtolnay/rust-toolchain@master
162+
with:
163+
toolchain: stable
164+
target: ${{ matrix.platform.target}}-apple-darwin
165+
- uses: Swatinem/rust-cache@v2
166+
167+
- name: Build wheels
168+
uses: PyO3/maturin-action@v1
169+
with:
170+
target: ${{ matrix.platform.target }}
171+
args: --release --out dist --interpreter ${{ matrix.platform.interpreter }}
172+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
173+
manylinux: auto
174+
175+
- name: Validate Python package distributions
176+
run: twine check --strict dist/*
177+
178+
- name: Install built wheel
179+
if: matrix.platform.target == 'aarch64'
180+
run: |
181+
pip install outlines_core --no-index --find-links dist --force-reinstall
182+
python -c "import outlines_core"
183+
184+
- uses: actions/upload-artifact@v4
185+
with:
186+
path: dist/*.whl
187+
name: wheels-${{ matrix.platform.runner }}-${{ matrix.platform.target }}
188+
189+
190+
build_sdist:
191+
name: Build source distribution
192+
runs-on: ubuntu-latest
193+
steps:
194+
- uses: actions/checkout@v3
195+
- name: Set up Python
196+
uses: actions/setup-python@v4
197+
with:
198+
python-version: '3.10'
199+
- name: Build sdist with Maturin
200+
uses: PyO3/maturin-action@v1
201+
with:
202+
command: sdist
203+
args: --out dist
204+
- uses: actions/upload-artifact@v4
205+
with:
206+
path: dist/*.tar.gz
207+
name: sdist

0 commit comments

Comments
 (0)