Plugins#
modelly.plugins finds third-party extensions through package entry points. The guide is
Plugins.
Third-party extensions found through package entry points.
A package extends Modelly by declaring entry points in one of the groups of GROUPS,
for example in its pyproject.toml:
[project.entry-points."modelly.spaces"]
hexworld = "hexworld.space:HexWorld"
discover(group) lists what is installed without importing anything; each Plugin is
imported the first time it is loaded. A plugin that fails to import raises
PluginError naming the plugin and its distribution, and never stops the others from
being found or loaded: load_all returns the loaded objects and the errors apart.
from modelly.plugins import discover
spaces = discover(“modelly.spaces”) # {“hexworld”: Plugin(…)} HexWorld = spaces[“hexworld”].load()
- class Plugin(name: str, group: str, value: str, distribution: str | None, _entry_point: EntryPoint, _loaded: Any = <object object>)[source]#
One entry point: imported on the first
loadand cached.- Variables:
- load() Any[source]#
Import and return the object the entry point names.
- Raises:
PluginError – if importing or resolving it fails, with the original error as its cause.
- discover(group: str) dict[str, Plugin][source]#
The installed plugins of
group, by name, sorted; nothing is imported.Any group name works, so a feature may define its own;
GROUPSlists Modelly’s. When two distributions declare the same name, the first distribution in alphabetical order wins and aRuntimeWarningnames both.Example
>>> discover("modelly.no_such_group") {}