You may wish to alter or expand Poetry's functionality with your own. For example if your environment poses special requirements on the behaviour of Poetry which do not apply to the majority of its users 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.

Creating a plugin

A plugin is a regular Python package which ships its code as part of the package and may also depend on further packages.

Plugin package

The plugin package must depend on Poetry and declare a proper plugin in the pyproject.toml file.

name = "my-poetry-plugin"
version = "1.0.0"
# ...

python = "~2.7 || ^3.7"
poetry = "^1.0"

demo = "poetry_demo_plugin.plugin:MyPlugin"

Plugin class

Every plugin has to supply a class which implements the poetry.plugins.Plugin interface.

The activate() method of the plugin is called after the plugin is loaded and receives an instance of Poetry as well as an instance of

Using these two objects all configuration can be read and all internal objects and state can be manipulated as desired.


from poetry.plugins import Plugin

class MyPlugin(Plugin):

    def activate(self, poetry, io):  # type: (Poetry, IO) -> None
        version = self.get_custom_version()
        io.write_line("Setting package version to {}".format(version))

        poetry.package.version = version

    def get_custom_version(self):  # type: () -> str


当前网页内容, 由 大妈 ZoomQuiet 使用工具: ScrapBook :: Firefox Extension 人工从互联网中收集并分享;
若有不妥, 欢迎评注提醒:


订阅 substack 体验古早写作:

点击注册~> 获得 100$ 体验券: DigitalOcean Referral Badge

关注公众号, 持续获得相关各种嗯哼:


关于 ~ DebugUself with DAMA ;-)
公安备案号: 44049002000656 ...::