Skip to main content

Python extension to run WebAssembly binaries

Project description

Wasmer logo Wasmer Python, the Singlepass compiler PyPI version Wasmer Python Documentation Wasmer PyPI downloads Wasmer Slack Channel

wasmer is a complete and mature WebAssembly runtime for Python. wasmer_compiler_singlepass provides the Singlepass compiler to wasmer, so that wasmer is able to compile WebAssembly module.

Other compilers exist:

  • wasmer_compiler_cranelift,
  • wasmer_compiler_llvm.

To get a more complete view, please see the documentation of the wasmer package itself.

Install

This package must be used with the wasmer package, thus:

$ pip install wasmer
$ pip install wasmer_compiler_singlepass

Usage

Any engines in wasmer.engine can take the wasmer_compiler_singlepass.Compiler class as argument:

from wasmer import engine, Store, Module, Instance
from wasmer_compiler_singlepass import Compiler

# Let's use the Singlepass compiler with the JIT engine…
store = Store(engine.JIT(Compiler))

# … or with the native engine!
store = Store(engine.Native(Compiler))

# And now, compile the module.
module = Module(store, open('my_program.wasm', 'rb').read())

# Now it's compiled, let's instantiate it.
instance = Instance(module)

# And get fun, for example by calling the `sum` exported function!
print(instance.exports.sum(1, 2))

Documentation

Browse the documentation at https://wasmerio.github.io/wasmer-python/api/wasmer_compiler_singlepass/.

Alternatively, run just build compiler-singlepass followed by just doc to generate the documentation inside docs/api/wasmer_compiler_singlepass.html.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

wasmer_compiler_singlepass-1.1.0-cp310-none-win_amd64.whl (539.0 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

wasmer_compiler_singlepass-1.1.0-cp310-cp310-manylinux_2_24_x86_64.whl (635.9 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.24+ x86-64

wasmer_compiler_singlepass-1.1.0-cp310-cp310-macosx_10_7_x86_64.whl (574.4 kB view hashes)

Uploaded CPython 3.10 macOS 10.7+ x86-64

wasmer_compiler_singlepass-1.1.0-cp39-none-win_amd64.whl (538.9 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

wasmer_compiler_singlepass-1.1.0-cp39-cp39-manylinux_2_24_x86_64.whl (636.1 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.24+ x86-64

wasmer_compiler_singlepass-1.1.0-cp39-cp39-macosx_10_7_x86_64.whl (574.6 kB view hashes)

Uploaded CPython 3.9 macOS 10.7+ x86-64

wasmer_compiler_singlepass-1.1.0-cp38-none-win_amd64.whl (539.0 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

wasmer_compiler_singlepass-1.1.0-cp38-cp38-manylinux_2_24_x86_64.whl (635.7 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.24+ x86-64

wasmer_compiler_singlepass-1.1.0-cp38-cp38-macosx_10_7_x86_64.whl (574.4 kB view hashes)

Uploaded CPython 3.8 macOS 10.7+ x86-64

wasmer_compiler_singlepass-1.1.0-cp37-none-win_amd64.whl (539.0 kB view hashes)

Uploaded CPython 3.7 Windows x86-64

wasmer_compiler_singlepass-1.1.0-cp37-cp37m-manylinux_2_24_x86_64.whl (635.7 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.24+ x86-64

wasmer_compiler_singlepass-1.1.0-cp37-cp37m-macosx_10_7_x86_64.whl (574.5 kB view hashes)

Uploaded CPython 3.7m macOS 10.7+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page