Skip to main content

pluginkit

PyPI Python CI Docs License: MIT

A small, strictly-typed, generics-first plugin framework for Python 3.13+. Declare extension points, let plugins implement them, discover plugins via entry points - and, unlike untyped hook systems, get the right return type for every call, derived from the spec and checked by your type checker.

pm.caller(spec) hands back a caller whose result type matches the dispatch mode - list[R] for collecting, R | None for firstresult, R for pipeline - with no hand-annotations and no drift. Zero runtime dependencies, a py.typed marker, and a few readable files.

uv add pluginkit   # or: pip install pluginkit
from pluginkit import Extension, ExtensionPoint, PluginManager

extension_point = ExtensionPoint("greeter")
extension = Extension("greeter")


class Specs:
    @staticmethod
    @extension_point
    def greeting(name: str) -> str:
        """Return a greeting for the given name."""


class Casual:
    @extension
    def greeting(self, name: str) -> str:
        return f"hey {name}!"


pm = PluginManager("greeter")
pm.add_extension_points(Specs)
pm.register(Casual(), name="casual")

greetings = pm.caller(Specs.greeting)(name="Ada")  # typed list[str] - derived, not asserted
print(greetings)  # ['hey Ada!']

What it supports

  • collecting, firstresult, and pipeline (fold/middleware) hooks;
  • call ordering with tryfirst / trylast, plus optional and target;
  • generator wrappers that decorate results and observe exceptions safely;
  • historic hooks replayed to plugins registered later;
  • async dispatch via AsyncPluginManager (awaits coroutine impls);
  • plugin lifecycle: register, unregister (by name or object), set_blocked, lookup, call_extra;
  • registration-time validation and call-time argument checking (failures are loud);
  • external plugin discovery via the stdlib importlib.metadata (no setuptools);
  • thread-safe registry mutation.

Layout

src/pluginkit/             the library (pure - no demo code)
examples/                  everything that uses the library (not shipped):
  cookbook/                  worked examples: bite-size scripts + full apps
  tour/                      pluginkit-tour: a guided CLI walkthrough
  external-plugin/           a separate distribution discovered via entry points
docs/                      mkdocs + Material documentation
tests/                     library, tour, and cookbook tests

Everything that demonstrates the library lives under examples/. The cookbook holds standalone examples (from one-mechanism snippets to complete FastAPI/Click/pytest apps); the tour is a guided walkthrough on one host; the external-plugin shows cross-package discovery via entry points.

Use it

make install              # uv sync (library + tour + external plugin)
make test                 # pytest (framework, tour, examples)
make lint                 # ruff + mypy + pyright
make docs-serve           # serve the docs at http://127.0.0.1:8000
make docs-build           # build the docs (strict)

Two ways to learn it

The tour (examples/tour/) walks through one mechanism at a time on a single host:

make run                  # run every step
make run DEMO=wrapper      # run one
uv run pluginkit-tour list

The cookbook applies the library to realistic domains and frameworks - see examples/cookbook/:

uv run python examples/cookbook/report_builder.py
uv run python examples/cookbook/fastapi_app.py
uv run python examples/cookbook/cli_app.py --help
uv run python examples/cookbook/app_lifecycle.py

Documentation

Full docs (concepts, one page per mechanism, production/hardening notes, and a generated API reference) live under docs/. Serve them with make docs-serve.

Is it production ready?

It is solid - exception-safe wrappers, fail-fast validation, lifecycle management, resilient discovery, thread-safe mutation, strict typing, and a test suite. But for anything you ship, prefer pluggy itself: it is maintained and battle tested by pytest, tox, and datasette. See docs/production/vs-pluggy.md for the honest inventory of what differs.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pluginkit-0.4.9.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

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

pluginkit-0.4.9-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

Details for the file pluginkit-0.4.9.tar.gz.

File metadata

  • Download URL: pluginkit-0.4.9.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pluginkit-0.4.9.tar.gz
Algorithm Hash digest
SHA256 04d66264f5df59d5555b301f15e6cd5c3e0c8bf95dd0ca1a743fb0e8cd841104
MD5 46dc8c2b356ded7cc6296e7a6361fdf5
BLAKE2b-256 8097ec47a51b58d69b93ad6cd1dc97100fe418f1f028d848f2ba3957d6a1da3d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pluginkit-0.4.9.tar.gz:

Publisher: release.yml on winterop-com/pluginkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pluginkit-0.4.9-py3-none-any.whl.

File metadata

  • Download URL: pluginkit-0.4.9-py3-none-any.whl
  • Upload date:
  • Size: 18.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pluginkit-0.4.9-py3-none-any.whl
Algorithm Hash digest
SHA256 fbe2252f0643e6fdce298c23047d1626f0426349829b1e7613e763bc57db67c3
MD5 4fdadc293e3169bd5a2f0b799b1bda7f
BLAKE2b-256 c2565399524ce5f92a5bd41b6592db4ea261b5f389d622f7d31f055f3d6de10f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pluginkit-0.4.9-py3-none-any.whl:

Publisher: release.yml on winterop-com/pluginkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.5.1

2 files

0.5.0

2 files

This release

0.4.9 This release

2 files

0.4.8

2 files

0.4.7

2 files

0.4.6

2 files

0.4.5

2 files

0.4.4

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page