-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Implement a plugin system #3733
Conversation
de6c5b3
to
af83c4b
Compare
af83c4b
to
f5eb015
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh. This is exciting [WIP] development. Looking forward to it!
Are plugins prohibited with poetry new
? Not sure why people would need them in that context, but 🤷.
poetry/console/application.py
Outdated
pass | ||
|
||
self._disable_plugins = ( | ||
io.input.has_parameter_option("--no-plugins") or command_name == "new" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plugins can't be used for poetry new
calls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a leftover restriction from a previous shot at implementing the plugin system.
The current implementation should not need such restriction.
I'll check and remove it if needed.
or if you wish to accomplish something with Poetry in a way that is not desired by most users. | ||
|
||
In these cases you could consider creating a plugin to handle your specific logic. | ||
|
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
e004ba9
to
18bc2fc
Compare
a690ce7
to
65a2219
Compare
I interpret your docs to mean "yes", but can you confirm whether it's possible with this system to have a repo-specific plugin that lives in the repo itself? or does it need to be installed in one of the sites for poetry to see it? That would be a really useful feature I think :) |
@1ace Plugins will be global and not on a per-project basis. |
b66107d
to
b29004f
Compare
!!!warning | ||
|
||
A plugin **must not** remove or modify in any way the core commands of Poetry. |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
d741351
to
b0ff2ea
Compare
2d9f282
to
43597ab
Compare
43597ab
to
7e5df69
Compare
@abn Regarding the
Once we make it an official plugin we'll see how it goes. For now, I don't have a strong preference even though I feel like keeping the option makes more sense. As to how sub commands can be added, it's simple since subcommands are nothing more than namespaced commands. So basically, it woould look like this: from cleo.commands.command import Command
from poetry.plugins.application_plugin import ApplicationPlugin
class ExportRequirementsCommand(Command):
name = "export requirements.txt"
def handle(self) -> int:
# Do the export
return 0
def export_command_factory():
return ExportRequirementsCommand()
class ExportApplicationPlugin(ApplicationPlugin):
def activate(self, application):
application.command_loader.register_factory(
"export requirements.txt", export_command_factory
) |
7e5df69
to
472fe7f
Compare
Just curious, would it be possible to add an extension building system via a plugin? So poetry handles the Python files and CMake (for example) handles the compiling? I assume a little extra work would be needed to ensure wheels has the right names and such, but how close might this be to working? |
@henryiii If I am understanding you correct, I suspect you can achieve that today using the build script without a plugin. https://github.com/sdispater/pendulum/blob/411d0aa41a5f39c5f4a2f43a3c369c2dd24787db/pyproject.toml#L51-L53 You can add the cmake call into the |
Thanks @abn, that's good to know about. (Though, @sdispater, two notes; just to keep in mind, distutils is slated for removal in Python 3.12, and you shouldn't name a top-level file I'll probably open a discussion, because I'm interested in developing a scikit-build plugin that would integrate CMake with Poetry. |
I was wondering if there is a recommended naming pattern for plugins? Like |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This PR introduces a plugin system to add commands and features to Poetry more easily.
It uses the standard entrypoints system that exists today and will make it possible to build two kinds of plugins:
Poetry
instance created by Poetry. This will be useful to, for instance, implement a plugin that will dynamically set the version of the project based on VCS tags and commits.This PR also provides three new commands to manage plugins:
plugin add
to install pluginsplugin remove
to uninstall pluginsplugin show
to list currently installed plugins.Todo
plugin add
commandplugin remove
commandplugin show
commandPull Request Check List
Resolves: #693