Skip to main content

Wasmer SDK for Python

Run Wasmer packages in lightweight, composable sandboxes from Python. The public API is handwritten and typed; a Python-independent UniFFI library calls the Rust wasmer-sdk underneath.

Install

pip install wasmer-sdk

Published wheels support macOS and Linux on arm64 and x86_64. One wheel works across supported Python 3 versions on the same platform because the native boundary does not use the CPython ABI.

Run Python inside Wasmer

import asyncio

from wasmer_sdk import Wasmer


async def main() -> None:
    wasmer = Wasmer()
    sandbox = await wasmer.sandboxes.create(
        packages=["python/python@=3.13.18"],
        files={
            "main.py": "print(sum(n * n for n in range(10)))",
        },
    )
    output = await sandbox.command(
        "python", ["/workspace/main.py"]
    ).run()
    print(output.text())


asyncio.run(main())

The @= package-version syntax is an exact pin. Use it when a sandbox must resolve the same Wasmer package version on every run.

Constructing Wasmer() is synchronous. Operations that perform I/O are awaited. A wasmer instance can be reused across multiple sandboxes. For long-lived applications and tests, use async with for deterministic cleanup:

async def main() -> None:
    async with Wasmer() as wasmer:
        sandbox = await wasmer.sandboxes.create(
            packages=["python/python@=3.13.18"],
        )
        async with sandbox:
            output = await sandbox.command(
                "python", ["--version"]
            ).run()
            print(output.text())


asyncio.run(main())

run() raises ProcessExitError for a non-zero exit, termination, or timeout by default. Pass check=False when the outcome is expected and should be inspected as an Output. Spawned-process wait() remains unchecked by default.

Live processes expose asynchronous stdin, stdout, and stderr streams. process.stdout.lines() is an async iterator suitable for servers and agent loops.

Networking and caching

Network access is an explicit sandbox capability:

sandbox = await wasmer.sandboxes.create(
    packages=["wasmer/edgejs@0.2.0"],
    network="host",
)

Packages and native compiled artifacts are cached in .wasmer by default:

wasmer = Wasmer(cache_root=".cache/wasmer")

The registry and downloaded package layout is shared with Node.js and Rust. Compiled artifacts remain target-specific.

Examples

Run the same guest programs used by the JavaScript and Rust SDK examples:

python3 python/examples/python.py
python3 python/examples/multiple_runtimes.py
python3 python/examples/edgejs_http.py
python3 python/examples/postgres_psql.py

The PostgreSQL example requires psql on PATH; pass --psql /path/to/psql otherwise. The common guest inputs live in ../fixtures/.

Build and test locally

From the repository root, install Rust 1.94 and build the UniFFI module:

rustup toolchain install 1.94.0 --profile minimal
python3 python/scripts/build.py --release

Run the Python suite against that local module:

PYTHONPATH=python/src \
  python3 -m unittest discover -s python/tests -v

Run an individual example against the local build:

PYTHONPATH=python/src python3 python/examples/python.py

The PostgreSQL tests require native psql. Set PSQL=/path/to/psql when it is not on PATH.

The generated _native.py module and platform library are private implementation details. Applications should import only from wasmer_sdk.

Release files for wasmer-sdk 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for wasmer-sdk 0.2.0
File
wasmer_sdk-0.2.0-py3-none-manylinux_2_35_x86_64.whl Python 3 none Linux glibc 2.35+ x86-64 Details
wasmer_sdk-0.2.0-py3-none-manylinux_2_35_aarch64.whl Python 3 none Linux glibc 2.35+ ARM64 Details
wasmer_sdk-0.2.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details
wasmer_sdk-0.2.0-py3-none-macosx_10_13_x86_64.whl Python 3 none macOS 10.13+ x86-64 Details

Total release size: 129.7 MB

Release files / wasmer_sdk-0.2.0-py3-none-manylinux_2_35_x86_64.whl

Download URL wasmer_sdk-0.2.0-py3-none-manylinux_2_35_x86_64.whl
Size 34.6 MB
Tags Linux glibc 2.35+ x86-64 Python 3
SHA-256 checksum
How to use checksums
89bd6ce6668fca556e8e1041e27d452086532f7e65dbdcae7e75abb07c835ada
BLAKE2b-256 checksum
How to use checksums
f9011a77878d64cc43fe47e5e912b84a8d0adc92904cf5fd5fa1b0c043b0c5a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.

Transparency log

Release files / wasmer_sdk-0.2.0-py3-none-manylinux_2_35_aarch64.whl

Download URL wasmer_sdk-0.2.0-py3-none-manylinux_2_35_aarch64.whl
Size 33.7 MB
Tags Linux glibc 2.35+ ARM64 Python 3
SHA-256 checksum
How to use checksums
3d413918b9eacc319a6f79a2bd7e23fd1d830dbec622acbb0b0a6753cf729b71
BLAKE2b-256 checksum
How to use checksums
2b4db2f7143ca9ec43bbfc9dfaf04b90c76974317e371f5de6b0d1a94d17b624
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.

Transparency log

Release files / wasmer_sdk-0.2.0-py3-none-macosx_11_0_arm64.whl

Download URL wasmer_sdk-0.2.0-py3-none-macosx_11_0_arm64.whl
Size 29.9 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f1c1590ab709a385c43b8458f101d592c1c9ef26fb6d000563505f672ef25fbf
BLAKE2b-256 checksum
How to use checksums
5de6c1faf82bc891b91471d33e1d5cd6d12a240ba61d6074c23c6b5275c983a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.

Transparency log

Release files / wasmer_sdk-0.2.0-py3-none-macosx_10_13_x86_64.whl

Download URL wasmer_sdk-0.2.0-py3-none-macosx_10_13_x86_64.whl
Size 31.5 MB
Tags Python 3 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
d6290def38db543482b53df52863d0d517093f06f45fd2eb3566abe419f6a5c0
BLAKE2b-256 checksum
How to use checksums
44991726b385e28d2c2d1026e7c784a9d4d280db489d6a562485d06859f7ee00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.

Transparency log

Release history Release notifications | RSS feed

0.5.0

4 release files

0.4.0

4 release files

0.3.0

4 release files

0.2.1

4 release files

This release

0.2.0 This release

4 release files

0.1.2

4 release files

0.1.1

4 release files

0.1.0

4 release files

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page