Skip to content

Commit 692fb38

Browse files
authored
clean up plublishing and add a test (#18)
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
1 parent 2d4707b commit 692fb38

File tree

5 files changed

+52
-41
lines changed

5 files changed

+52
-41
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ jobs:
123123
- name: Python SDK Benchmark
124124
run: just benchmark
125125

126+
# Build release wheels and verify they install + work correctly
127+
- name: Python SDK Wheelhouse test
128+
run: |
129+
just python-dist
130+
just python python-wheelhouse-test
131+
126132
javascript-sandbox:
127133
name: JS Sandbox · lint / build / examples
128134
runs-on: ubuntu-latest

.github/workflows/publish.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,8 @@ jobs:
4343
- name: Install JS guest dependencies
4444
run: just wasm js-guest-install
4545

46-
- name: Build guests
47-
run: |
48-
just wasm guest-build
49-
just wasm js-guest-build
50-
5146
- name: Build & Publish
5247
if: ${{ !env.ACT }}
53-
run: just python python-publish
48+
run: |
49+
just python-dist
50+
just python python-publish

Justfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ test-rust:
4141

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

44+
python-dist: (wasm::build "release") python::python-dist
45+
4446
examples target=default-target: (wasm::examples target) (jssandbox::examples target) python::examples
4547

4648
integration-examples target=default-target: (wasm::guest-build target) wasm::js-guest-build python::build examples_mod::integration-examples

src/sdk/python/Justfile

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ javascript-guest-dist := dist-root + "/javascript_guest"
1010

1111
#### BUILD ####
1212

13+
# Copy pre-built guest binaries (.aot/.wasm) from the wasm_sandbox build
14+
# into the Python guest packages so they can be bundled into wheels.
15+
# Requires `just wasm build` to have run first.
1316
python-sync-guest-resources:
1417
mkdir -p {{repo-root}}/src/sdk/python/wasm_guests/python_guest/python_guest/resources
1518
mkdir -p {{repo-root}}/src/sdk/python/wasm_guests/javascript_guest/javascript_guest/resources
@@ -18,33 +21,32 @@ python-sync-guest-resources:
1821
cp {{repo-root}}/src/wasm_sandbox/guests/javascript/js-sandbox.aot {{repo-root}}/src/sdk/python/wasm_guests/javascript_guest/javascript_guest/resources/js-sandbox.aot
1922
cp {{repo-root}}/src/wasm_sandbox/guests/javascript/js-sandbox.wasm {{repo-root}}/src/sdk/python/wasm_guests/javascript_guest/javascript_guest/resources/js-sandbox.wasm
2023

21-
# Sync the venv (installs maturin, guest packages, etc.) but skip the
22-
# two maturin backend crates — they are built below via `maturin develop`.
24+
# Install pure Python dependencies from the lockfile into the local venv.
25+
# Skips the two Rust backend packages — those are compiled and installed
26+
# separately by `python-install-backends` via `maturin develop`.
2327
python-sync-env:
2428
uv sync --frozen --inexact --no-install-package hyperlight-sandbox-backend-wasm --no-install-package hyperlight-sandbox-backend-hyperlight-js
2529

26-
python-install-backend-wasm:
27-
cd {{repo-root}}/src/sdk/python/wasm_backend && {{ wit-world }} uv run --no-sync maturin develop
28-
29-
python-install-backend-wasm-release:
30-
# Remove cached build-script output so the runtime binary is rebuilt
31-
# for the release profile. The debug build may have left stale
32-
# fingerprints that prevent the build script from re-running.
33-
rm -rf {{repo-root}}/target/release/build/hyperlight-wasm-* \
34-
{{repo-root}}/target/release/.fingerprint/hyperlight-wasm-*
35-
cd {{repo-root}}/src/sdk/python/wasm_backend && {{ wit-world }} uv run --no-sync maturin develop --release
36-
37-
python-install-backend-hyperlight-js:
38-
cd {{repo-root}}/src/sdk/python/hyperlight_js_backend && uv run --no-sync maturin develop
39-
40-
python-install-backend-hyperlight-js-release:
41-
rm -rf {{repo-root}}/target/release/build/hyperlight-js-* \
42-
{{repo-root}}/target/release/.fingerprint/hyperlight-js-*
43-
cd {{repo-root}}/src/sdk/python/hyperlight_js_backend && uv run --no-sync maturin develop --release
44-
45-
python-build: python-sync-guest-resources python-sync-env python-install-backend-wasm python-install-backend-hyperlight-js
30+
# Install maturin backends into the local venv for development (maturin develop).
31+
# This compiles the Rust backend crates and installs them as editable packages
32+
# in the local venv so you can `import hyperlight_sandbox` directly.
33+
# For distributable wheels, use `python-dist` (maturin build) instead.
34+
# Use `just python python-build` for debug, `just python python-build release` for release.
35+
python-install-backends profile="debug":
36+
#!/usr/bin/env bash
37+
set -e
38+
release_flag=""
39+
if [ "{{ profile }}" = "release" ]; then
40+
release_flag="--release"
41+
rm -rf {{repo-root}}/target/release/build/hyperlight-wasm-* \
42+
{{repo-root}}/target/release/.fingerprint/hyperlight-wasm-* \
43+
{{repo-root}}/target/release/build/hyperlight-js-* \
44+
{{repo-root}}/target/release/.fingerprint/hyperlight-js-*
45+
fi
46+
cd {{repo-root}}/src/sdk/python/wasm_backend && {{ wit-world }} uv run --no-sync maturin develop $release_flag
47+
cd {{repo-root}}/src/sdk/python/hyperlight_js_backend && uv run --no-sync maturin develop $release_flag
4648

47-
python-build-release: python-sync-guest-resources python-sync-env python-install-backend-wasm-release python-install-backend-hyperlight-js-release
49+
python-build profile="debug": python-sync-guest-resources python-sync-env (python-install-backends profile)
4850

4951
build: python-build
5052

@@ -58,7 +60,7 @@ python-dist: python-sync-guest-resources
5860
cd {{repo-root}}/src/sdk/python/wasm_guests/python_guest && uv run python -m build --outdir {{python-guest-dist}}
5961
cd {{repo-root}}/src/sdk/python/wasm_guests/javascript_guest && uv run python -m build --outdir {{javascript-guest-dist}}
6062

61-
python-publish repository="pypi": python-dist
63+
python-publish repository="pypi":
6264
#!/usr/bin/env bash
6365
set -e
6466
publish_url=()
@@ -71,25 +73,25 @@ python-publish repository="pypi": python-dist
7173
uv publish "${publish_url[@]}" {{javascript-guest-dist}}/*
7274
uv publish "${publish_url[@]}" {{core-dist}}/*
7375

74-
python-wheelhouse-test: python-sync-guest-resources
76+
python-wheelhouse-test: python-dist
7577
#!/usr/bin/env bash
7678
set -e
77-
wheelhouse=$(mktemp -d)
7879
root={{repo-root}}
79-
80-
uv build --wheel --out-dir "$wheelhouse" "$root/src/sdk/python/core"
81-
{{ wit-world }} uv build --wheel --out-dir "$wheelhouse" "$root/src/sdk/python/wasm_backend"
82-
uv build --wheel --out-dir "$wheelhouse" "$root/src/sdk/python/hyperlight_js_backend"
83-
uv build --wheel --out-dir "$wheelhouse" "$root/src/sdk/python/wasm_guests/python_guest"
84-
uv build --wheel --out-dir "$wheelhouse" "$root/src/sdk/python/wasm_guests/javascript_guest"
80+
dist={{dist-root}}
8581

8682
# Test wasm + python guest
87-
uv run --no-project --no-index --find-links="$wheelhouse" \
83+
uv run --no-project --no-index \
84+
--find-links="$dist/core" \
85+
--find-links="$dist/wasm_backend" \
86+
--find-links="$dist/python_guest" \
8887
--with "hyperlight-sandbox[wasm,python_guest]" \
8988
python "$root/src/sdk/python/tests/wheelhouse_wasm.py"
9089

9190
# Test hyperlight-js + javascript guest
92-
uv run --no-project --no-index --find-links="$wheelhouse" \
91+
uv run --no-project --no-index \
92+
--find-links="$dist/core" \
93+
--find-links="$dist/hyperlight_js_backend" \
94+
--find-links="$dist/javascript_guest" \
9395
--with "hyperlight-sandbox[hyperlight_js,javascript_guest]" \
9496
python "$root/src/sdk/python/tests/wheelhouse_js.py"
9597

@@ -106,7 +108,7 @@ examples: python-build
106108
{{ wit-world }} uv run python {{repo-root}}/src/sdk/python/core/examples/jswasm_network_demo.py
107109
{{ wit-world }} uv run python {{repo-root}}/src/sdk/python/core/examples/jswasm_filesystem_demo.py
108110

109-
python-sandbox-benchmark: python-build-release
111+
python-sandbox-benchmark: (python-build "release")
110112
{{ wit-world }} uv run python {{repo-root}}/src/sdk/python/core/examples/benchmark.py
111113

112114
#### CLEAN ####

src/wasm_sandbox/Justfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@ guest-compile-wit: ensure-tools
2424
rm -rf {{repo-root}}/target/hyperlight-wasm-runtime \
2525
{{repo-root}}/target/debug/build/hyperlight-wasm-* \
2626
{{repo-root}}/target/debug/.fingerprint/hyperlight-wasm-* \
27+
{{repo-root}}/target/release/build/hyperlight-wasm-* \
28+
{{repo-root}}/target/release/.fingerprint/hyperlight-wasm-* \
2729
{{repo-root}}/src/sdk/python/wasm_backend/target/hyperlight-wasm-runtime \
2830
{{repo-root}}/src/sdk/python/wasm_backend/target/debug/build/hyperlight-wasm-* \
2931
{{repo-root}}/src/sdk/python/wasm_backend/target/debug/.fingerprint/hyperlight-wasm-* \
32+
{{repo-root}}/src/sdk/python/wasm_backend/target/release/build/hyperlight-wasm-* \
33+
{{repo-root}}/src/sdk/python/wasm_backend/target/release/.fingerprint/hyperlight-wasm-* \
3034
2>/dev/null || true
3135

3236
guest-build-aot target=default-target: guest-build-wasm ensure-tools

0 commit comments

Comments
 (0)