我在 setup.cfg 中寻找“继承”其他附加功能的可能性,如下所示:
[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
我希望通过运行来安装所有附加组件
pip install PACKAGE[all]
最佳答案
我相信 setuptools 使用 configparser
's BasicInterpolation
在解析 setup.cfg
文件时。因此,您可以利用这一优势来执行以下操作:
[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
构建 sdist
然后查看项目的 *.egg-info/requires.txt
文件以获取结果。由于 test
被包含在 all
中两次,一次是直接包含的,一次是通过 dev
间接包含的,所以 all
中会有一些重复>,但很可能这应该不是什么大问题。
另一个理论上应该适用于所有构建后端和前端的解决方案是“自力更生”:
[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
引用:
关于installation - setup.py/setup.cfg 安装所有附加功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61609869/