Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
7bdeaff
Pyodide: force only one thread
IvanIsCoding May 10, 2025
7ce8078
Add .cargo/config.toml
IvanIsCoding May 11, 2025
b440e6b
Unstable feature that makes rayon work
IvanIsCoding May 11, 2025
e70b263
Newline
IvanIsCoding May 11, 2025
bf15e3b
Merge remote-tracking branch 'upstream/main' into pyodide-rayon
IvanIsCoding May 11, 2025
76f5dff
Document pyodide
IvanIsCoding May 11, 2025
4b17893
Add release note for pyodide
IvanIsCoding May 11, 2025
0e3b0ce
Fix separator
IvanIsCoding May 11, 2025
3527a6f
Consolidate the bare minimum of flags
IvanIsCoding May 12, 2025
72ceb1a
Add emscripten-wasm-eh flag
IvanIsCoding May 12, 2025
65d4eb8
Use pixi to have a reproducible pyodide build
IvanIsCoding May 13, 2025
8c4ed7b
Add GitHub Actions to execute
IvanIsCoding May 13, 2025
d99c029
Fix main.yml syntax
IvanIsCoding May 13, 2025
615d5bd
Specify pyproject.toml
IvanIsCoding May 13, 2025
32e44cf
Actually download repo
IvanIsCoding May 14, 2025
ad1f19d
Add pyodide build docs
IvanIsCoding May 14, 2025
901c674
Minor stuff
IvanIsCoding May 14, 2025
92b8910
Minor update to CONTRIBUTING.md
IvanIsCoding May 14, 2025
826fbe7
Merge branch 'main' into pyodide-rayon
IvanIsCoding May 17, 2025
61383bf
Merge branch 'pyodide-rayon' into pixi-pyodide
IvanIsCoding May 17, 2025
b6fcd9a
Merge branch 'main' into pyodide-rayon
IvanIsCoding May 29, 2025
aa34512
Solve nit
IvanIsCoding May 29, 2025
854e672
Merge branch 'pyodide-rayon' into pixi-pyodide
IvanIsCoding May 29, 2025
1a04b00
Merge branch 'main' into pyodide-rayon
IvanIsCoding May 29, 2025
b0042ff
Merge branch 'pyodide-rayon' into pixi-pyodide
IvanIsCoding May 30, 2025
d7bb215
Bump pyodide to 0.27.6 and pyodide-build to 0.30.4
IvanIsCoding May 30, 2025
5378a9e
Merge branch 'main' into pyodide-rayon
IvanIsCoding Jun 4, 2025
cea6073
Merge remote-tracking branch 'origin/pyodide-rayon' into pixi-pyodide
IvanIsCoding Jun 4, 2025
6b8b8fc
Merge branch 'main' into pixi-pyodide
IvanIsCoding Jun 28, 2025
1a188e4
Merge branch 'main' into pixi-pyodide
IvanIsCoding Jun 29, 2025
24f000c
Update pyodide build & pyodide
IvanIsCoding Jun 29, 2025
ce94f8e
Merge remote-tracking branch 'upstream/main' into pixi-pyodide
IvanIsCoding Aug 12, 2025
281fae3
Merge branch 'main' into pixi-pyodide
IvanIsCoding Sep 29, 2025
74c65db
Merge branch 'main' into pixi-pyodide
IvanIsCoding Sep 29, 2025
fb02e0a
Merge branch 'main' into pixi-pyodide
IvanIsCoding Oct 24, 2025
618a669
Bump emscripten and Pyodide
IvanIsCoding Dec 13, 2025
71f03f8
Bump pixi
IvanIsCoding Dec 13, 2025
0884ce4
Refresh lock file to fix failure
IvanIsCoding Dec 13, 2025
c7af71a
Try to align Rust version with pyodide recipes
IvanIsCoding Dec 13, 2025
b3f4d2a
Revert to Pyodide 0.27.7 with emscripten 3.1.58
IvanIsCoding Dec 13, 2025
54d64b0
Merge branch 'main' into pixi-pyodide
IvanIsCoding Dec 14, 2025
52bdafc
Merge remote-tracking branch 'upstream/main' into pixi-pyodide
IvanIsCoding Dec 16, 2025
a4c1b21
Smaller diff now that pixi understands TOML better
IvanIsCoding Dec 16, 2025
cb9e76f
Fix toml
IvanIsCoding Dec 16, 2025
bdbee5b
Merge remote-tracking branch 'upstream/main' into pixi-pyodide
IvanIsCoding Jan 1, 2026
c25dec2
Merge branch 'main' into pixi-pyodide
IvanIsCoding Jan 30, 2026
1ceb2be
Merge branch 'main' into pixi-pyodide
mtreinish Mar 11, 2026
3406ff3
Merge branch 'main' into pixi-pyodide
IvanIsCoding Mar 22, 2026
7a4d3ed
Merge remote-tracking branch 'upstream/main' into pixi-pyodide
IvanIsCoding Mar 22, 2026
2c6f706
Update CONTRIBUTING.md
IvanIsCoding Mar 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
docs/* linguist-documentation
releasenotes/* linguist-documentation
# SCM syntax highlighting & preventing 3-way merges
pixi.lock merge=binary linguist-language=YAML linguist-generated=true
13 changes: 13 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,16 @@ jobs:
with:
name: html_docs
path: docs/build/html
pyodide-build:
if: github.repository_owner == 'Qiskit'
needs: [tests]
name: Pyodide Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: prefix-dev/setup-pixi@v0.9.3
with:
manifest-path: pyproject.toml
pixi-version: v0.61.0
environments: default
- run: pixi run build_pyodide
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ rustworkx-core/Cargo.lock
**/.DS_Store
venv/
.python-version

# pixi environments
.pixi
*.egg-info

# pyodide xbuild
.xbuildenv
74 changes: 74 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,80 @@ has the necessary approvals and is tagged as `automerge` unless it has a merge
conflict or has a failed CI run. Doing so will just waste CI resources and
delay everything from merging, including your PR.

### Pyodide Support

`rustworkx` has experimental support for Pyodide, the Python distribution for
the browser.

Because building for Pyodide is a more involved process, we use [Pixi](https://pixi.sh/latest/)
to manage the dependencies of the build. Currently, the scripts work only for Linux x86-64 and macOS arm64.
It is also possible to run the build on Windows with Windows Subsystem for Linux (WSL).

Please refer to the [Pixi](https://pixi.sh/latest/) page for the latest instructions on how
to install Pixi. Once installed, there's a single command that needs to be run.

#### Building for Pyodide

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'

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

```

This will create a separate environment with all of the required toolchains. At the end,
a Pyodide wheel will be available in the `dist` folder if the build is successful.

#### Testing Pyodide Wheels

Currently, there are no tests for Pyodide wheels. In the future, we plan to add smoke tests
like those in the `pyodide-recipes` repository.

#### Updating `pyodide-build` and dependencies

All the dependencies for the Pyodide build are listed under `[tool.pixi.dependencies]`. To find a set
of versions that works, visit the [pyodide-cross-build-environments.json](https://github.com/pyodide/pyodide/blob/main/pyodide-cross-build-environments.json) file in the `pyodide` repository.

Pixi pulls dependencies from `conda-forge`. Therefore, we need to work with versions published in the [Emscripten feedstock for Conda Forge](https://anaconda.org/conda-forge/emscripten). Because of the constraints imposed by Pixi, some Pyodide versions will not work with the script as the required Emscripten version is not in Conda Forge.

Once a Pyodide version with a matching Emscripten version has been picked, we need to select a `pyodide-build` version. `pyodide-build` is less tricky because we have a minimum version and not a pinned version. Select any version higher than the required build version and the equivalent Python
version.

Once all versions are picked, update `[tool.pixi.tasks.install_xbuildenv]` accordingly. For example, the following entry from `pyodide-cross-build-environments.json`:

```json
"0.27.7": {
"version": "0.27.7",
"python_version": "3.12.7",
"emscripten_version": "3.1.58",
"min_pyodide_build_version": "0.26.0"
}
```

Becomes:
```toml
[tool.pixi.dependencies]
python = "==3.12.7"
pyodide-build = "==0.30.9"
emscripten = "==3.1.58"

[tool.pixi.tasks.install_xbuildenv]
cmd = ["pyodide", "xbuildenv", "install", "0.27.7"]
```

Lastly, we need to pin the Rust compiler. To find an appropriate Rust compiler version, run:

```bash
pixi shell
pyodide config list
```

This will output a list including `rust_toolchain`. Currently, `pyodide-build` requires Rust Nightly. Because conda-forge
only provides stable releases, we'll need to map a nightly version to a stable version. Some repositories like [oxalica/rust-overlay](https://github.com/oxalica/rust-overlay/tree/master/manifests/nightly/) contain a list of the nightly releases. For example, `nightly-2025-02-01`
maps roughly to `1.86`. If that version was not yet stable, we could try picking `1.85` as well.

After updating the versions in `[tool.pixi.dependencies]`, run `pixi lock` which will update `pixi.lock`. Onwards, all builds
will use the same environment. As long as `pixi run build_pyodide` passes locally or on CI it should keep compiling and building.

### Stable Branch Policy and Backporting

The stable branch is intended to be a safe source of fixes for high-impact bugs,
Expand Down
4 changes: 4 additions & 0 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ source.
- WASM (Emscripten)
- :ref:`tier-experimental`
-
* - Pyodide
- WASM (Emscripten)
- :ref:`tier-experimental`
-


.. _manylinux 2014: https://peps.python.org/pep-0599/>
Expand Down
Loading
Loading