通常情况下,您只需安装这样的任何软件包 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/