setuptools和pip:最小和完整ins的选择

2024-04-28 14:38:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我们建立了一个依赖其他图书馆的图书馆。但是有必要(例如,对于服务器批处理)和可选的依赖关系(例如,对于带有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
)

Tags: installpip图书馆withsetuplibrarydependenciesrequire