Skip to main content

Latest Version

Python interface to the Binaryen library

This module provides a Python interface to the binaryen webassembly library.

That library has to be installed separately, make sure it is available on your system as a shared library. You may need to add something to your link library search path to let python pick it up.

Requires Python 3.6 or newer. Also works on pypy3 (because it uses cffi). The minor version number of this library tracks the binaryen release number (such as 112)

Software license: MIT

Installation

This Python package expects binaryen to be installed in /usr/include/ and /usr/lib/. On some Linux distributions community packages are available which install Binaryen in the correct place, have a search first to see if that's available for your distribution.

For distributions that don't have this, you build from source or download a release from https://github.com/WebAssembly/binaryen/releases and install it manually.

Manual Installation

Manual installation can be done by extracting the archive, and copying (or symlinking) the files in it to the appropriate location in /usr/.

As an example here is what this might look like in GitHub Actions CI (for Ubuntu 22.04):

    - name: Install Binaryen
      run: |
        wget https://github.com/WebAssembly/binaryen/releases/download/version_109/binaryen-version_109-x86_64-linux.tar.gz
        tar -xf binaryen-version_109-x86_64-linux.tar.gz
        sudo ln -s $PWD/binaryen-version_109/include/binaryen-c.h /usr/include/binaryen-c.h
        sudo ln -s $PWD/binaryen-version_109/include/wasm-delegations.def /usr/include/wasm-delegations.def
        sudo ln -s $PWD/binaryen-version_109/lib/libbinaryen.a /usr/lib/libbinaryen.a

Example

Running the following code:

import binaryen

module = binaryen.ModuleCreate()
params = binaryen.TypeCreate([binaryen.TypeInt32(), binaryen.TypeInt32()], 2)
results = binaryen.TypeInt32()
x = binaryen.LocalGet(module, 0, binaryen.TypeInt32())
y = binaryen.LocalGet(module, 1, binaryen.TypeInt32())
add = binaryen.Binary(module, binaryen.AddInt32(), x, y)
adder = binaryen.AddFunction(module, b"adder", params, results, binaryen.ffi.NULL, 0, add)
binaryen.ModulePrint(module)
binaryen.ModuleDispose(module)

results in the following Webasm Text output:

(module
 (type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
 (func $adder (; 0 ;) (param $0 i32) (param $1 i32) (result i32)
  (i32.add
   (local.get $0)
   (local.get $1)
  )
 )
)

Release files for pybinaryen 1.124

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

Source distribution (sdist)

Source distribution for pybinaryen 1.124
File Size Uploaded
pybinaryen-1.124.tar.gz 17.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pybinaryen 1.124
File Interpreter ABI Platform
pybinaryen-1.124-py3-none-any.whl Python 3 none any Details

Total release size: 32.1 kB

Release files / pybinaryen-1.124.tar.gz

Download URL pybinaryen-1.124.tar.gz
Size 17.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1db98a407c489397279f7185998e769341bb0d334a6051f91ffdb950d671cf14
BLAKE2b-256 checksum
How to use checksums
6bec13aba62ea7ac8bb74c480c0be9e73d44d4109fff5a75679a5c98d752a5cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / pybinaryen-1.124-py3-none-any.whl

Download URL pybinaryen-1.124-py3-none-any.whl
Size 14.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
85ab1ffe0ac866ad3e5808d4f0980f7fc0a7f3da4784b038df5c332328574652
BLAKE2b-256 checksum
How to use checksums
4fcd755754d69f6141ee96c52843344d0b72fc3c3a7e4c97e00d2c6fc9c52a3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

1.124 This release

2 release files

1.123

1 release file

1.122

1 release file

1.120

2 release files

1.116

1 release file

1.112

1 release file

1.13

1 release file

1.11

1 release file

1.10

1 release file

1.9

1 release file

1.7

1 release file

1.6

1 release file

1.5

1 release file

1.4

1 release file

1.3

1 release file

1.2

1 release file

1.1

1 release file

1.0

1 release file

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