You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To install wasmtime-py, run this command in your terminal:
$ pip install wasmtime
The package currently supports 64-bit builds of Python 3.9+ on Windows,
macOS, and Linux, for x86_64 and arm64 architectures.
Versioning
wasmtime-py follows the Wasmtime versioning scheme, with a new major version being
released every month. As with Wasmtime itself, new major versions of wasmtime-py
can contain changes that break code written against the previous major version.
Since every installed Python package needs to agree on a single version of
wasmtime-py, to use the upper bound on the major version in the dependency
requirement should be bumped reguarly, ideally as soon as a new wasmtime-py
version is released. To automate this process it is possible to use
the whitequark/track-pypi-dependency-version script. YoWASP/runtime is
an example of a project that automatically publishes releases on PyPI once a new
version of wasmtime-py is released if it passes the testsuite.
Usage
In this example, we compile and instantiate a WebAssembly module and use it from Python:
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` filesimportwasmtime.loader# Assuming `your_wasm_file.wasm` is in the python load path...importyour_wasm_file# Now you're compiled and instantiated and ready to go!print(your_wasm_file.run())
Components
Components are also supported in wasmtime-py. For more information see the
documentation of
wasmtime.component.
Using a component is similar to using core wasm modules, and for examples see
the tests/component/ directory.