python sdk for byk plugin
Project description
byksdk
Python SDK for building byk plugins — zero dependencies at the top level.
Features
- Zero dependencies — all top-level imports use only the Python standard library. Third-party dependencies are guarded by
@requiresdecorators and loaded on demand. - Plugin context —
plugin()gives you persistence, logging, and directory management in one call. - Built-in tools — network utilities, CLI output helpers, and web application assistants.
Installation
pip install byksdk
Quick Start
from byksdk import plugin
ctx = plugin("my_plugin")
ctx.logger.info("plugin started")
ctx.state().set("initialized", True)
Directory Layout
~/.byk/
├── plugins/ # plugin sandbox
│ └── my_plugin/
│ ├── state.json # ctx.state()
│ └── my_plugin.log # ctx.logger
├── state/ # global persistence
│ └── plugins.state.json # ctx.app.store()
├── logs/
│ └── plugins.log # ctx.app.logger
├── runtime/
└── cache/
Core APIs
Plugin Context
from byksdk import plugin
ctx = plugin("server")
# plugin-scoped persistence
ctx.state().set("port", 8080)
ctx.state("config").set("timeout", 30)
# plugin-scoped logging
ctx.logger.info("server started")
# global persistence (shared across plugins)
ctx.app.store().set("theme", "dark")
# global logging
ctx.app.logger.info("app started")
StateStore — JSON-based persistence
store = ctx.state()
store.set("key", "value")
store.get("key") # "value"
store.get("missing", default) # default
store.update({"a": 1, "b": 2})
store.delete("key")
store.clear()
store.load() # returns the full dict
Network
from byksdk import get_private_networks
networks = get_private_networks()
# [{ "iface": "eth0", "ips": ["192.168.1.100"], "type": "ethernet", ... }]
CLI Helpers
from byksdk import check_port, colored_key_value
if not check_port(8080):
return
click.echo(colored_key_value("URL", "http://localhost:8080"))
Web — SPA + unified response
from byksdk import create_spa, R
app = create_spa("dist")
@app.route("/api/hello")
def hello():
return R.ok({"message": "Hello"})
Dependency Model
byksdk follows "who uses it declares it":
- Top-level modules use only the Python standard library.
- Functions requiring third-party packages use
@requiresdecorators that raise a clearImportErrorwhen the dependency is missing.
| If you use... | declare in pyproject.toml |
|---|---|
create_spa / R / get_client_ip |
flask>=2.0 |
copy_to_clipboard |
pyperclip>=1.9.0 |
get_private_networks |
psutil>=5.9.0 |
check_port / colored_key_value |
click>=8.0.0 |
| all other APIs | nothing extra needed |
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
byksdk-0.1.0.tar.gz
(15.9 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
byksdk-0.1.0-py3-none-any.whl
(12.5 kB
view details)
File details
Details for the file byksdk-0.1.0.tar.gz.
File metadata
- Download URL: byksdk-0.1.0.tar.gz
- Upload date:
- Size: 15.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b314ddacfaa7785aede852adb91acbc1dc4f4891e0b97bab62c1ff8e725c1743
|
|
| MD5 |
1393bd179355e3d81c78c52ac0a4d848
|
|
| BLAKE2b-256 |
a1f0dd35b8cbc97d1fb6b07ab92c6d0947c9066473f0215b71322ff8c6058d95
|
File details
Details for the file byksdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: byksdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2278d143404af06cf8a5cb9a91175fcf8f1dfb60394c357ce19231c71fbb5f3d
|
|
| MD5 |
47bc232b4ee0e4251720cebb502a1dda
|
|
| BLAKE2b-256 |
bdf5ae425e936342ce2f52d945f0f01c5fafeaade1633f0ff6611ac9fcad616b
|