Home¶
Plugin system and CLI engine for projects built with pyrig.
Overview¶
Put simply, pyrig-runtime is a plugin system based on classes that declare functionality through code, and via subclassing these classes any state and functionality can be changed, removed or extended by overriding the methods of parent classes. For pyrig-runtime itself this applies to the CLI class it provides.
Specifically, pyrig-runtime defines one base class DependencySubclass
at the root of this plugin system. All classes that inherit from it
are automatically discoverable. The discovery is achieved as follows:
pyrig-runtime builds a directed graph from all installed dependencies in
the current Python environment, and finds all packages that have
pyrig-runtime as their ancestor in the graph. Those packages are then
imported and scanned for any classes that inherit from DependencySubclass.
Through the DependencySubclass base class, every subclass has a .leaf()
method that returns the leaf class of the inheritance tree. If several leaf
classes are found by the discovery mechanism, they are dynamically merged
into a single class with multiple inheritance. This is what lets
independently installed packages cooperatively extend the same piece of
behaviour. See Plugin discovery for more details.
pyrig-runtime was originally built for pyrig which
uses it for its file generation and tool wrapping classes and its CLI.
pyrig-runtime is a standalone library — its only dependency is Typer, and nothing
here requires pyrig itself to be installed. pyrig is a development dependency and
dev toolkit; pyrig-runtime is a plugin system and automatic CLI enabler.
Installation¶
In most cases you do not install it directly as pyrig adds it to a project's dependencies for you when you initialize a project with it. But if you for example want to use the plugin discovery for your own interests you can add it like any other python package:
Features¶
pyrig-runtime provides two main capabilities. Each has its own page with more detail:
- Plugin discovery — define a base class and its subclasses are discovered automatically across every installed package that depends on it, with no registration step.
- Automatic CLI — every project gets a working command-line interface.
API reference¶
Every public module, class, and function is documented from its source in the API reference.