Skip to content

Commit 26d99e1

Browse files
authored
Fix packages to support more python Versions (#26)
* Fix packages to support more python Versions Signed-off-by: James Sturtevant <jsturtevant@gmail.com> * Avoid quoting issues Signed-off-by: James Sturtevant <jsturtevant@gmail.com> --------- Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
1 parent 4a7b42c commit 26d99e1

4 files changed

Lines changed: 38 additions & 20 deletions

File tree

.github/workflows/ci.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ jobs:
193193
- uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
194194

195195
- name: Install Python
196-
run: uv python install 3.12
196+
run: uv python install 3.10 3.11 3.12 3.13
197197

198198
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
199199
with:
@@ -208,7 +208,9 @@ jobs:
208208
run: sudo apt-get update && sudo apt-get install -y clang
209209

210210
- name: Build all Python packages
211-
run: just python-dist
211+
run: |
212+
export INTERPRETERS="--interpreter $(uv python find 3.10) $(uv python find 3.11) $(uv python find 3.12) $(uv python find 3.13)"
213+
just python-dist
212214
213215
- uses: actions/upload-artifact@v4
214216
with:
@@ -230,7 +232,7 @@ jobs:
230232
- uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
231233

232234
- name: Install Python
233-
run: uv python install 3.12
235+
run: uv python install 3.10 3.11 3.12 3.13
234236

235237
- name: Install just
236238
run: cargo install --locked just
@@ -239,7 +241,11 @@ jobs:
239241
run: choco install llvm -y
240242

241243
- name: Build backend wheels
242-
run: just python-dist-backends
244+
shell: pwsh
245+
run: |
246+
$interps = "3.10", "3.11", "3.12", "3.13" | ForEach-Object { & uv python find $_ }
247+
$env:INTERPRETERS = "--interpreter $($interps -join ' ')"
248+
just python-dist-backends
243249
244250
- uses: actions/upload-artifact@v4
245251
with:
@@ -248,19 +254,20 @@ jobs:
248254

249255
# Download merged Linux + Windows wheels and run wheelhouse smoke tests.
250256
python-wheelhouse-test:
251-
name: Python wheelhouse test (${{ matrix.os }})
257+
name: Python wheelhouse test (${{ matrix.os }}, py${{ matrix.python }})
252258
needs: [python-wheelhouse-build-linux, python-wheelhouse-build-windows]
253259
runs-on: ${{ matrix.os }}
254260
strategy:
255261
matrix:
256262
os: [ubuntu-latest, windows-latest]
263+
python: ["3.10", "3.11", "3.12", "3.13"]
257264
steps:
258265
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
259266

260267
- uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
261268

262269
- name: Install Python
263-
run: uv python install 3.12
270+
run: uv python install ${{ matrix.python }}
264271

265272
- name: Install just
266273
run: cargo install --locked just
@@ -280,7 +287,7 @@ jobs:
280287
sudo chmod 666 /dev/kvm
281288
282289
- name: Run wheelhouse tests
283-
run: just python python-wheelhouse-test
290+
run: just python python-wheelhouse-test ${{ matrix.python }}
284291

285292
javascript-sandbox:
286293
name: JS Sandbox (${{ matrix.os }})

.github/workflows/publish.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
2626

2727
- name: Install Python
28-
run: uv python install 3.12
28+
run: uv python install 3.10 3.11 3.12 3.13
2929

3030
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
3131
with:
@@ -40,7 +40,9 @@ jobs:
4040
run: sudo apt-get update && sudo apt-get install -y clang
4141

4242
- name: Build all Python packages
43-
run: just python-dist
43+
run: |
44+
export INTERPRETERS="--interpreter $(uv python find 3.10) $(uv python find 3.11) $(uv python find 3.12) $(uv python find 3.13)"
45+
just python-dist
4446
4547
- uses: actions/upload-artifact@v4
4648
with:
@@ -63,7 +65,7 @@ jobs:
6365
- uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
6466

6567
- name: Install Python
66-
run: uv python install 3.12
68+
run: uv python install 3.10 3.11 3.12 3.13
6769

6870
- name: Install just
6971
run: cargo install --locked just
@@ -72,7 +74,11 @@ jobs:
7274
run: choco install llvm -y
7375

7476
- name: Build backend wheels
75-
run: just python-dist-backends
77+
shell: pwsh
78+
run: |
79+
$interps = "3.10", "3.11", "3.12", "3.13" | ForEach-Object { & uv python find $_ }
80+
$env:INTERPRETERS = "--interpreter $($interps -join ' ')"
81+
just python-dist-backends
7682
7783
- uses: actions/upload-artifact@v4
7884
with:

Justfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ test-rust:
4141

4242
benchmark: python::python-sandbox-benchmark
4343

44-
python-dist: (wasm::build "release") (js::build "release") python::python-dist
44+
python-dist: (wasm::build "release") (js::build "release")
45+
just python python-dist
4546

4647
python-dist-backends: wasm::_clean-stale-wasm wasm::guest-compile-wit js::_clean-stale
4748
cargo build --manifest-path src/wasm_sandbox/Cargo.toml --release

src/sdk/python/Justfile

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ export WIT_WORLD := repo-root + "/src/wasm_sandbox/wit/sandbox-world.wasm"
55
rmrf := if os() == "windows" { "Remove-Item -Recurse -Force -ErrorAction SilentlyContinue" } else { "rm -rf" }
66
mkdirp := if os() == "windows" { "New-Item -ItemType Directory -Force" } else { "mkdir -p" }
77

8+
# Set via env or CLI (e.g. `just interpreters="--interpreter python3.10 python3.13" python-dist`)
9+
# to build wheels for multiple Python versions. Defaults to empty (maturin uses active Python).
10+
interpreters := env("INTERPRETERS", "")
11+
812
dist-root := repo-root + "/dist/pythonsdk"
913
core-dist := dist-root + "/core"
1014
wasm-wheels := dist-root + "/wasm_backend"
@@ -53,8 +57,8 @@ build: python-build
5357
python-dist: python-sync-guest-resources
5458
-{{rmrf}} {{dist-root}}
5559
cd {{repo-root}}/src/sdk/python/core && uv run python -m build --outdir {{core-dist}}
56-
cd {{repo-root}}/src/sdk/python/wasm_backend && uv run maturin build --release --out {{wasm-wheels}}
57-
cd {{repo-root}}/src/sdk/python/hyperlight_js_backend && uv run maturin build --release --out {{hyperlight-js-wheels}}
60+
cd {{repo-root}}/src/sdk/python/wasm_backend && uv run maturin build --release --out {{wasm-wheels}} {{interpreters}}
61+
cd {{repo-root}}/src/sdk/python/hyperlight_js_backend && uv run maturin build --release --out {{hyperlight-js-wheels}} {{interpreters}}
5862
cd {{repo-root}}/src/sdk/python/wasm_guests/python_guest && uv run python -m build --outdir {{python-guest-dist}}
5963
cd {{repo-root}}/src/sdk/python/wasm_guests/javascript_guest && uv run python -m build --outdir {{javascript-guest-dist}}
6064

@@ -64,8 +68,8 @@ python-dist: python-sync-guest-resources
6468
python-dist-backends: python-sync-env
6569
-{{rmrf}} {{wasm-wheels}}
6670
-{{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}}
71+
cd {{repo-root}}/src/sdk/python/wasm_backend && uv run maturin build --release --out {{wasm-wheels}} {{interpreters}}
72+
cd {{repo-root}}/src/sdk/python/hyperlight_js_backend && uv run maturin build --release --out {{hyperlight-js-wheels}} {{interpreters}}
6973

7074
python-publish repository="pypi":
7175
uv publish {{ if repository != "pypi" { "--publish-url https://test.pypi.org/legacy/" } else { "" } }} {{wasm-wheels}}/*
@@ -77,20 +81,20 @@ python-publish repository="pypi":
7781
# Smoke-test the wheels in dist/pythonsdk/ by installing them into
7882
# isolated environments and running basic tests.
7983
# Requires `just python-dist` (root) to have been run first.
80-
python-wheelhouse-test:
81-
uv run --no-project --no-index \
84+
python-wheelhouse-test python-version="":
85+
uv run --no-project {{ if python-version != "" { "--python " + python-version } else { "" } }} --no-index \
8286
--find-links={{core-dist}} \
8387
--find-links={{wasm-wheels}} \
8488
--find-links={{python-guest-dist}} \
8589
--with "hyperlight-sandbox[wasm,python_guest]" \
8690
python {{repo-root}}/src/sdk/python/tests/wheelhouse_wasm_python.py
87-
uv run --no-project --no-index \
91+
uv run --no-project {{ if python-version != "" { "--python " + python-version } else { "" } }} --no-index \
8892
--find-links={{core-dist}} \
8993
--find-links={{wasm-wheels}} \
9094
--find-links={{javascript-guest-dist}} \
9195
--with "hyperlight-sandbox[wasm,javascript_guest]" \
9296
python {{repo-root}}/src/sdk/python/tests/wheelhouse_wasm_js.py
93-
uv run --no-project --no-index \
97+
uv run --no-project {{ if python-version != "" { "--python " + python-version } else { "" } }} --no-index \
9498
--find-links={{core-dist}} \
9599
--find-links={{hyperlight-js-wheels}} \
96100
--find-links={{javascript-guest-dist}} \

0 commit comments

Comments
 (0)