Python bindings for the Wasmer sandbox SDK
Project description
Wasmer SDK for Python
The Python package is a typed, handwritten façade over the Rust
wasmer-sdk, exported through UniFFI. Package resolution, sandbox state,
commands, live processes, streams, files, and ports follow the same model as
the Rust and JavaScript SDKs. Constructing Wasmer() is synchronous; only
operations that perform I/O and deterministic shutdown are awaited.
from wasmer_sdk import Wasmer
client = Wasmer(cache_root=".wasmer")
python = await client.packages.load("python/python@3.12")
sandbox = await client.sandboxes.create(
packages=[python],
files={"main.py": "print('hello from WASIX')"},
)
output = await sandbox.command(
"python", ["/workspace/main.py"]
).run(check=True)
print(output.text())
For long-lived applications and tests, await client.close() or
async with Wasmer() as client provides deterministic cleanup.
Build the local native package and run the executable tests from the repository root:
python3 python/scripts/build.py --release
PYTHONPATH=python/src \
python3 -m unittest discover -s python/tests -v
The generated _native.py module and platform library are private
implementation details. Applications should only import from wasmer_sdk.
Examples
Run a Python package:
PYTHONPATH=python/src python3 python/examples/python_package.py
Serve HTTP with wasmer/edgejs-quickjs:
PYTHONPATH=python/src python3 python/examples/edgejs_http.py
Run wasmer/pglite under Wasmer, then query it with the standard native
psql client:
PYTHONPATH=python/src python3 python/examples/postgres_psql.py
The example accepts --psql /path/to/psql when the client is not on PATH.
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 Distribution
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.0.1-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: wasmer_sdk-0.0.1-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 12.3 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4324f896eac71b3c4010743289e14b826847a72cc924f14f6782b366e4736da5
|
|
| MD5 |
93d940efcf173daa2c2e835fc7e62f1f
|
|
| BLAKE2b-256 |
33d410447b1aa34e44f400dc7cbb57daa1a037ef782f78f924800233225e6931
|