A simple plugin system for python with async hooks supported
Project description
simplug
A simple plugin system for Python with async hooks support.
Features
- Decorator-based API: Define hooks with
@simplug.specand implement with@simplug.impl - Async support: First-class async hooks with sync/async bridging
- Flexible result collection: 18 built-in strategies for collecting plugin results
- Priority system: Control plugin execution order
- Setuptools entrypoints: Load plugins from installed packages
- Singleton per project: Same instance returned for same project name
Installation
pip install -U simplug
Quick Start
from simplug import Simplug
# Create a plugin manager
simplug = Simplug('myproject')
# Define a hook specification
class MySpec:
@simplug.spec
def process_data(self, data):
"""Process data in plugins."""
# Implement the hook in plugins
class PluginA:
@simplug.impl
def process_data(self, data):
return data.upper()
class PluginB:
@simplug.impl
def process_data(self, data):
return data.lower()
# Register plugins
simplug.register(PluginA, PluginB)
# Call the hook
results = simplug.hooks.process_data("Hello")
print(results) # ['HELLO', 'hello']
Documentation
Full documentation is available at https://pwwang.github.io/simplug/
Getting Started
- Define hooks - Specify what plugins can customize
- Implement hooks - Create plugins with implementations
- Register plugins - Load plugins into your application
- Call hooks - Trigger plugin execution
For detailed guides and API reference, see the full documentation.
Examples
See the examples directory for complete examples:
examples/toy.py- A minimal 30-line demoexamples/complete/- Full example with setuptools entrypoints
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
simplug-0.5.7.tar.gz
(18.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
simplug-0.5.7-py3-none-any.whl
(12.2 kB
view details)
File details
Details for the file simplug-0.5.7.tar.gz.
File metadata
- Download URL: simplug-0.5.7.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
316d0623858fefc893cfaa7ae21495f1d7dcf4607457aa220e6ac0302e4e7546
|
|
| MD5 |
f60204c1c73f56830d56211afe7a7a4b
|
|
| BLAKE2b-256 |
f1ba187201c2bdcd0658e629dae8af3339d89866b8fa09e31d1857f86f317d0f
|
File details
Details for the file simplug-0.5.7-py3-none-any.whl.
File metadata
- Download URL: simplug-0.5.7-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4987639d4c8f596bb541e6677a9762c7b259951b8787253ad336163a081b143
|
|
| MD5 |
8854bdbf4ba9b2b71f26e5240316d48d
|
|
| BLAKE2b-256 |
74c3babcea097dcc3684e96eef5d03e7558935aaae0dc28a8fd68aa86bc5ad09
|