Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugins: load plugins from setuptools entry points #1585

Merged
merged 1 commit into from
Jul 2, 2019

Conversation

Exirel
Copy link
Contributor

@Exirel Exirel commented May 3, 2019

By defining a sopel.plugins entry point in a setup.cfg (or setup.py) it is now possible to expose a Sopel plugin:

setup(
    name='my_plugin',
    version='1.0'
    entry_points={
        'sopel.plugins': [
            'custom = my_plugin.path.to.plugin',
        ],
    }
)

This definition will allow Sopel to load the custom plugin, from the Python sub-module my_plugin.path.to.plugin from the my_plugin package.

I'm not 100% happy with my abstractclass/subclasses, but I think that's for another day. Here, I wanted to showcase how quick and easy it is to implement new ways to discover Sopel plugins.

I'd like to mention that, in my opinion, entry points are probably a better option than sopel_modules.* subpackages.

@Exirel Exirel added this to the 7.0.0 milestone May 3, 2019
@Exirel Exirel requested review from dgw and a team May 3, 2019 16:16
Copy link
Member

@dgw dgw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this. It's much more elegant than the sopel_modules namespace introduced under my predecessor (and not only because it should have been named sopel_plugins 😛)! Just some nitpicky (as usual) naming stuff from me—and only one grammar fix! You're getting better. 😸

sopel/plugins/handlers.py Outdated Show resolved Hide resolved
sopel/plugins/handlers.py Outdated Show resolved Hide resolved
sopel/plugins/handlers.py Outdated Show resolved Hide resolved
test/test_plugins.py Outdated Show resolved Hide resolved
test/test_plugins.py Outdated Show resolved Hide resolved
sopel/plugins/__init__.py Outdated Show resolved Hide resolved
sopel/plugins/__init__.py Outdated Show resolved Hide resolved
sopel/plugins/__init__.py Outdated Show resolved Hide resolved
sopel/plugins/__init__.py Outdated Show resolved Hide resolved
sopel/plugins/__init__.py Outdated Show resolved Hide resolved
sopel/plugins/__init__.py Outdated Show resolved Hide resolved
sopel/plugins/handlers.py Outdated Show resolved Hide resolved
sopel/plugins/handlers.py Outdated Show resolved Hide resolved
sopel/plugins/handlers.py Outdated Show resolved Hide resolved
sopel/plugins/handlers.py Outdated Show resolved Hide resolved
sopel/plugins/handlers.py Outdated Show resolved Hide resolved
sopel/plugins/handlers.py Outdated Show resolved Hide resolved
test/test_plugins.py Outdated Show resolved Hide resolved
test/test_plugins.py Outdated Show resolved Hide resolved
@Exirel Exirel force-pushed the plugin-entrypoints branch from e0a387d to 6f48be0 Compare May 7, 2019 07:32
@dgw dgw mentioned this pull request May 10, 2019
40 tasks
@Exirel Exirel requested a review from dgw May 11, 2019 15:17
@Exirel
Copy link
Contributor Author

Exirel commented Jun 29, 2019

Just a quick note: fixed as asked. It looks good for a last review & merge. Can't wait to play with that feature for future plugins!

Copy link
Member

@dgw dgw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last English nitpick. Don't worry about the EntryPointPlugin class note; I'm just asking, not requesting that you update or rewrite anything for this PR.

sopel/plugins/__init__.py Outdated Show resolved Hide resolved
sopel/plugins/handlers.py Outdated Show resolved Hide resolved
By defining a `sopel.plugins` entry point in a `setup.cfg` (or
`setup.py`) it is now possible to expose a Sopel plugin:

    setup(
        name='my_plugin',
        version='1.0'
        entry_points={
            'sopel.plugins': [
                'custom = my_plugin.path.to.plugin',
            ],
        }
    )

This definition will allow Sopel to load the `custom` plugin, from the
Python sub-module `my_plugin.path.to.plugin` from the `my_plugin`
package.

Co-Authored-By: dgw <dgw@technobabbl.es>
@Exirel Exirel force-pushed the plugin-entrypoints branch from 35fed08 to 18e8ac6 Compare July 1, 2019 16:19
@Exirel
Copy link
Contributor Author

Exirel commented Jul 1, 2019

@dgw done! 😉

Copy link
Member

@dgw dgw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hoorah!

@dgw dgw removed the request for review from a team July 2, 2019 04:05
@dgw dgw merged commit f7cd5c5 into sopel-irc:master Jul 2, 2019
@Exirel Exirel deleted the plugin-entrypoints branch September 5, 2019 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants