python - 使用其他包扩展 pip 包

标签 python pip

通常情况下,您只需安装这样的任何软件包 pip install SomePackage,但对于某些软件包,我见过 pip install SomePackage[anotherPackage] 或使用 SomePackage[ anotherPackage,yetAnother] 因此它有效地扩展了 SomePackage 中的一些功能,而不会导致膨胀。

如何实现这一目标?

最佳答案

它被称为 extras在安装工具命名法中

引用官方文档:

Sometimes a project has “recommended” dependencies, that are not required for all uses of the project. For example, a project might offer optional PDF output if ReportLab is installed, and reStructuredText support if docutils is installed. These optional features are called “extras”, and setuptools allows you to define their requirements as well. In this way, other projects that require these optional features can force the additional requirements to be installed, by naming the desired extras in their install_requires.

For example, let’s say that Project A offers optional PDF and reST support:

setup(
    name="Project-A",
    ...
    extras_require={
        'PDF':  ["ReportLab>=1.2", "RXP"],
        'reST': ["docutils>=0.3"],
    } )

关于python - 使用其他包扩展 pip 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44017056/

相关文章:

python - pip install urllib3 卡在 "Caching due to etag"

python - 执行Python时!pip的含义是什么?

python - 庆典 : virtualenv: command not found "ON Linux"

python - 为什么 Python 在销毁对象之前销毁类变量?

python - 如何更改分类 x 轴的绘图顺序

python - 是否可以在不使用回测库的情况下回测交易算法?

python - 使用 python ibPy 库获取你的投资组合的位置

python - pip 和 python2 -m pip 有什么区别?

python - 更改 matplotlib 中的抗锯齿强度

python - pip install -rrequirements.txt 在 venv 中不起作用