Skip to main content

A WebAssembly runtime powered by Wasmtime

Project description

wasmtime-py

Python embedding of Wasmtime

A Bytecode Alliance project

CI status Latest Version Latest Version Documentation Code Coverage

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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

wasmtime-2.0.0-py3-none-win_amd64.whl (3.4 MB view details)

Uploaded Python 3Windows x86-64

wasmtime-2.0.0-py3-none-manylinux2014_aarch64.whl (5.3 MB view details)

Uploaded Python 3

wasmtime-2.0.0-py3-none-manylinux1_x86_64.whl (5.4 MB view details)

Uploaded Python 3

wasmtime-2.0.0-py3-none-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

wasmtime-2.0.0-py3-none-macosx_10_13_x86_64.whl (4.1 MB view details)

Uploaded Python 3macOS 10.13+ x86-64

wasmtime-2.0.0-py3-none-any.whl (3.4 MB view details)

Uploaded Python 3

File details

Details for the file wasmtime-2.0.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: wasmtime-2.0.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 3.4 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for wasmtime-2.0.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 05c34641d78ba27ae2b97879a7bcee691f6b5ef6ac7943e59f8c8371ddd1751b
MD5 1d5ab138594ffad376f59b5d82b55449
BLAKE2b-256 a029b2f5f5644a0d9ee0968703cb4e9ececef3a2ccae238b36da1e50a6091ec4

See more details on using hashes here.

File details

Details for the file wasmtime-2.0.0-py3-none-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for wasmtime-2.0.0-py3-none-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e00050e7ae18098b50439ab75e1fb77e67f2aa34bedc8b15687887cca978d818
MD5 479d563a8828e299661d8852c2678307
BLAKE2b-256 82559d705275d795a41309d6489287b995bd5e60255b84ffcd2236defd4134c8

See more details on using hashes here.

File details

Details for the file wasmtime-2.0.0-py3-none-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for wasmtime-2.0.0-py3-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 7cedb79b27fac6e1278fc348549912786281e7f6fe64a7cf248d4b9e34b8b42f
MD5 7c0a4587c5fc190f3ef669725a5b170b
BLAKE2b-256 11271be9091b9d4eff981edcb2a9126b05ce0083596a9743e922c422f234dc89

See more details on using hashes here.

File details

Details for the file wasmtime-2.0.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for wasmtime-2.0.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2800e2e2c15c3f82fd1462a2651685330d7e0ef4d5e3d7072cc5b85a76aec18c
MD5 532836547cf2a6611f59fa7206678eca
BLAKE2b-256 3b2d07e3dc8c2659d4c072e3040e9372b9047743ae8f5d9e7c8c04840c6d7191

See more details on using hashes here.

File details

Details for the file wasmtime-2.0.0-py3-none-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for wasmtime-2.0.0-py3-none-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 d52ee9c07fa2234bfb916ea02a779d9719cf8e28b55f44f56589effa44ef20c8
MD5 1cf3bda04e6935c7e59be78ada78cea8
BLAKE2b-256 1741e903b67ef13f20e4d405bde36fb33859055c48a4d7a743ba36f3594234ce

See more details on using hashes here.

File details

Details for the file wasmtime-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: wasmtime-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for wasmtime-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 61148a89f3f8580d4b0dae354d5cc3ec5eda5c459b7c8d1a5e9d68897873c973
MD5 62895a688ee8625a5c73644c887bf0ad
BLAKE2b-256 055abab5052e31e9c2540a61edf9dce51fb0e8403fc09a1fe718884c030debee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page