pluxeo¶
pluxeo is a plugin framework for Python applications. A host application declares what plugins can do; plugins ship as ordinary installed packages; pluxeo finds them, loads them, calls them, and lets the host decide which ones run.
Pre-release
pluxeo has not had its first release yet. The API described here is implemented and tested, but it can still change before 0.1.
from pluxeo import Plugin, PluginManager, hookimpl, hookspec
class Spec:
@hookspec
def render_block(self, block: dict) -> str | None: ...
class Charts(Plugin):
namespace = "acme.renderers"
name = "charts"
@hookimpl
def render_block(self, block):
if block["type"] == "chart":
return f"<figure data-chart='{block['spec']}'></figure>"
return None
pm = PluginManager("acme.renderers", hookspec=Spec)
pm.register(Charts) # or ship it as an entry point, and skip this line
pm.load_all()
print(pm.hook.render_block(block={"type": "chart", "spec": "x"}))
# ["<figure data-chart='x'></figure>"]
Four jobs, one library¶
-
Discover
Plugins are installed packages declaring an entry point. Discovery reads package metadata and imports no plugin code until a plugin is loaded.
-
Load
A defined lifecycle: gates, declared dependencies, cleanup on unload, and failures contained to the plugin that caused them.
-
Dispatch
Typed hooks called on every active plugin, sync or async, with Pluggy's result modes and ordering.
-
Gate
typing.Protocolcontracts checked when a plugin loads, and host-controlled enable/disable that takes effect immediately.
Where to go next¶
- New here? Quick Start builds a host and a plugin in five minutes.
- Writing a plugin for an existing host? Plugin Classes and Functions and Distributing a Plugin.
- Building a host? Hooks, then the other guides under Building a Host.
- Already using Pluggy? Pluggy vs. pluxeo says what changes and when Pluggy alone is enough.
- Looking something up? The Python API reference.