License plugins - Betty documentation

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

# License plugins

Type | `betty.license.License`
Repository | `betty.project.Project.license_repository`

## Creating a license

1. Create a new class that extends `betty.license.License` and implements the abstract methods, for example:

       from typing import override
       from betty.license import License
       from betty.machine_name import MachineName

       class MyLicense(License):
         @override
         @classmethod
         def plugin_id(cls) -> MachineName:
             return "my-module-my-license"

         # Implement remaining abstract methods...
         ...

#. Tell Betty about your license by registering it as an entry point. Given the license above in a module `my_package.my_module`, add the following to your Python package:

pyproject.toml

    [project.entry-points.'betty.license']
    'my-module-my-license' = 'my_package.my_module.MyLicense'

setup.py

    SETUP = {
        'entry_points': {
            'betty.license': [
                'my-module-my-license=my_package.my_module.MyLicense',
            ],
        },
    }
    if __name__ == '__main__':
        setup(**SETUP)

## See also

Read more about how to use licenses and Betty’s built-in licenses at Licenses.