setuptools and pip: choice of minimal and complete install

前端 未结 2 2023
情歌与酒
情歌与酒 2020-12-05 19:15

We\'ve made a library which depends on other libraries. But there are necessary (e.g. for server batch processing) and optional dependencies (e.g. for clients with GUI).

2条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-05 20:18

    You can install the packages in extras_require by appending the name of the recommended dependency in square brackets (i.e. [mpl] or [bn] in your case) to the package name in pip.

    So to install 'mylib' with the additional requirements, you would call pip like this:

    pip install 'mylib[mpl]'
    pip install 'mylib[bn]'
    

    This will first download and install the extra dependencies, and then mylib's core dependencies.

    This is anologous to how you declare those dependencies with setuptools: http://pythonhosted.org/setuptools/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies (see the install_requires value in the third example)

提交回复
热议问题