Skip to main content

ZLayer Plugin Development Kit for Python

Project description

ZLayer Python SDK

Plugin Development Kit for building WASM plugins in Python targeting ZLayer.

Requirements

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.13.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zlayer_sdk-0.13.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file zlayer_sdk-0.13.0.tar.gz.

File metadata

  • Download URL: zlayer_sdk-0.13.0.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for zlayer_sdk-0.13.0.tar.gz
Algorithm Hash digest
SHA256 a5560326874fc058c3dc474bd6b4ae18e2c17e4b547e08c6aee8c8b884c41264
MD5 8f14b8480b83f165c0442882b8f51087
BLAKE2b-256 b83dc3206f500ba4a9af97cbc69bb4183f097dc0d9843643947eb84dca2af036

See more details on using hashes here.

File details

Details for the file zlayer_sdk-0.13.0-py3-none-any.whl.

File metadata

  • Download URL: zlayer_sdk-0.13.0-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.13

File hashes

Hashes for zlayer_sdk-0.13.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c1db3bd950f82e1ed3ca12ccd4be7a3591c5902479abce9bd28801a18dd69f1e
MD5 a5c6e568ccd0d8f67438845f909502a7
BLAKE2b-256 f2e09de5b0b199a1501ef8b985b52cda505310078ed20319203447d9baf9d90f

See more details on using hashes here.

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