pythonpython-poetrypyproject.toml

Does Poetry for Python use a nonstandard pyproject.toml? How?


I am considering introducing my organization to Poetry for Python, and I came across this claim:

Avoid using the Poetry tool for new projects. Poetry uses non-standard implementations of key features. For example, it does not use the standard format in pyproject.toml files, which may cause compatibility issues with other tools.

--Modern Good Practices for Python Development

Is this true? I didn't immediately turn up anything searching. What does Poetry do that is nonstandard, in the pyproject.toml or anywhere else?


Solution

  • Yes, Poetry as of writing still uses its own [tool.poetry.dependencies] table in pyproject.toml.

    This is in conflict with PEP621, which specifies among other things that a project's dependencies ought to be listed in [project.dependencies] instead.

    There is an issue tracking this here https://github.com/python-poetry/poetry/issues/3332 and it seems that as of writing support for PEP621 is on the way, with a draft pull request passing checks here: https://github.com/python-poetry/poetry/pull/9135.

    The main downside of this is that other tools do not understand which packages your poetry project depends on. I believe the built packages that you upload to PyPI etc do not suffer from this issue, because poetry during the build process creates correct package metadata with a fixed set of version-pinned dependencies, so pip install your-poetry-package would work just fine to install the dependencies.

    In conclusion, in poetry version 2.0, some time soon poetry might be compatible with pyproject.toml standards.