Poetry add same library for different Python versions


I know how to add python constraint for a single library

flake8 = { version = "^6.0.0", python = ">=3.8.1" }

But what if I want to have same library, but different version for a different Python version? In case I add it with another constraint it produces an error

Invalid TOML file /home/user/mylib/pyproject.toml: Key "flake8" already exists.

For example, I want my package to support Python ^3.7 but latest flake8 is only compatible with >=3.8.1. How to I add flake8 specification which will be installed for python = "<3.8.1".

Is it possible to achieve at all? Should I create another release calleb mylib-3.7 just to support earlier Python versions?

Asked By: Misha Brt



You can use multiple constraints dependencies:

flake8 = [
    {version = "^5.0", python = ">=3.6,<3.8"},
    {version = "^6.0", python = ">=3.8"}
Answered By: finswimmer