Skip to main content

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. Published wheels support macOS and Linux on both arm64 and x86_64. They use a Python-independent UniFFI boundary, so one native wheel works across supported Python 3 versions on the same platform.

Examples

Run a Python package:

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

Run shell tools, Python, Edge.js, and PHP in one sandbox:

PYTHONPATH=python/src python3 python/examples/multiple_runtimes.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

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.

wasmer_sdk-0.1.1-py3-none-manylinux_2_34_x86_64.whl (14.1 MB view details)

Uploaded Python 3manylinux: glibc 2.34+ x86-64

wasmer_sdk-0.1.1-py3-none-manylinux_2_34_aarch64.whl (13.5 MB view details)

Uploaded Python 3manylinux: glibc 2.34+ ARM64

wasmer_sdk-0.1.1-py3-none-macosx_11_0_arm64.whl (12.4 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

wasmer_sdk-0.1.1-py3-none-macosx_10_13_x86_64.whl (13.1 MB view details)

Uploaded Python 3macOS 10.13+ x86-64

File details

Details for the file wasmer_sdk-0.1.1-py3-none-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for wasmer_sdk-0.1.1-py3-none-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 8f3a230c71d659f7c8215491f09bebdbc8c4233073a75ee375eb2c3c79a4d912
MD5 82d20b439ceed61c6324fa603370a203
BLAKE2b-256 2a2a273f3271d249f7ced7675735f3797764c3fed7c8c6596458becddd6edc7c

See more details on using hashes here.

Provenance

The following attestation bundles were made for wasmer_sdk-0.1.1-py3-none-manylinux_2_34_x86_64.whl:

Publisher: release.yml on wasmerio/wasmer-sdk

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

File details

Details for the file wasmer_sdk-0.1.1-py3-none-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for wasmer_sdk-0.1.1-py3-none-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 4516e09be00085ac9bf9ba2859863e55df8e3309e8740e7784a910588974a1ef
MD5 24c36d68c2517fe6bc5d0e4805942ce8
BLAKE2b-256 0d2e73d1eeb39f710e946b874c0674a34c9d88d7e723f9e69cd71ccc9998d856

See more details on using hashes here.

Provenance

The following attestation bundles were made for wasmer_sdk-0.1.1-py3-none-manylinux_2_34_aarch64.whl:

Publisher: release.yml on wasmerio/wasmer-sdk

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

File details

Details for the file wasmer_sdk-0.1.1-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for wasmer_sdk-0.1.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e0291667c583c6c2844c3f34709f9259e96f267b25f4689f28383fadee6f9f98
MD5 4a9e5443b09c02a7178ec1b1deeadf55
BLAKE2b-256 2dabd67bd9249144be71cd9010428e8e891c54b04c12ebcba00643dc4b7fb8eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for wasmer_sdk-0.1.1-py3-none-macosx_11_0_arm64.whl:

Publisher: release.yml on wasmerio/wasmer-sdk

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

File details

Details for the file wasmer_sdk-0.1.1-py3-none-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for wasmer_sdk-0.1.1-py3-none-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 8d85a833c9ada371c423c429466add2d224e88fb2ca03e8f06b4e1f5bfb21ec6
MD5 4175bf29da1c68f2f64d5bbe66d9f90d
BLAKE2b-256 1c0a457962d48885038691ab23af1afad8051c83e43cfb4fe9263e52c3b7f7cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for wasmer_sdk-0.1.1-py3-none-macosx_10_13_x86_64.whl:

Publisher: release.yml on wasmerio/wasmer-sdk

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