hintze
hintze

Reputation: 630

Nest or combine extras_require for setuptools in setup.cfg

Is it possible to re-use dependencies already specified in the [options.extras_require] for other entries in the [options.extras_require]? Say, for example, a team of devs is using mypy to check their type annotations during development, and black to auto-format their code. in this case, they would specify the [options.extras_require] like:

[options.extras_require]
dev = black, mypy

But now a testing environment is set-up, which also uses mypy to check type hints, but doesn't need black. So the config is extended to look like:

[options.extras_require]
test = mypy
dev = black, mypy

Now any testing-dependency also needed for development is repeated for the development-dependencies.

Is there any way to avoid this by saying that dev requires all in test as well?

Upvotes: 4

Views: 1042

Answers (1)

renatodamas
renatodamas

Reputation: 19595

You can make a reference to the extra package:

[metadata]
name = foo

[options.extras_require]
test = mypy
dev = black; foo[test]

Upvotes: 11

Related Questions