Skip to main content

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.spec and 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

  1. Define hooks - Specify what plugins can customize
  2. Implement hooks - Create plugins with implementations
  3. Register plugins - Load plugins into your application
  4. Call hooks - Trigger plugin execution

For detailed guides and API reference, see the full documentation.

Examples

See the examples directory for complete examples:

License

MIT

Project details


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)

Uploaded Source

Built Distribution

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

simplug-0.5.7-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

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

Hashes for simplug-0.5.7.tar.gz
Algorithm Hash digest
SHA256 316d0623858fefc893cfaa7ae21495f1d7dcf4607457aa220e6ac0302e4e7546
MD5 f60204c1c73f56830d56211afe7a7a4b
BLAKE2b-256 f1ba187201c2bdcd0658e629dae8af3339d89866b8fa09e31d1857f86f317d0f

See more details on using hashes here.

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

Hashes for simplug-0.5.7-py3-none-any.whl
Algorithm Hash digest
SHA256 e4987639d4c8f596bb541e6677a9762c7b259951b8787253ad336163a081b143
MD5 8854bdbf4ba9b2b71f26e5240316d48d
BLAKE2b-256 74c3babcea097dcc3684e96eef5d03e7558935aaae0dc28a8fd68aa86bc5ad09

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