Search code examples
pythonpython-poetry

poetry: no way exclude dependencies for production?


I’m publishing a Python package.

It has dependencies a, b, c. It also has pytest as a dependency, defined in the group.dev as per poetry’s documentation.

However, I couldn’t find a conclusive answer for the following question:

When some installs my library with:

pip install my_library

Is pytest (defined in any group other than the main group, in this case dev) also installed? That would be very undesirable.


Solution

  • You can mention the dev dependency like this. It will not install the pytest. Reference

    # rp_poetry/pyproject.toml (Excerpt)
    
    [tool.poetry.dependencies]
    python = "^3.9"
    requests = "^2.26.0"
    
    [tool.poetry.dev-dependencies]
    pytest = "^5.2"
    black = "^21.9b0"
    

    poetry is may go to change the label of dev-dependencies in the future.