zlayer-sdk 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- zlayer/__init__.py +1563 -0
- zlayer/py.typed +0 -0
- zlayer_sdk-0.1.0.dist-info/METADATA +107 -0
- zlayer_sdk-0.1.0.dist-info/RECORD +5 -0
- zlayer_sdk-0.1.0.dist-info/WHEEL +4 -0
zlayer/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: zlayer-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: ZLayer Plugin Development Kit for Python
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Keywords: plugin,wasi,wasm,zlayer
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
13
|
+
Requires-Python: >=3.11
|
|
14
|
+
Provides-Extra: dev
|
|
15
|
+
Requires-Dist: componentize-py>=0.13; extra == 'dev'
|
|
16
|
+
Requires-Dist: mypy>=1.8; extra == 'dev'
|
|
17
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
18
|
+
Requires-Dist: ruff>=0.3; extra == 'dev'
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# ZLayer Python SDK
|
|
22
|
+
|
|
23
|
+
Plugin Development Kit for building WASM plugins in Python targeting ZLayer.
|
|
24
|
+
|
|
25
|
+
## Requirements
|
|
26
|
+
|
|
27
|
+
- Python 3.11+
|
|
28
|
+
- [componentize-py](https://github.com/bytecodealliance/componentize-py) for WASM compilation
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Using uv (recommended)
|
|
34
|
+
uv add zlayer-sdk
|
|
35
|
+
|
|
36
|
+
# Or with pip
|
|
37
|
+
pip install zlayer-sdk
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Development Setup
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Clone and install in development mode
|
|
44
|
+
cd clients/zlayer-sdk/python
|
|
45
|
+
uv sync --all-extras
|
|
46
|
+
|
|
47
|
+
# Install componentize-py for WASM compilation
|
|
48
|
+
uv add --dev componentize-py
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Usage
|
|
52
|
+
|
|
53
|
+
### Basic Plugin Structure
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from zlayer import kv, log
|
|
57
|
+
|
|
58
|
+
def handle_request(request: bytes) -> bytes:
|
|
59
|
+
"""Plugin entry point called by ZLayer runtime."""
|
|
60
|
+
# Access key-value storage
|
|
61
|
+
value = kv.get("my-key")
|
|
62
|
+
|
|
63
|
+
# Log messages to host
|
|
64
|
+
log.info("Processing request")
|
|
65
|
+
|
|
66
|
+
# Return response
|
|
67
|
+
return b"OK"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Building WASM Component
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Generate WIT bindings and compile to WASM
|
|
74
|
+
componentize-py -d ../../wit -w zlayer-plugin componentize my_plugin -o my_plugin.wasm
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Available Host Capabilities
|
|
78
|
+
|
|
79
|
+
The SDK provides access to ZLayer host functions:
|
|
80
|
+
|
|
81
|
+
- **kv** - Key-value storage operations
|
|
82
|
+
- **log** - Structured logging
|
|
83
|
+
- **http** - Outbound HTTP requests
|
|
84
|
+
- **config** - Plugin configuration access
|
|
85
|
+
|
|
86
|
+
## Project Structure
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
zlayer/
|
|
90
|
+
__init__.py # Package root with version
|
|
91
|
+
py.typed # PEP 561 type marker
|
|
92
|
+
examples/
|
|
93
|
+
.gitkeep # Example plugins (coming soon)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Type Checking
|
|
97
|
+
|
|
98
|
+
This package is fully typed and includes a `py.typed` marker for PEP 561 compliance.
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Run type checks
|
|
102
|
+
uv run mypy zlayer/
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## License
|
|
106
|
+
|
|
107
|
+
MIT
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
zlayer/__init__.py,sha256=NHi6jek_VHLfiCQNC5hFtxI3kh_ept7F4ZmCSdedjpc,42456
|
|
2
|
+
zlayer/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
zlayer_sdk-0.1.0.dist-info/METADATA,sha256=EOJs9MMfE_BXMRE0r7FZ0mPoTn2E-DnzG23r6LHkw5w,2371
|
|
4
|
+
zlayer_sdk-0.1.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
5
|
+
zlayer_sdk-0.1.0.dist-info/RECORD,,
|