I search for a possibility to 'inherit' other extras in the setup.cfg like so:
[options.extras_require]
all =
<doc>
<dev>
<test>
doc =
sphinx
dev =
dvc
twine # for publishing
<test>
test =
flake8
pytest
pytest-cov
coverage
pytest-shutil
pytest-virtualenv
pytest-fixture-config
pytest-xdist
I wish to install all extras by running
pip install PACKAGE[all]
I believe setuptools uses configparser
's BasicInterpolation
when parsing the setup.cfg
files. So you could use that to your advantage to do something like the following:
[options.extras_require]
all =
%(doc)s
%(dev)s
%(test)s
doc =
sphinx
dev =
dvc
twine # for publishing
%(test)s
test =
flake8
pytest
pytest-cov
coverage
pytest-shutil
pytest-virtualenv
pytest-fixture-config
pytest-xdist
Build the sdist
then look at the *.egg-info/requires.txt
file for your project for the result. Since test
is included in all
twice, once directly and once indirectly via dev
, there will be some repetitions in all
, but most likely it shouldn't be much of an issue.
Another solution, that theoretically should work with all build back-ends and front-ends is to "self-depend":
[options.extras_require]
all =
PROJECT[doc]
PROJECT[dev]
PROJECT[test]
doc =
sphinx
dev =
dvc
twine # for publishing
PROJECT[test]
test =
flake8
pytest
pytest-cov
coverage
pytest-shutil
pytest-virtualenv
pytest-fixture-config
pytest-xdist
References: