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.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wasmtime-0.30.0-py3-none-win_amd64.whl.
File metadata
- Download URL: wasmtime-0.30.0-py3-none-win_amd64.whl
- Upload date:
- Size: 3.8 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca6fc2faf2658569d397ed386a435dbdb7d325eef58535ef24bb25d525f6d2fa
|
|
| MD5 |
443c33c84180f780a224cb116cac0d68
|
|
| BLAKE2b-256 |
59c4e83b323e69512bf6502a90ec2a8b64b0277b9ece0646aa0f63057900a406
|
File details
Details for the file wasmtime-0.30.0-py3-none-manylinux1_x86_64.whl.
File metadata
- Download URL: wasmtime-0.30.0-py3-none-manylinux1_x86_64.whl
- Upload date:
- Size: 5.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f6a83ead797430e1a63ef5fcd5e93cd2013f0dc67600c4130cf9a7f269ef748
|
|
| MD5 |
a06e17aaa0268f4decc60f556ed229ce
|
|
| BLAKE2b-256 |
ee1924bad181bfd97b5bc67dcf50297a0ecbe5ff8458bd05215520a481bcb36a
|
File details
Details for the file wasmtime-0.30.0-py3-none-macosx_10_13_x86_64.whl.
File metadata
- Download URL: wasmtime-0.30.0-py3-none-macosx_10_13_x86_64.whl
- Upload date:
- Size: 4.4 MB
- Tags: Python 3, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5728a9555a1042c49a331db189f95ce158ae440ef9fbc98b71a39b5b9201cff8
|
|
| MD5 |
551523413c786e164e06a7d4d5f0edf2
|
|
| BLAKE2b-256 |
960638ddb3d3f7ab199ef8c1e313f6451a6d1b19137519542fb82c0e0aa4b419
|
File details
Details for the file wasmtime-0.30.0-py3-none-any.whl.
File metadata
- Download URL: wasmtime-0.30.0-py3-none-any.whl
- Upload date:
- Size: 8.9 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b2b85d80408f8090997be9c5db8d6e2724d8967f7f357879a410b7ce7be0ae8
|
|
| MD5 |
f1eb26eadb97a1b4893c080f2e325474
|
|
| BLAKE2b-256 |
1ccc615374204bd360eaa2e7b426ea9dcd6e8692c5cbae67082295fc5e925ba5
|