Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Consider using release 116.0.1 instead.
Reason given by maintainers: Wrong tags

icpp-binaryen

cffi bindings over Binaryen's C API, with the official Binaryen shared library bundled per platform.

Built and maintained by icppWorld for the icpp-pro toolchain of the Internet Computer, and usable by any project that needs Binaryen from Python.

Why

The Internet Computer rejects a wasm module with more than 1000 defined globals (install error IC0505). A wasi-sdk build of a large C++ project blows past this. The fix: remove every export of kind global (an exported global is otherwise kept alive), then run Binaryen's optimizer, which drops the now-dead globals. fix_globals_limit does exactly that.

Install

pip install icpp-binaryen

One wheel per platform (macOS x86_64 / arm64, Linux x86_64) covers every Python version >= 3.11: the bindings use cffi in ABI mode, so there is no compiled extension module. On Windows, use WSL.

Public API — all of it

from icpp_binaryen import fix_globals_limit  # the one high-level entry point
from icpp_binaryen import Module             # load / optimize / emit / write
from icpp_binaryen import ffi, lib           # raw escape hatch
from icpp_binaryen import BINARYEN_VERSION   # int, from the bundled version.txt

fix_globals_limit

from pathlib import Path
from icpp_binaryen import fix_globals_limit

report = fix_globals_limit(Path("build/my_canister.wasm"))
print(report.summary())

Rewrites the wasm in place and keeps a byte-identical backup copy (default <stem>_before_opt.wasm). Returns a GlobalsFixReport with the before/after counts of exports and defined globals.

Documented side effect: the optimize pass strips the wasm name section. The _before_opt backup is what keeps named backtraces possible (e.g. under wasmtime). This is by design — do not delete the backup pair.

Module

from icpp_binaryen import Module

with Module.load("my.wasm") as module:      # or Module.read(wasm_bytes)
    print(module.num_exports, module.num_globals)
    for name in module.global_export_names():
        module.remove_export(name)
    module.optimize(shrink_level=0, optimize_level=0)
    assert module.validate()
    module.write("my_fixed.wasm")           # or wasm_bytes = module.emit()

ffi / lib

The raw ABI-mode cffi handles, for post-processing needs beyond the wrapper. The cdef is a hand-curated subset of binaryen-c.h — see src/icpp_binaryen/_cdef.py for what is available. module.ref hands you the raw BinaryenModuleRef for use with lib directly.

Versioning

<binaryen>.<minor>.<patch> — the major component IS the bundled Binaryen version, asserted at import time. The wasm bytes this package emits are part of its contract: minor/patch releases are byte-identical in fix_globals_limit output; a Binaryen bump is a major release.

Contributing

See README-feature-guide.md (the ceremony-based development process) and README-release-guide.md. Development setup:

conda create --name icpp-binaryen python=3.11
conda activate icpp-binaryen
make install-python
make get-binaryen        # fetch the official Binaryen lib for this platform
make all-tests

Credits & license

Apache-2.0, like Binaryen itself. The cffi-over-libbinaryen approach was inspired by jonathanharg/binaryen.py, which this package replaces for the icpp-pro toolchain.

Metadata

Release files for icpp-binaryen 116.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for icpp-binaryen 116.0.0
File Interpreter ABI Platform
icpp_binaryen-116.0.0-py3-none-manylinux_2_35_x86_64.whl Python 3 none Linux glibc 2.35+ x86-64 Details
icpp_binaryen-116.0.0-py3-none-macosx_11_0_universal2.whl Python 3 none macOS 11.0+ universal2 (ARM64, x86-64) Details
icpp_binaryen-116.0.0-py3-none-macosx_10_14_universal2.whl Python 3 none macOS 10.14+ universal2 (ARM64, x86-64) Details

Total release size: 15.4 MB

Release files / icpp_binaryen-116.0.0-py3-none-manylinux_2_35_x86_64.whl

Download URL icpp_binaryen-116.0.0-py3-none-manylinux_2_35_x86_64.whl
Size 6.3 MB
Tags Linux glibc 2.35+ x86-64 Python 3
SHA-256 checksum
How to use checksums
3e4b3d711cd09cae9be05df5486bef44cafce13fd87725749ba859dc15441ddd
BLAKE2b-256 checksum
How to use checksums
d11a958c4d83abb8097ba425add9b6122587059cf399f43eb3ca969ea9074f1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

Release files / icpp_binaryen-116.0.0-py3-none-macosx_11_0_universal2.whl

Download URL icpp_binaryen-116.0.0-py3-none-macosx_11_0_universal2.whl
Size 4.1 MB
Tags Python 3 macOS 11.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
bc4ac526d36ed3f605d4f8e5b96b13b72b28dce9ab8b8b6a32c4542df8771014
BLAKE2b-256 checksum
How to use checksums
4e19c618b886c42d081a63ba249c56c13c7492ca7fb102c1948d212a54616814
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

Release files / icpp_binaryen-116.0.0-py3-none-macosx_10_14_universal2.whl

Download URL icpp_binaryen-116.0.0-py3-none-macosx_10_14_universal2.whl
Size 5.0 MB
Tags Python 3 macOS 10.14+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
4a1c580391f1383ea4b86555431189a00abc8c13547e189c1e02a2593f0f7632
BLAKE2b-256 checksum
How to use checksums
521fee01bb92b015e78509f1b557bfe0fb3d91a274c997bd5bc678cec40ad358
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

116.0.0 This release

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page