Python bindings for the Wasmer sandbox SDK
Project description
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.5"],
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())
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.5"],
)
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-quickjs@0.1.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.
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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wasmer_sdk-0.1.2-py3-none-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: wasmer_sdk-0.1.2-py3-none-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 14.1 MB
- Tags: Python 3, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69f9d41c605420c7d3cb0c075b189bcc40db5c2c038a11a03c267e9def7100a5
|
|
| MD5 |
d8eba5a42ff7d0d122773ef28adf26a5
|
|
| BLAKE2b-256 |
caddd74c29cb2223bf13f6ba041bdfbbe666846f8fec12ede0512e6d4337b663
|
Provenance
The following attestation bundles were made for wasmer_sdk-0.1.2-py3-none-manylinux_2_34_x86_64.whl:
Publisher:
release.yml on wasmerio/wasmer-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wasmer_sdk-0.1.2-py3-none-manylinux_2_34_x86_64.whl -
Subject digest:
69f9d41c605420c7d3cb0c075b189bcc40db5c2c038a11a03c267e9def7100a5 - Sigstore transparency entry: 2298297062
- Sigstore integration time:
-
Permalink:
wasmerio/wasmer-sdk@450c5b2a095dc5e40af4a982be0a63a02ed6b73c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/wasmerio
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@450c5b2a095dc5e40af4a982be0a63a02ed6b73c -
Trigger Event:
pull_request
-
Statement type:
File details
Details for the file wasmer_sdk-0.1.2-py3-none-manylinux_2_34_aarch64.whl.
File metadata
- Download URL: wasmer_sdk-0.1.2-py3-none-manylinux_2_34_aarch64.whl
- Upload date:
- Size: 13.5 MB
- Tags: Python 3, manylinux: glibc 2.34+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
736fb35455e126a30aabad4d80defe86768a74091a49be08b947d5c0ab962c3a
|
|
| MD5 |
325312435e94a0cc7fae82ba49c9f542
|
|
| BLAKE2b-256 |
123fa5e48b1d62ddccc6118c409d2a7586389c9e47e352578a96c1b3eed7d58c
|
Provenance
The following attestation bundles were made for wasmer_sdk-0.1.2-py3-none-manylinux_2_34_aarch64.whl:
Publisher:
release.yml on wasmerio/wasmer-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wasmer_sdk-0.1.2-py3-none-manylinux_2_34_aarch64.whl -
Subject digest:
736fb35455e126a30aabad4d80defe86768a74091a49be08b947d5c0ab962c3a - Sigstore transparency entry: 2298297113
- Sigstore integration time:
-
Permalink:
wasmerio/wasmer-sdk@450c5b2a095dc5e40af4a982be0a63a02ed6b73c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/wasmerio
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@450c5b2a095dc5e40af4a982be0a63a02ed6b73c -
Trigger Event:
pull_request
-
Statement type:
File details
Details for the file wasmer_sdk-0.1.2-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: wasmer_sdk-0.1.2-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 12.4 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71dd5529b36551e15563e20828382496c7a9aa0616eb92b4b6d80c5d00b03ebf
|
|
| MD5 |
3f9ebebe7b3d13b68e8286657474f7d6
|
|
| BLAKE2b-256 |
9a7429521c6f9379777f092440a8174f72785f46823f2e1f2811e0c4264e1624
|
Provenance
The following attestation bundles were made for wasmer_sdk-0.1.2-py3-none-macosx_11_0_arm64.whl:
Publisher:
release.yml on wasmerio/wasmer-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wasmer_sdk-0.1.2-py3-none-macosx_11_0_arm64.whl -
Subject digest:
71dd5529b36551e15563e20828382496c7a9aa0616eb92b4b6d80c5d00b03ebf - Sigstore transparency entry: 2298297088
- Sigstore integration time:
-
Permalink:
wasmerio/wasmer-sdk@450c5b2a095dc5e40af4a982be0a63a02ed6b73c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/wasmerio
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@450c5b2a095dc5e40af4a982be0a63a02ed6b73c -
Trigger Event:
pull_request
-
Statement type:
File details
Details for the file wasmer_sdk-0.1.2-py3-none-macosx_10_13_x86_64.whl.
File metadata
- Download URL: wasmer_sdk-0.1.2-py3-none-macosx_10_13_x86_64.whl
- Upload date:
- Size: 13.1 MB
- Tags: Python 3, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fda0d441e7e2df6e0873dd1e2cea06c0588d32ad3566da88fedfe86e136b6985
|
|
| MD5 |
edc63d459ce7aeb4d6045cd6b92fe543
|
|
| BLAKE2b-256 |
bf5008d068781ca84495902048269aa9d39eb544b8a013bb6563020c946804cc
|
Provenance
The following attestation bundles were made for wasmer_sdk-0.1.2-py3-none-macosx_10_13_x86_64.whl:
Publisher:
release.yml on wasmerio/wasmer-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wasmer_sdk-0.1.2-py3-none-macosx_10_13_x86_64.whl -
Subject digest:
fda0d441e7e2df6e0873dd1e2cea06c0588d32ad3566da88fedfe86e136b6985 - Sigstore transparency entry: 2298297043
- Sigstore integration time:
-
Permalink:
wasmerio/wasmer-sdk@450c5b2a095dc5e40af4a982be0a63a02ed6b73c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/wasmerio
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@450c5b2a095dc5e40af4a982be0a63a02ed6b73c -
Trigger Event:
pull_request
-
Statement type: