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["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

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

wasmtime-0.27.0-py3-none-win_amd64.whl (3.8 MB view details)

Uploaded Python 3Windows x86-64

wasmtime-0.27.0-py3-none-manylinux1_x86_64.whl (5.7 MB view details)

Uploaded Python 3

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

Uploaded Python 3macOS 10.13+ x86-64

wasmtime-0.27.0-py3-none-any.whl (9.0 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: wasmtime-0.27.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.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for wasmtime-0.27.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 8b783a2569e068ba87e6d8a5204fa3118cc84778ce250a444757e4b8c7ae2e53
MD5 319e3e7b8d8bee8d40abaf12cf3bfc5b
BLAKE2b-256 4b9fd62402357de1b770e5a3690e9486f4b0afebd6770bcfde2259d0a2bc4ff7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: wasmtime-0.27.0-py3-none-manylinux1_x86_64.whl
  • Upload date:
  • Size: 5.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for wasmtime-0.27.0-py3-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 945b9a874b38fc3e69a2efce0c8e2af7059e305f288a4ce1c0978d993ddf9d79
MD5 460043e6eac88ca50f8a2aa83f70121f
BLAKE2b-256 f4cafcf17aadcb1e108bd6f40d412313c1c255a6af4a8f703568e22a2dd978bd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: wasmtime-0.27.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.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for wasmtime-0.27.0-py3-none-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 242100c859e65af1563ffe11c749c2ead5b970d7878acd0ae095a3cdb69c95da
MD5 703f9231e104f13ffc702fa4b09f68ed
BLAKE2b-256 f222c4defff2bd9b6340bb284279685175bfd6efe17f29729621bbd62418f434

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for wasmtime-0.27.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d0d20786385b2a4f1435b6b0480ac534cfadd8fd93908bb5001619c9623ef31
MD5 134a90f900e16d9777d2697478b13cbc
BLAKE2b-256 b994dcd3c5f8d81f2e32fde03e416080bbe07033816a1b418851086a1417ebd2

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