pyplugin

Plugin Framework Library for Python


Keywords
plugin, plugin-manager, pyplugin
License
MIT-feh
Install
pip install pyplugin==0.4.1

Documentation

pyplugin

Pytest Status codecov License: MIT Documentation Status Pylint Status Code style: black

Pyplugin is a plugin framework library, supporting declarative-style plugin writing, allowing modular, swappable functionality in any codebase.

See Getting Started for more.

Version Name Latest Tag Release Notes Patch Notes Documentation Release Date End Support Date
0.4 v0.4.1 Release Notes Patch Notes Documentation 23 Oct 2023

Changelog v0.4

Features

  • Added new setting register_mode which can be used to configure how plugins get registered upon initialization.
  • Added set_flag function that will set a particular setting globally.
  • Added unset_flag function to reset a setting to default.
  • Added with_flag context manager to temporarily set a setting.

Fixes

  • Fixes dynamic requirements being registered in other parts of the load function (e.g. when loading a dependency).
  • Fixes groups reloading entirely when loading individual elements.
  • Fixes copying of requirements when copying a Plugin.

Contributing

Want a new feature, found a bug, or have questions? Feel free to add to our issue board on Github: Open Issues

We welcome any developer who enjoys the package enough to contribute. If you want to be added as a contributor and check out the Developer's Guide.

Introduction

Plugins are arbitrary callables. They can declare other plugins as requirements while operating under certain guarantees:

  • A plugin can be loaded (i.e. called) exactly once until it is unloaded.
  • A plugin's dependencies will be loaded before.
  • A plugin's loaded dependents will be reloaded after.
  • When a plugin is unloaded, its loaded dependents will be unloaded before.

This paradigm naturally puts an emphasis on the structure of packages and applications and less on its orchestration. This allows consumers of applications to easily swap or add plugins while guaranteeing conformity to API contracts.

Install

The package is currently not available on pypi pending a PEP 541 request.

The package can be configured as a Github dependency in a requirements.txt

pyplugin @ git+https://github.com/pyplugin/pyplugin@main

or to pin to a tag

pyplugin @ git+https://github.com/pyplugin/pyplugin@v0.1