Wasmer Python, the Cranelift compiler

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
store = Store(engine.JIT(Compiler))
store = Store(engine.Native(Compiler))
module = Module(store, open('my_program.wasm', 'rb').read())
instance = Instance(module)
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
.