Skip to main content

The Cranelift compiler for the `wasmer` package (to compile WebAssembly module)

Project description

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

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

Other compilers exist:

  • wasmer_compiler_llvm,
  • wasmer_compiler_singlepass.

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_cranelift

Usage

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

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

# Let's use the Cranelift 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_cranelift/.

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

Download files

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

Files for wasmer-compiler-cranelift, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size wasmer_compiler_cranelift-1.0.0-cp36-cp36m-macosx_10_7_x86_64.whl (1.5 MB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size wasmer_compiler_cranelift-1.0.0-cp36-cp36m-manylinux2010_x86_64.whl (1.6 MB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size wasmer_compiler_cranelift-1.0.0-cp36-none-win_amd64.whl (1.5 MB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size wasmer_compiler_cranelift-1.0.0-cp37-cp37m-macosx_10_7_x86_64.whl (1.5 MB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size wasmer_compiler_cranelift-1.0.0-cp37-cp37m-manylinux2010_x86_64.whl (1.6 MB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size wasmer_compiler_cranelift-1.0.0-cp37-none-win_amd64.whl (1.5 MB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size wasmer_compiler_cranelift-1.0.0-cp38-cp38-macosx_10_7_x86_64.whl (1.5 MB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size wasmer_compiler_cranelift-1.0.0-cp38-cp38-manylinux2010_x86_64.whl (1.6 MB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size wasmer_compiler_cranelift-1.0.0-cp38-none-win_amd64.whl (1.5 MB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size wasmer_compiler_cranelift-1.0.0-cp39-cp39-macosx_10_7_x86_64.whl (1.5 MB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size wasmer_compiler_cranelift-1.0.0-cp39-cp39-macosx_11_0_arm64.whl (1.4 MB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size wasmer_compiler_cranelift-1.0.0-cp39-cp39-manylinux2010_x86_64.whl (1.6 MB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size wasmer_compiler_cranelift-1.0.0-cp39-none-win_amd64.whl (1.5 MB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size wasmer_compiler_cranelift-1.0.0-py3-none-any.whl (1.9 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page