Skip to content

Commit e23272e

Browse files
committed
Add Windows support to Python sdk
Add wheel generation and tests the support for publishing Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
1 parent 479d8e5 commit e23272e

7 files changed

Lines changed: 153 additions & 24 deletions

File tree

.github/workflows/ci.yml

Lines changed: 69 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,10 @@ jobs:
134134
- name: Python SDK Benchmark
135135
run: just benchmark
136136

137-
python-wheelhouse:
138-
name: Python SDK wheelhouse test (${{ matrix.os }})
139-
runs-on: ${{ matrix.os }}
140-
strategy:
141-
matrix:
142-
os: [ubuntu-latest, windows-latest]
137+
# Build all Python packages on Linux (pure + backend wheels).
138+
python-wheelhouse-build-linux:
139+
name: Python wheelhouse build (Linux)
140+
runs-on: ubuntu-latest
143141
steps:
144142
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
145143

@@ -162,14 +160,73 @@ jobs:
162160
- name: Install just
163161
run: cargo install --locked just
164162

165-
- name: Install clang (Linux)
166-
if: runner.os == 'Linux'
163+
- name: Install clang
167164
run: sudo apt-get update && sudo apt-get install -y clang
168165

169-
- name: Install LLVM (Windows)
170-
if: runner.os == 'Windows'
166+
- name: Build all Python packages
167+
run: just python-dist
168+
169+
- uses: actions/upload-artifact@v4
170+
with:
171+
name: python-wheels-linux
172+
path: dist/pythonsdk/
173+
174+
# Build Windows-specific maturin backend wheels only.
175+
python-wheelhouse-build-windows:
176+
name: Python wheelhouse build (Windows)
177+
runs-on: windows-latest
178+
steps:
179+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
180+
181+
- uses: actions-rust-lang/setup-rust-toolchain@150fca883cd4034361b621bd4e6a9d34e5143606 # v1.15.4
182+
with:
183+
cache-key: release
184+
rustflags: ""
185+
186+
- uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
187+
188+
- name: Install Python
189+
run: uv python install 3.12
190+
191+
- name: Install just
192+
run: cargo install --locked just
193+
194+
- name: Install LLVM
171195
run: choco install llvm -y
172196

197+
- name: Build backend wheels
198+
run: just python-dist-backends
199+
200+
- uses: actions/upload-artifact@v4
201+
with:
202+
name: python-wheels-windows
203+
path: dist/pythonsdk/
204+
205+
# Download merged Linux + Windows wheels and run wheelhouse smoke tests.
206+
python-wheelhouse-test:
207+
name: Python wheelhouse test (${{ matrix.os }})
208+
needs: [python-wheelhouse-build-linux, python-wheelhouse-build-windows]
209+
runs-on: ${{ matrix.os }}
210+
strategy:
211+
matrix:
212+
os: [ubuntu-latest, windows-latest]
213+
steps:
214+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
215+
216+
- uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
217+
218+
- name: Install Python
219+
run: uv python install 3.12
220+
221+
- name: Install just
222+
run: cargo install --locked just
223+
224+
- uses: actions/download-artifact@v4
225+
with:
226+
path: dist/pythonsdk/
227+
merge-multiple: true
228+
pattern: python-wheels-*
229+
173230
- name: Enable KVM
174231
if: runner.os == 'Linux' && !env.ACT
175232
run: |
@@ -178,8 +235,8 @@ jobs:
178235
sudo udevadm trigger --name-match=kvm
179236
sudo chmod 666 /dev/kvm
180237
181-
- name: Build release wheels and run wheelhouse test
182-
run: just python-wheelhouse-test
238+
- name: Run wheelhouse tests
239+
run: just python python-wheelhouse-test
183240

184241
javascript-sandbox:
185242
name: JS Sandbox (${{ matrix.os }})

.github/workflows/publish.yml

Lines changed: 70 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,11 @@ on:
66
- "v*"
77

88
jobs:
9-
publish:
9+
# Build all Python packages on Linux (pure + backend wheels).
10+
build-linux:
1011
if: ${{ !github.event.act }}
11-
name: Build & publish to PyPI
12+
name: Build Linux packages
1213
runs-on: ubuntu-latest
13-
environment:
14-
name: pypi
15-
permissions:
16-
id-token: write
17-
contents: read
1814
steps:
1915
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2016

@@ -40,8 +36,70 @@ jobs:
4036
- name: Install clang
4137
run: sudo apt-get update && sudo apt-get install -y clang
4238

43-
- name: Build & Publish
44-
if: ${{ !env.ACT }}
45-
run: |
46-
just python-dist
47-
just python python-publish
39+
- name: Build all Python packages
40+
run: just python-dist
41+
42+
- uses: actions/upload-artifact@v4
43+
with:
44+
name: python-wheels-linux
45+
path: dist/pythonsdk/
46+
47+
# Build Windows-specific maturin backend wheels only.
48+
build-windows:
49+
if: ${{ !github.event.act }}
50+
name: Build Windows backend wheels
51+
runs-on: windows-latest
52+
steps:
53+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
54+
55+
- uses: actions-rust-lang/setup-rust-toolchain@150fca883cd4034361b621bd4e6a9d34e5143606 # v1.15.4
56+
with:
57+
cache-key: release
58+
rustflags: ""
59+
60+
- uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
61+
62+
- name: Install Python
63+
run: uv python install 3.12
64+
65+
- name: Install just
66+
run: cargo install --locked just
67+
68+
- name: Install LLVM
69+
run: choco install llvm -y
70+
71+
- name: Build backend wheels
72+
run: just python-dist-backends
73+
74+
- uses: actions/upload-artifact@v4
75+
with:
76+
name: python-wheels-windows
77+
path: dist/pythonsdk/
78+
79+
# Merge artifacts from both platforms and publish to PyPI.
80+
publish:
81+
if: ${{ !github.event.act }}
82+
name: Publish to PyPI
83+
needs: [build-linux, build-windows]
84+
runs-on: ubuntu-latest
85+
environment:
86+
name: pypi
87+
permissions:
88+
id-token: write
89+
contents: read
90+
steps:
91+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
92+
93+
- uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
94+
95+
- name: Install just
96+
run: cargo install --locked just
97+
98+
- uses: actions/download-artifact@v4
99+
with:
100+
path: dist/pythonsdk/
101+
merge-multiple: true
102+
pattern: python-wheels-*
103+
104+
- name: Publish to PyPI
105+
run: just python python-publish

Justfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ benchmark: python::python-sandbox-benchmark
4343

4444
python-dist: (wasm::build "release") (js::build "release") python::python-dist
4545

46+
python-dist-backends: wasm::guest-compile-wit python::python-dist-backends
47+
4648
python-wheelhouse-test: python-dist python::python-wheelhouse-test
4749

4850
examples target=default-target: (wasm::examples target) (js::examples target) python::examples

src/sdk/python/Justfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ python-dist: python-sync-guest-resources
5858
cd {{repo-root}}/src/sdk/python/wasm_guests/python_guest && uv run python -m build --outdir {{python-guest-dist}}
5959
cd {{repo-root}}/src/sdk/python/wasm_guests/javascript_guest && uv run python -m build --outdir {{javascript-guest-dist}}
6060

61+
# Build only the platform-specific maturin backend wheels.
62+
# Used by CI to produce Windows wheels without needing guest binaries.
63+
# Requires sandbox-world.wasm to exist (run `just wasm guest-compile-wit` first).
64+
python-dist-backends:
65+
-{{rmrf}} {{wasm-wheels}}
66+
-{{rmrf}} {{hyperlight-js-wheels}}
67+
cd {{repo-root}}/src/sdk/python/wasm_backend && uv run maturin build --release --out {{wasm-wheels}}
68+
cd {{repo-root}}/src/sdk/python/hyperlight_js_backend && uv run maturin build --release --out {{hyperlight-js-wheels}}
69+
6170
python-publish repository="pypi":
6271
uv publish {{ if repository != "pypi" { "--publish-url https://test.pypi.org/legacy/" } else { "" } }} {{wasm-wheels}}/*
6372
uv publish {{ if repository != "pypi" { "--publish-url https://test.pypi.org/legacy/" } else { "" } }} {{hyperlight-js-wheels}}/*

src/sdk/python/core/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ classifiers = [
1717
"Programming Language :: Python :: 3",
1818
"Programming Language :: Rust",
1919
"Operating System :: POSIX :: Linux",
20+
"Operating System :: Microsoft :: Windows",
2021
]
2122
keywords = ["hyperlight", "wasm", "sandbox", "isolation", "code-execution"]
2223

src/sdk/python/hyperlight_js_backend/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ classifiers = [
1515
"Programming Language :: Python :: 3",
1616
"Programming Language :: Rust",
1717
"Operating System :: POSIX :: Linux",
18+
"Operating System :: Microsoft :: Windows",
1819
]
1920

2021
[tool.maturin]

src/sdk/python/wasm_backend/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ classifiers = [
1515
"Programming Language :: Python :: 3",
1616
"Programming Language :: Rust",
1717
"Operating System :: POSIX :: Linux",
18+
"Operating System :: Microsoft :: Windows",
1819
]
1920

2021
[tool.maturin]

0 commit comments

Comments
 (0)