Search code examples
pythonsetuptoolspython-poetry

How to specify flask entry_points in plugins that use project.toml instead of setup.py


We have some in-house python libraries which we install from our private index. Some of them provide a few CLI commands which we make available to our flask projects by using the pattern described on the flask documentation page.

We would like to switch from using setuptools to poetry + project.toml files in our python libraries, but can't seem to figure out how we can still provide those entry_points to our flask projects. Is that possible?

My guess is it's not possible because flask is not aware of other packaging methods. Can that be the case?


Solution

  • You can define plugin entrypoints with poetry as well (see Doc)

    In your case the section would look like this:

    [tool.poetry.plugins."flask.commands"]
    "my-command" = "flask_my_extension.commands:cli"