Search code examples
pippython-packagingpython-poetry

is it possible to install poetry groups with pip?


As recomended by poetry, I'm using groups for dev specific dependencies ("test", "docs", and "dev").

I would to use them in automated tools such as github actions, readthedocs and nox which are more bounds to pip installation.

Is it possible to install specific groups from poetry as I do with setuptools based packages ?

pip install my_lib[dev]

Solution

  • As far as I can tell, it is not possible. The [tool.poetry.group] section of pyproject.toml is proprietary to Poetry, its content does not follow a standard specification. Technically speaking, nothing prevents any tool (including pip) to implement support for this Poetry-specific feature, but as far as I know no tool has implemented this support (besides Poetry of course).

    Poetry's own documentation chapter "Managing dependencies" says the following on the matter:

    Dependency groups, other than the implicit main group, must only contain dependencies you need in your development process. Installing them is only possible by using Poetry.

    To declare a set of dependencies, which add additional functionality to the project during runtime, use extras instead. Extras can be installed by the end user using pip.

    Other tools have their own way of handling similar concepts of dependency groups. For example Hatch, and PDM.

    You might be interested in reading, following, and weighing in on these discussions regarding the standardization of such dependency groups so that they can be used in interoperable manner by various tools (including pip potentially):