Skip to main content

A Python runtime for Binmod WebAssembly modules

Project description

Binmod Runtime Python

Python runtime for executing Binmod WebAssembly modules.

Quick Start

Installation

pip install binmod

Basic Usage

from binmod import Module, ModuleEnv

# Load a binmod module
mod = Module.from_file(
    "my_module.wasm",
    name="my_module",
    environment=ModuleEnv.inherit(),
    namespace="test",
    host_fns={
        "host_log": lambda msg: print(f"Host log: {msg}"),
        "host_add": lambda a, b: a + b,
    }
)
mod.instantiate()

# Call a function from the module. Note: All parameters and outputs must be
# serializable to JSON.
result = mod.api.greet("Alice", 5)
print(result)  # Output: Hello, Alice you are 5 years old!

# Or use the async API
result = await mod.api_async.greet("Bob", 10)
print(result)  # Output: Hello, Bob you are 10 years old!

Note: The WebAssembly module must be compiled with the WASI Preview 1 target.

License

This project is licensed under MIT License.

Support & Feedback

If you encounter any issues or have feedback, please open an issue.

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 Distribution

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

binmod-0.1.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file binmod-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: binmod-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for binmod-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 31839e5687f92206e5020304b5c88d68534ebc0d874ae97806f7168f28ad21f1
MD5 e10a9d91e0a8c37063e9e92921036172
BLAKE2b-256 7133f03ce6fbc1d45931ccc8337c070a8698c41fc9212c3b3e0a4c4ca5d82c48

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