Entry point plugins - Betty 0.4.0a3 documentation

Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# Entry point plugins

Plugins may be discovered by defining them as Python distribution package entry points.

## Creating a plugin type

If you are developing an API that needs a new plugin type, and you want other developers to be able to define them as entry points, you want to use `betty.plugin.entry_point.EntryPointPluginRepository`. It requires an entry point group (name) such as `YourPluginGroup`, which is also used for the entry point definitions.

## Creating a plugin

If you are developing a plugin of an existing plugin type that uses entry points, you’ll have to add that plugin to your package metadata. For example, for a plugin type

- whose entry point group is `YourPluginGroup`

- with a plugin class `MyPlugin` in the module `my_package.my_module`

- and a plugin ID `my_package_plugin`:

pyproject.toml

    [project.entry-points.'YourPluginGroup']
    'my_package_plugin' = 'my_package.my_module:MyPlugin'

setup.py

    SETUP = {
        'entry_points': {
            'YourPluginGroup': [
                'my_package_plugin=my_package.my_module:MyPlugin',
            ],
        },
    }
    if __name__ == '__main__':
        setup(**SETUP)