我们创建了一个依赖于其他库的库。但是有必要的(例如对于服务器批处理)和可选的依赖项(例如对于具有 GUI 的客户端)。
这样的事情可能吗:
pip install mylib.tar.gz # automatically downloads and installs with the minimal set of dependencies
pip install mylib.tar.gz --install-option="complete" # automatically installs with all dependencies
我找到了extra_require
旗帜,但我怎么知道pip
要使用它们呢?setup.py
看起来像这样:
from setuptools import setup
# ...
# Hard library depencencies:
requires = [
"numpy>=1.4.1",
"scipy>=0.7.2",
"traits>=3.4.0"
]
# Soft library dependencies:
recommended = {
"mpl": ["matplotlib>=0.99.3"],
"bn": ["bottleneck>=0.6"]
}
# ...
# Installer parameters:
setup(
name = "mylib",
#...
install_requires = requires,
extras_require = recommended
)