ZLayer Plugin Development Kit for Python
Project description
ZLayer Python SDK
Plugin Development Kit for building WASM plugins in Python targeting ZLayer.
Requirements
- Python 3.11+
- componentize-py for WASM compilation
Installation
# Using uv (recommended)
uv add zlayer-sdk
# Or with pip
pip install zlayer-sdk
Development Setup
# Clone and install in development mode
cd clients/zlayer-sdk/python
uv sync --all-extras
# Install componentize-py for WASM compilation
uv add --dev componentize-py
Usage
Basic Plugin Structure
from zlayer import kv, log
def handle_request(request: bytes) -> bytes:
"""Plugin entry point called by ZLayer runtime."""
# Access key-value storage
value = kv.get("my-key")
# Log messages to host
log.info("Processing request")
# Return response
return b"OK"
Building WASM Component
# Generate WIT bindings and compile to WASM
componentize-py -d ../../wit -w zlayer-plugin componentize my_plugin -o my_plugin.wasm
Available Host Capabilities
The SDK provides access to ZLayer host functions:
- kv - Key-value storage operations
- log - Structured logging
- http - Outbound HTTP requests
- config - Plugin configuration access
Project Structure
zlayer/
__init__.py # Package root with version
py.typed # PEP 561 type marker
examples/
.gitkeep # Example plugins (coming soon)
Type Checking
This package is fully typed and includes a py.typed marker for PEP 561 compliance.
# Run type checks
uv run mypy zlayer/
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
zlayer_sdk-0.9.981.tar.gz
(11.1 kB
view details)
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 zlayer_sdk-0.9.981.tar.gz.
File metadata
- Download URL: zlayer_sdk-0.9.981.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7193b1f96f6cd763c66f614c366090c6e400f1690b5018e9315b550efad88b6
|
|
| MD5 |
cc736998c591518d8d6de420d275720e
|
|
| BLAKE2b-256 |
3a59df2d2254b81c728aa8653a19b4a18bfac72a43d8009c8e12d0658a2e8c48
|
File details
Details for the file zlayer_sdk-0.9.981-py3-none-any.whl.
File metadata
- Download URL: zlayer_sdk-0.9.981-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2114862089d37148a1e5a2cf03762c29fc76bad57c3644ef76240ddc9edef95
|
|
| MD5 |
a8eab8199eeb6117059f1826aa4e7cc5
|
|
| BLAKE2b-256 |
85d67bbd4503d6f5a840e5634ccd45864e213f6b95c64be04c4beb6463f80e35
|