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

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.0-py3-none-manylinux_2_34_x86_64.whl (14.0 MB view details)

Uploaded Python 3manylinux: glibc 2.34+ x86-64

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

Uploaded Python 3manylinux: glibc 2.34+ ARM64

wasmer_sdk-0.1.0-py3-none-macosx_11_0_arm64.whl (12.3 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

wasmer_sdk-0.1.0-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.0-py3-none-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for wasmer_sdk-0.1.0-py3-none-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 c17bf96ef83ff7d43c903a1dc747df4e4fc3f1435c949f1b902de11abc789def
MD5 4f8354707f5801857439d8c2f4e42784
BLAKE2b-256 c1a6b32fcd481dab14dabe7ae15955fcac0673076d1d7459f9f744d37cb63142

See more details on using hashes here.

Provenance

The following attestation bundles were made for wasmer_sdk-0.1.0-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.0-py3-none-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for wasmer_sdk-0.1.0-py3-none-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 bf51b969bf72e64d568c339a8b46a746e02a4a73d13678272afa90def5e4a63b
MD5 94dbe8a4749118a9887f98e7a676b1dd
BLAKE2b-256 7c5beca12b0e6c818dab41b79a9ac81be9f4f7469731c075667bc5da7910a44c

See more details on using hashes here.

Provenance

The following attestation bundles were made for wasmer_sdk-0.1.0-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.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for wasmer_sdk-0.1.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4a0634a65264d4b47ea06a6d1ad88b96089538568587e4484bf3a5903c2d5c42
MD5 32627007f8f571b34da2e5d5914b05af
BLAKE2b-256 750c96d3f9e9a2ead1467bd96ce3f83158b8af24db76aee51acadb49a87e4d4a

See more details on using hashes here.

Provenance

The following attestation bundles were made for wasmer_sdk-0.1.0-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.0-py3-none-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for wasmer_sdk-0.1.0-py3-none-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 3dec5e2914aafffe6336fa1747fc2384c0e707fc6358b9216485a56d3897e2a1
MD5 6f125e8ac031ae9b4e57aeade3a2474b
BLAKE2b-256 b2296241c640afc3ba462c28ae4c5c0592e73298ed3242cc79782d33f08f2af1

See more details on using hashes here.

Provenance

The following attestation bundles were made for wasmer_sdk-0.1.0-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