Skip to content

Locking different versions of a dependency for different python versions #10142

Answered by radoering
aryarm asked this question in Q&A
Discussion options

You must be logged in to vote

You can use both, project.dependencies and tool.poetry.dependencies, see https://python-poetry.org/docs/dependency-specification/#projectdependencies-and-toolpoetrydependencies
When using both, tool.poetry.dependencies do not influence the metadata but are only used for locking.

I would try something like:

[project]
dependencies = [
    "numpy>=1.17.3",
]

[tool.poetry.dependencies]
numpy = [
    { version = "1.17.3", markers = "python_version < '3.9'" },
    { version = "1.21.1", markers = "python_version >= '3.9'" },
]

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@aryarm
Comment options

Answer selected by aryarm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants