zlayer-sdk 0.1.0__tar.gz
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_sdk-0.1.0/.gitignore +23 -0
- zlayer_sdk-0.1.0/PKG-INFO +107 -0
- zlayer_sdk-0.1.0/README.md +87 -0
- zlayer_sdk-0.1.0/examples/.gitkeep +0 -0
- zlayer_sdk-0.1.0/pyproject.toml +39 -0
- zlayer_sdk-0.1.0/zlayer/__init__.py +1563 -0
- zlayer_sdk-0.1.0/zlayer/py.typed +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# ---> Rust
|
|
2
|
+
# Generated by Cargo
|
|
3
|
+
# will have compiled files and executables
|
|
4
|
+
debug/
|
|
5
|
+
target/
|
|
6
|
+
|
|
7
|
+
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
|
8
|
+
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
|
9
|
+
Cargo.lock
|
|
10
|
+
|
|
11
|
+
# These are backup files generated by rustfmt
|
|
12
|
+
**/*.rs.bk
|
|
13
|
+
|
|
14
|
+
# MSVC Windows builds of rustc generate these, which store debugging information
|
|
15
|
+
*.pdb
|
|
16
|
+
|
|
17
|
+
# RustRover
|
|
18
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
19
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
20
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
21
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
22
|
+
#.idea/
|
|
23
|
+
.claude/settings.local.json
|
|
@@ -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,87 @@
|
|
|
1
|
+
# ZLayer Python SDK
|
|
2
|
+
|
|
3
|
+
Plugin Development Kit for building WASM plugins in Python targeting ZLayer.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Python 3.11+
|
|
8
|
+
- [componentize-py](https://github.com/bytecodealliance/componentize-py) for WASM compilation
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
# Using uv (recommended)
|
|
14
|
+
uv add zlayer-sdk
|
|
15
|
+
|
|
16
|
+
# Or with pip
|
|
17
|
+
pip install zlayer-sdk
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Development Setup
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Clone and install in development mode
|
|
24
|
+
cd clients/zlayer-sdk/python
|
|
25
|
+
uv sync --all-extras
|
|
26
|
+
|
|
27
|
+
# Install componentize-py for WASM compilation
|
|
28
|
+
uv add --dev componentize-py
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
### Basic Plugin Structure
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from zlayer import kv, log
|
|
37
|
+
|
|
38
|
+
def handle_request(request: bytes) -> bytes:
|
|
39
|
+
"""Plugin entry point called by ZLayer runtime."""
|
|
40
|
+
# Access key-value storage
|
|
41
|
+
value = kv.get("my-key")
|
|
42
|
+
|
|
43
|
+
# Log messages to host
|
|
44
|
+
log.info("Processing request")
|
|
45
|
+
|
|
46
|
+
# Return response
|
|
47
|
+
return b"OK"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Building WASM Component
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# Generate WIT bindings and compile to WASM
|
|
54
|
+
componentize-py -d ../../wit -w zlayer-plugin componentize my_plugin -o my_plugin.wasm
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Available Host Capabilities
|
|
58
|
+
|
|
59
|
+
The SDK provides access to ZLayer host functions:
|
|
60
|
+
|
|
61
|
+
- **kv** - Key-value storage operations
|
|
62
|
+
- **log** - Structured logging
|
|
63
|
+
- **http** - Outbound HTTP requests
|
|
64
|
+
- **config** - Plugin configuration access
|
|
65
|
+
|
|
66
|
+
## Project Structure
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
zlayer/
|
|
70
|
+
__init__.py # Package root with version
|
|
71
|
+
py.typed # PEP 561 type marker
|
|
72
|
+
examples/
|
|
73
|
+
.gitkeep # Example plugins (coming soon)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Type Checking
|
|
77
|
+
|
|
78
|
+
This package is fully typed and includes a `py.typed` marker for PEP 561 compliance.
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# Run type checks
|
|
82
|
+
uv run mypy zlayer/
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## License
|
|
86
|
+
|
|
87
|
+
MIT
|
|
File without changes
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "zlayer-sdk"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "ZLayer Plugin Development Kit for Python"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.11"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
keywords = ["wasm", "wasi", "plugin", "zlayer"]
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Development Status :: 3 - Alpha",
|
|
11
|
+
"Intended Audience :: Developers",
|
|
12
|
+
"License :: OSI Approved :: MIT License",
|
|
13
|
+
"Programming Language :: Python :: 3.11",
|
|
14
|
+
"Programming Language :: Python :: 3.12",
|
|
15
|
+
"Topic :: Software Development :: Libraries",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[project.optional-dependencies]
|
|
19
|
+
dev = [
|
|
20
|
+
"componentize-py>=0.13",
|
|
21
|
+
"mypy>=1.8",
|
|
22
|
+
"pytest>=8.0",
|
|
23
|
+
"ruff>=0.3",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[build-system]
|
|
27
|
+
requires = ["hatchling"]
|
|
28
|
+
build-backend = "hatchling.build"
|
|
29
|
+
|
|
30
|
+
[tool.hatch.build.targets.wheel]
|
|
31
|
+
packages = ["zlayer"]
|
|
32
|
+
|
|
33
|
+
[tool.ruff]
|
|
34
|
+
line-length = 100
|
|
35
|
+
target-version = "py311"
|
|
36
|
+
|
|
37
|
+
[tool.mypy]
|
|
38
|
+
python_version = "3.11"
|
|
39
|
+
strict = true
|