A WebAssembly runtime powered by Wasmtime
Project description
Installation
To install wasmtime-py
, run this command in your terminal:
$ pip install wasmtime
The package currently supports 64-bit builds of Python 3.6+ on x86_64 Windows, macOS, and Linux
Usage
In this example, we compile and instantiate a WebAssembly module and use it from Python:
from wasmtime import Store, Module, Instance, Func, FuncType store = Store() module = Module(store.engine, """ (module (func $hello (import "" "hello")) (func (export "run") (call $hello)) ) """) def say_hello(): print("Hello from Python!") hello = Func(store, FuncType([], []), say_hello) instance = Instance(store, module, [hello]) run = instance.exports(store)["run"] run(store)
Be sure to check out the examples
directory, which has other usage patterns
as well as the full API documentation of the wasmtime-py
package.
If your WebAssembly module works this way, then you can also import the WebAssembly module directly into Python without explicitly compiling and instantiating it yourself:
# Import the custom loader for `*.wasm` files import wasmtime.loader # Assuming `your_wasm_file.wasm` is in the python load path... import your_wasm_file # Now you're compiled and instantiated and ready to go! print(your_wasm_file.run())
Contributing
See CONTRIBUTING.md
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Built Distributions
Close
Hashes for wasmtime-0.38.0-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30d2210fb66cf8bf19b25b8beac6d8a848dd9f963ae31cd5f39a1e157f868dcc |
|
MD5 | 7018c55f138d598257f2fc1d4dd4e42b |
|
BLAKE2-256 | df6c051f6b5e496c3a4a69eaa6af3afc07e38292e62991e50674ed756ced760f |
Close
Hashes for wasmtime-0.38.0-py3-none-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63bd31ce0d7db5968da51316f49d64081b9f0aff04df2a063b39df475a5f1bc2 |
|
MD5 | 85b38ba9fe06fd350d31dabf71fcdf2d |
|
BLAKE2-256 | b3a036ada9294db939a1f4401527fc0b17f9d29aa574b81f2831c0e3a328b6af |
Close
Hashes for wasmtime-0.38.0-py3-none-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb5ef3225da353c95f9ec721e61979ed57299fbcffbc4ecdbe5e9cc699035066 |
|
MD5 | 3769ee5878b75181e725c617d9ddf0b6 |
|
BLAKE2-256 | 21d643cc06924b87211a357eb78f894a39a731d34853293e5f63ebf923791e52 |
Close
Hashes for wasmtime-0.38.0-py3-none-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78c283a25dce82665634e421ae369a0b11e3ff39bd3f621ebb5c266afa59a2d7 |
|
MD5 | 3ae76af1c5544bd5582011e5d0d4d083 |
|
BLAKE2-256 | 5ee12aec232249520671a9a97aec60233b009c53f6a38f6357c6affdb0fb5d8b |
Close
Hashes for wasmtime-0.38.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69df8e73817a8483454fef71f5eca37f970e7dcd89ef4c4c6eba0bcfa9807c67 |
|
MD5 | 1e0dd96d3210ac388b7533c28df3b844 |
|
BLAKE2-256 | 6caa98cbb06db20e276237de195a3eec676d624e9280dee335db723affd8db58 |