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-0.28.0-py3-none-win_amd64.whl (3.8 MB view details)

Uploaded Python 3Windows x86-64

wasmtime-0.28.0-py3-none-manylinux1_x86_64.whl (5.6 MB view details)

Uploaded Python 3

wasmtime-0.28.0-py3-none-macosx_10_13_x86_64.whl (4.4 MB view details)

Uploaded Python 3macOS 10.13+ x86-64

wasmtime-0.28.0-py3-none-any.whl (8.9 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: wasmtime-0.28.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.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

File hashes

Hashes for wasmtime-0.28.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 9963c78fbd123fc1e9cc42b2399446a96180019499d5690795381a0e422544c1
MD5 083addb1f47e0bbeff79b92adfa4fad7
BLAKE2b-256 e5302d13da0d67f240c0984ef67c665c63ca13c8ffd9f16bd9b272eed04a021e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: wasmtime-0.28.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.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

File hashes

Hashes for wasmtime-0.28.0-py3-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 5adfc66b3c057a30f0bed2efa199d92081a213891fdf32f33a3d44fca07b650e
MD5 6f09cf50be77a6e36417e7d8a20b3695
BLAKE2b-256 315c81e36171ae595a614af14dca5b18bf397c5c2ef62c71b1d58d4850c35264

See more details on using hashes here.

File details

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

File metadata

  • Download URL: wasmtime-0.28.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.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

File hashes

Hashes for wasmtime-0.28.0-py3-none-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 a7bf4276da716503e06acff9205320489ba158d0f7add34856d7f08c465a5134
MD5 5f3ecfc3a12499cec0a48ec7e6e67613
BLAKE2b-256 e242bc2d2cc7d1e51a35a45cd39e43ea37088f7aa902771527b8a391844586a2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: wasmtime-0.28.0-py3-none-any.whl
  • Upload date:
  • Size: 8.9 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

File hashes

Hashes for wasmtime-0.28.0-py3-none-any.whl
Algorithm Hash digest
SHA256 77fc3e46c344a13264e412edd06d1ef7013d8373659557c90be443cd3a32cb7d
MD5 dc1a5e4ee8157b5ed6a53431a201d96e
BLAKE2b-256 7750d0aad0aaa40481cb2bc8593de300c6b5e131162fac78d0a70a4957222edd

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