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["run"]
run()
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.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distributions
Close
Hashes for wasmtime-0.26.0-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0bc2bab0c28dff73b701537a153c211d590d4af0e082454d10df03f22d0ff6c2 |
|
MD5 | 1b8336de3f7032e862e8db5ba112a5fb |
|
BLAKE2b-256 | 4e4b8206d6ae46645a8ca9ea254f6f5608d329c1245967eace4ac51c240cc7be |
Close
Hashes for wasmtime-0.26.0-py3-none-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10dc80dd28fafb369962be66636d82272c23b56aa8f19857d6e88592ddc06d92 |
|
MD5 | 319420e9bdf9c518dfd3f39d1af19bf4 |
|
BLAKE2b-256 | 2d9c4df0d927e460a0bec0c20d90441d86eedb5836485377c69113b3d06a87ef |
Close
Hashes for wasmtime-0.26.0-py3-none-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3e79183b1424b926a5e1d891d58eafb88197f8e8eb8ba4eb63c5efcf685d7be |
|
MD5 | f66da8498df32d0549225d5865401ba4 |
|
BLAKE2b-256 | 7be1498b961e7025f3427a1486099041e7d99f9f510dbb301a365c8aaf55a928 |
Close
Hashes for wasmtime-0.26.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4543973f49033dfcd0578389f2a74fa3f087bb2707d2913b8c81e5b7d069f3f7 |
|
MD5 | 3dd5de8b820c270488ac33e212580fbf |
|
BLAKE2b-256 | 3e11c82388ba83e76450f34af250ed0959906a845c94dec3c457227ffcd534ef |