setup.py/setup.cfg安装所有其他功能 [英] setup.py/setup.cfg install all extras

查看:227
本文介绍了setup.py/setup.cfg安装所有其他功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索是否可以继承" setup.cfg中的其他功能,如下所示:

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]

推荐答案

我相信 setuptools 使用

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

生成 sdist ,然后查看项目的 *.egg-info/requires.txt 文件以获取结果.由于 test 包含在 all 中两次,一次直接或一次通过 dev 间接进行,因此在 all ,但很可能这不是什么大问题.

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.

这篇关于setup.py/setup.cfg安装所有其他功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆