Skip to content

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

Merged
aborgna-q merged 14 commits into
mainfrom
agents/wasm-wheels
Aug 27, 2026
Merged

aborgna-q merged 14 commits into
mainfrom
agents/wasm-wheels

Conversation

@aborgna-q

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

Copy link
Copy Markdown
Collaborator

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 4.0.9 / Python 3.13 (pyodide pyemscripten_2025_0 ABI), to match hugr's wasm wheels


I tested these locally with emscripten, and in a guppy-playpond instance.
Note that the pytket python wheel is not available in WASM, but tket's pytket-based pass work correctly as they use an internally compiled tket-c-api.

Wheel building run: https://github.com/Quantinuum/tket2/actions/runs/33096483912/job/98602665474

@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 86.60%. Comparing base (b6baef6) to head (f0863fb).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1788      +/-   ##
==========================================
- Coverage   86.60%   86.60%   -0.01%     
==========================================
  Files         202      202              
  Lines       32644    32679      +35     
  Branches    31158    31193      +35     
==========================================
+ Hits        28271    28301      +30     
- Misses       3089     3092       +3     
- Partials     1284     1286       +2     
Flag Coverage Δ
python 91.64% <ø> (ø)
qis-compiler 73.60% <ø> (ø)
rust 86.35% <100.00%> (-0.01%) ⬇️

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.

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>
@aborgna-q
aborgna-q marked this pull request as ready for review August 21, 2026 11:59
@aborgna-q
aborgna-q requested a review from a team as a code owner August 21, 2026 11:59
@aborgna-q
aborgna-q requested review from cqc-alec and doug-q August 21, 2026 11:59

@doug-q doug-q left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a couple comments

Comment thread .github/workflows/python-wheels.yml Outdated
.convert_pyerrs()?;
// Emscripten wheels are built with `rayon` disabled, so we need to run the
// pass sequentially in that case.
if cfg!(target_os = "emscripten") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a weird way to do it. Rayon doesn't look like it's disabled in Cargo.toml.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's mostly that running par_iter_mut on emscripten fails at runtime:

The global thread pool has not been initialized:
ThreadPoolBuildError {
    kind: IOError(Os {
        code: 6,
        kind: WouldBlock,
        message: "Resource temporarily unavailable"
    })
}

I'll update the comment

Comment thread .github/workflows/python-wheels.yml Outdated
@aborgna-q
aborgna-q added this pull request to the merge queue Aug 27, 2026
Merged via the queue into main with commit 066576a Aug 27, 2026
36 checks passed
@aborgna-q
aborgna-q deleted the agents/wasm-wheels branch August 27, 2026 17:18
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.

3 participants