Skip to content

Add Pixi workflow to verify Pyodide build works#1449

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

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

Conversation

@IvanIsCoding
Copy link
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

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 removed this from the 0.17.0 milestone Jun 29, 2025
@IvanIsCoding IvanIsCoding added this to the 0.17.1 milestone Jul 6, 2025
@IvanIsCoding IvanIsCoding modified the milestones: 0.17.1, 0.18.0 Oct 24, 2025
@IvanIsCoding
Copy link
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
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
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.

Comment on lines +597 to +600
We'll need to align the [Emscripten](https://anaconda.org/conda-forge/emscripten) version from `conda-forge` with one
of the public releases. Then, we pick a `pyodide-build` version higher than the required build version and the equivalent Python
version also specified in the cross build environments. Lastly, update `[tool.pixi.tasks.install_xbuildenv]` to install
the selected version of Pyodide.
Copy link
Member

Choose a reason for hiding this comment

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

I assume this is because pixi is pulling emscripten from conda instead of a system installed package? But it was a bit confusing to read this description as conda isn't mentioned before. Maybe we should have a sentence before this explaining where conda is coming into play. Since this is a very different workflow from the normal rustworkx build process it's best to be a bit more explicit about how all these pieces come together.

At the root of the directory, simply run:

```bash
pixi run build_pyodide
Copy link
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'


[tool.pixi.workspace]
channels = ["conda-forge"]
platforms = ["linux-64", "osx-arm64"]
Copy link
Member

Choose a reason for hiding this comment

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

I thought we weren't supporting pixi on arm64 macos?

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