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.9+ on Windows, macOS, and Linux, for x86_64 and arm64 architectures.

Versioning

wasmtime-py follows the Wasmtime versioning scheme, with a new major version being released every month. As with Wasmtime itself, new major versions of wasmtime-py can contain changes that break code written against the previous major version.

Since every installed Python package needs to agree on a single version of wasmtime-py, to use the upper bound on the major version in the dependency requirement should be bumped reguarly, ideally as soon as a new wasmtime-py version is released. To automate this process it is possible to use the whitequark/track-pypi-dependency-version script. YoWASP/runtime is an example of a project that automatically publishes releases on PyPI once a new version of wasmtime-py is released if it passes the testsuite.

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.

Components

Components are also supported in wasmtime-py. For more information see the documentation of wasmtime.component. Using a component is similar to using core wasm modules, and for examples see the tests/component/ directory.

Contributing

See CONTRIBUTING.md.

Project details


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.

pgrayy_wasmtime-44.0.1-py3-none-macosx_11_0_arm64.whl (7.6 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

pgrayy_wasmtime-44.0.1-py3-none-macosx_10_13_x86_64.whl (8.7 MB view details)

Uploaded Python 3macOS 10.13+ x86-64

File details

Details for the file pgrayy_wasmtime-44.0.1-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pgrayy_wasmtime-44.0.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 55013c8f039d6488569ce63be40d8f22a8c3a7665bb7e22b2e4b0e15dd7195da
MD5 2d84e75428adfd68983ba3a74f728764
BLAKE2b-256 c8aaf69f0febaf076a9286b1b4d06230057649b94d5f1559f5e37b44788c65ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for pgrayy_wasmtime-44.0.1-py3-none-macosx_11_0_arm64.whl:

Publisher: publish-pypi.yml on pgrayy/wasm-deps

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pgrayy_wasmtime-44.0.1-py3-none-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for pgrayy_wasmtime-44.0.1-py3-none-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 a720675417d1df079d3c1fb9f5be8d132f409e61459ea2cea20b9d69d4d7912f
MD5 148e7812d97ff5c56d66a0f4ccb747ef
BLAKE2b-256 807f522af44c6a52e6acc047e67d812d9ea5c918d462955321a4c8047c3b24fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pgrayy_wasmtime-44.0.1-py3-none-macosx_10_13_x86_64.whl:

Publisher: publish-pypi.yml on pgrayy/wasm-deps

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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