Skip to content

Add working ONNX 1.15 recipe#620

Closed
metalmancode wants to merge 2 commits into
pyodide:mainfrom
metalmancode:add-onnx-working-recipe
Closed

Add working ONNX 1.15 recipe#620
metalmancode wants to merge 2 commits into
pyodide:mainfrom
metalmancode:add-onnx-working-recipe

Conversation

@metalmancode

@metalmancode metalmancode commented Jul 13, 2026

Copy link
Copy Markdown

Summary

Add an experimental ONNX 1.15.0 recipe with a reproducible, working WebAssembly build.

Closes #216 with a version set that has been built from the recipe, structurally verified, and exercised through a full browser conversion path.

Cross-compilation fixes

  • use a host-native protoc 22.3 while compiling the Protobuf runtime for WebAssembly;
  • pass the target Python include directories from PYTHONINCLUDE to CMake;
  • remove the ELF-only --exclude-libs linker option unsupported by wasm-ld; and
  • disable Protobuf thread-safety for the standard single-threaded side-module build.

The host protoc archive is pinned by SHA-256.

Validation

The independently reproduced Pyodide 0.29.4 / Python 3.13 build produced a 1.7 MB wheel and passed:

  1. WebAssembly magic and CPython module-export checks;
  2. import onnx, onnx.checker, and onnx.helper;
  3. browser-local scikit-learn training;
  4. conversion with skl2onnx 1.19.1;
  5. ONNX validation and serialization; and
  6. execution with ONNX Runtime Web 1.22.0.

Public recipe and build provenance:
https://github.com/metalmancode/onnx-pyodide

Live end-to-end proof:
https://metalmancode.github.io/onnx-pyodide/demo/

Verified release and wheel:
https://github.com/metalmancode/onnx-pyodide/releases/tag/v0.1.0

Wheel SHA-256:
2a827f6e2649395743afac49186343ca9221f48a1c67cce300cd019a7f448cd4

Current-repository validation

The recipe now builds successfully with the repository's current Python 3.14 / Pyodide toolchain. A targeted fork CI run built the wheel and passed the recipe's runtime test in Chrome, Firefox, and Node:

https://github.com/metalmancode/pyodide-recipes/actions/runs/29262798470

The runtime test creates a small ONNX graph, validates it through the compiled checker, serializes it, loads it back, and validates the restored model.

Related work: #463 targets ONNX 1.20.0 but currently has a failing build. This pull request intentionally starts from the independently reproduced and current-toolchain-validated 1.15.0 baseline rather than claiming unverified 1.20.0 support.

Provenance

The port and browser proof were created by Gholamreza Rashidi Ardestani (@metalmancode) from the browser-local ONNX export work used in MLDeck.

@metalmancode
metalmancode marked this pull request as ready for review July 13, 2026 15:47
@ryanking13

Copy link
Copy Markdown
Member

Thanks, but onnx is already building pyodide wheels in their repository and publishing to pypi so this is not needed.

@ryanking13 ryanking13 closed this Jul 14, 2026
@agriyakhetarpal

Copy link
Copy Markdown
Member

Yes, agreed. Also, they only build for the 2025 ABI and not the 2026 ABI based on https://pypi.org/project/onnx/#files, so perhaps you please request them to do so, @metalmancode? Thanks!

@metalmancode

Copy link
Copy Markdown
Author

Thank you for pointing me to the correct upstream location. I moved the 2026 ABI follow-up to ONNX and opened:

onnx/onnx#8192

The change now successfully builds onnx_weekly-1.23.0.dev20260714-cp312-abi3-pyemscripten_2026_0_wasm32.whl with ONNX's official Pyodide workflow and passes the Python 3.14 Pyodide runtime test. The first run also exposed an Emscripten/Abseil deprecation-pragmas issue, which the pull request addresses while retaining ONNX_WERROR=ON for other warnings.

Thanks again for the guidance.

— Gholamreza Rashidi Ardestani

andife pushed a commit to onnx/onnx that referenced this pull request Jul 14, 2026
## Summary

- target the Python 3.14 Pyodide cross-build environment
- produce a `pyemscripten_2026_0_wasm32` wheel instead of the current
2025 ABI wheel
- allow the Emscripten deprecated-macro pragmas emitted by protobuf's
bundled Abseil while retaining `ONNX_WERROR=ON` for other warnings

The additional warning exception is needed because the newer Emscripten
headers deprecate `__EMSCRIPTEN_major__`, `__EMSCRIPTEN_minor__`, and
`__EMSCRIPTEN_tiny__`, which the bundled Abseil headers still reference.

## Validation

The repository's official `Pyodide Build` workflow was run on this
branch:


https://github.com/metalmancode/onnx-pyodide-abi/actions/runs/29329430629

It completed successfully, including the cibuildwheel runtime test in a
Python 3.14 Pyodide virtual environment. The produced artifact is:

```text
onnx_weekly-1.23.0.dev20260714-cp312-abi3-pyemscripten_2026_0_wasm32.whl
SHA-256: ab20c140cbe5dfa63068ae476fcf9eb5b76d9fc4ce94b8fb2badbd391364bc37
```

`lintrunner` also completed with no lint issues.

## Context

This follows the Pyodide maintainers' recommendation in
pyodide/pyodide-recipes#620 to publish the 2026 ABI wheel from the ONNX
repository rather than add a separate recipe. The current stable and
weekly ONNX Pyodide wheels are published with the 2025 ABI.

A stable browser distribution for the Python 3.14 Pyodide environment is
not yet available, so the validation uses cibuildwheel's official Python
3.14 Pyodide runtime test.

---------

Signed-off-by: Gholamreza Rashidi Ardestani <rrashidi@gmail.com>
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.

Add package: onnx

3 participants