Skip to content

ci: Build WebAssembly (wasm32-unknown-emscripten) wheels#1788

Draft
aborgna-q wants to merge 1 commit into
mainfrom
agents/wasm-wheels
Draft

ci: Build WebAssembly (wasm32-unknown-emscripten) wheels#1788
aborgna-q wants to merge 1 commit into
mainfrom
agents/wasm-wheels

Conversation

@aborgna-q

@aborgna-q aborgna-q commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Warning

⚠️ This PR is an LLM-generated proof of concept ⚠️

Summary

Adds a wasm job to the Python wheels workflow that cross-compiles the tket Python extension to wasm32-unknown-emscripten, producing pyodide-compatible WebAssembly wheels. Implements #1415.

Targets Emscripten 5.0.3 / Python 3.14 (pyodide pyemscripten_2026_0 ABI), mirroring the proven hugr wasm-wheel pipeline.

Changes

  • tket1-passes/build.rs: recognise the emscripten target (SupportedPlatform::Emscripten) and skip linking a system stdc++ — the em++ linker driver provides its own libc++. The wasm tket-c-api static archive is consumed via TKET_C_API_PATH.
  • .github/workflows/python-wheels.yml: new wasm job — nightly Rust with -Zbuild-std, emsdk 5.0.3, Python 3.14 — that fetches the prebuilt emscripten tket-c-api from hugrverse-env via install-hugrenv-action with the new target: emscripten_wasm32 input (and packages: tket, since llvm has no wasm build).

Dependencies / sequencing

⚠️ This depends on Quantinuum/hugrverse-env#15 (adds the emscripten_wasm32 build + the target action input). Before the wasm job can succeed:

  1. hugrverse-env#15 merges to main.
  2. A hugrverse-env release is cut that includes the hugrenv-tket-emscripten_wasm32.tar.gz asset.
  3. tket2's hugrenv.lock version points at that release.

Note: the wheels workflow only triggers on push to main, tags, or workflow_dispatch (not on PRs), so this PR won't build wheels on its own.

Open questions / known limitations

  • pytket dependency: tket-py depends on pytket, which has no wasm wheel, so importing the wasm wheel in pyodide may require additional work (cf. jpacold's notes on the issue).
  • Threading: rayon par_iter_mut paths won't work under single-threaded wasm; may need a feature-flag/fallback.
  • The wasm job is intentionally not added to the release needs yet, pending a decision on whether to publish emscripten wheels to PyPI.

Draft — pending hugrverse-env#15.

Add a `wasm` job to the python-wheels workflow that cross-compiles the
tket Python extension to `wasm32-unknown-emscripten`, producing
pyodide-compatible wheels.

- build.rs: recognise the emscripten target and skip linking a system
  `stdc++` (the `em++` linker driver provides its own libc++). The
  wasm tket-c-api archive is consumed via TKET_C_API_PATH.
- python-wheels.yml: new `wasm` job using nightly Rust with
  `-Zbuild-std`, emsdk 5.0.3 and Python 3.14, fetching the prebuilt
  emscripten tket-c-api from hugrverse-env via the install-hugrenv-action
  `target: emscripten_wasm32` input.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.56%. Comparing base (0b7766d) to head (62a2c94).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1788      +/-   ##
==========================================
- Coverage   85.57%   85.56%   -0.02%     
==========================================
  Files         197      197              
  Lines       30964    30964              
  Branches    29528    29528              
==========================================
- Hits        26497    26493       -4     
- Misses       3192     3195       +3     
- Partials     1275     1276       +1     
Flag Coverage Δ
rust 85.24% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant