Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to inculde one group of optional-dependencies in another?

If I have 2 groups of project.optional-dependencies in my pyproject.toml, is there a way to specify that installing one group installs the dependencies of the other?

E.g.

[project.optional-dependencies]
test = [
    "pytest",
    "pytest-asyncio",
    "pytest-cov",
]

dev = [
    "flake8",
    "flake8-import-order",
    "black",
]

How can I specify that installing myproj[dev] also installs [test].

like image 332
Gary van der Merwe Avatar asked Oct 23 '25 17:10

Gary van der Merwe


1 Answers

Not sure from which pip version this is possible, on 22.2.2 it is, on 20.0.2 it isn't.

[project]
name = "my-pkg"


[project.optional-dependencies]
test = [
    "pytest",
    "pytest-asyncio",
    "pytest-cov",
]

dev = [
    "flake8",
    "flake8-import-order",
    "black",
    "my-pkg[test]"
]

source => https://hynek.me/articles/python-recursive-optional-dependencies/

like image 127
Frigus Avatar answered Oct 26 '25 07:10

Frigus