Skip to content

Add Pixi workflow to verify Pyodide build works#1449

Open
IvanIsCoding wants to merge 53 commits intoQiskit:mainfrom
IvanIsCoding:pixi-pyodide
Open

Add Pixi workflow to verify Pyodide build works#1449
IvanIsCoding wants to merge 53 commits intoQiskit:mainfrom
IvanIsCoding:pixi-pyodide

Conversation

@IvanIsCoding
Copy link
Copy Markdown
Collaborator

@IvanIsCoding IvanIsCoding commented May 13, 2025

Follow up of #1447

This uses pixi to run the Pyodide build. This is still higly experimental. It is related to #1416 and #1420 in the sense that pixi is to conda what uv is to pypi.

The Github Action workflow I created does the following:

  • Installs Python 3.12.7 from Conda via Pixi. Python needs to be pinned
  • Installs Emscripten 3.1.58. This is also pinned. Newer versions are required to build with Python 3.13 but that is not on Conda at the moment.
  • Installs Node.js
  • Installs Rust 1.86. Generally we'd use nightly rust, but Conda does not offer that. So I had to use the RUSTC_BOOTSTRAP trick to enable nightly features on a compiler. Of course that is terrible, but the version is pinned so essentially it is like using a pinned nightly compiler
  • Installs a pinned version of https://github.com/pyodide/pyodide-build
  • The Pyodide CLI installs the tools to build for 0.27.7, which maps to Python 3.12
  • Compiles the code with Rust and Emscripten

Tests are included in #1450

@coveralls
Copy link
Copy Markdown

coveralls commented May 13, 2025

Pull Request Test Coverage Report for Build 21499831342

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.01%) to 94.203%

Files with Coverage Reduction New Missed Lines %
rustworkx-core/src/generators/random_graph.rs 2 69.81%
Totals Coverage Status
Change from base Build 21464860520: -0.01%
Covered Lines: 18283
Relevant Lines: 19408

💛 - Coveralls

@IvanIsCoding IvanIsCoding modified the milestones: 0.17.1, 0.18.0 Oct 24, 2025
@IvanIsCoding
Copy link
Copy Markdown
Collaborator Author

Emscripten 4.0.9 seems to be broken with binaryen, I'll need to investigate. It's a shame because I wanted to bump Pyodide such that we can test with the Pyodide shipped by uv

@IvanIsCoding
Copy link
Copy Markdown
Collaborator Author

Looks like uv might support a version compiled
with emscripten 3.1.58

@IvanIsCoding IvanIsCoding mentioned this pull request Dec 15, 2025
Copy link
Copy Markdown
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

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

Sorry this took me so long to follow up on. This looks good to me, it exciting to see a workflow for building pyodide in CI. I just had a couple of questions inline. I wasn't able to get pixi working locally and I'm wondering if something went stale while this was waiting on my review.

At the root of the directory, simply run:

```bash
pixi run build_pyodide
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

When I run this locally I first got an issue about the emcc -v call failing, when I set the env var to skip the version check it errors during the build with:

error: linking with `emcc` failed: exit status: 1
  |
  = note:  "emcc" "-s" "EXPORTED_FUNCTIONS=[\"_PyInit_generators\",\"_PyInit_rustworkx\"]" "<1 object files omitted>" "/home/mtreinish/git/qiskit/retworkx/target/wasm32-unknown-emscripten/release/deps/{libcompiler_builtins-ee68dc841fe2a394.rlib}.rlib" "-B<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "--target=wasm32-unknown-emscripten" "-sDISABLE_EXCEPTION_CATCHING=0" "-o" "/home/mtreinish/git/qiskit/retworkx/target/wasm32-unknown-emscripten/release/deps/rustworkx.wasm" "-O3" "-g0" "-sSIDE_MODULE=2" "-sWASM_BIGINT" "-sSIDE_MODULE=2" "-sWASM_BIGINT" "-sABORTING_MALLOC=0" "-sWASM_BIGINT"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: Traceback (most recent call last):
            File "/home/mtreinish/git/qiskit/retworkx/.pixi/envs/default/bin/emcc", line 23, in <module>
              from tools.toolchain_profiler import ToolchainProfiler
          ModuleNotFoundError: No module named 'tools'

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.

So I have not been able to reproduce this. I tested on Linux locally, Mac locally, and on CI.

If you tell me the workaround you used, I can add it to pyproject.toml or at least mention it in CONTRIBUTING.md

@IvanIsCoding IvanIsCoding requested a review from mtreinish March 22, 2026 17:44
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