简体   繁体   English

setup.py 中 extras_require 的依赖链接

[英]Dependency links for extras_require in setup.py

  1. Is there a way to process dependency links automatically when installing a package with extras, without having to call --process-dependency-links as it is the case with install_requires ?有没有办法在安装带有附加功能的包时自动处理依赖关系链接,而不必像install_requires那样调用--process-dependency-links

     pip install -e .[extra] --process-dependency-links

    I need this because the dependency is only located on a private git repo.我需要这个,因为依赖项仅位于私有 git 存储库上。

  2. Is it possible to install extras using python setup.py install ?是否可以使用python setup.py install安装附加功能?

  3. Is --process-dependency-links still to be considered as it is deprecated? --process-dependency-links仍被考虑,因为它已被弃用? I am not sure about the status here.我不确定这里的状态。

I searched way too long to figure out how to do this with setup.cfg so hopefully this will help someone else if they don't want to use setup.py as the OP didn't specify.我搜索了太长时间,无法弄清楚如何使用 setup.cfg 执行此操作,因此希望如果其他人不想使用 setup.py,因为 OP 未指定,这将对其有所帮助。 I've also included a custom URL for install_requires as that took a while to figure out as well.我还包含了 install_requires 的自定义 URL,因为这也需要一段时间才能弄清楚。

#setup.cfg (only showing relevant parts)
[options]
install_requires =
    pyyaml @ git+https://github.com/yaml/pyyaml.git@master
    
[options.extras_require]
jsonschema = jsonschema @ git+https://github.com/Julian/jsonschema.git@v3.2.0
six = six
  1. pip install -e .[jsonschema] will get you the extra with a custom URL or pip install -e .[jsonschema,six] will get you both extras (note that there are NO spaces after the . or around the comma(s) in the extras list). pip install -e .[jsonschema]会给你额外的自定义 URL 或pip install -e .[jsonschema,six]会给你额外的东西(注意.或逗号周围没有空格)在附加列表中)。
  2. As far as I can tell, you cannot get extras installed using python setup.py install .据我所知,您无法使用python setup.py install附加功能。
  3. Yes --process-dependency-links is still deprecated in spite of much complaining but the above is good enough once you know the syntax.是的--process-dependency-links尽管有很多抱怨,但仍然不推荐使用,但是一旦您知道语法,上述内容就足够了。
  1. Yes, you no longer need --process-dependency-links if you use extras_require .是的,如果您使用extras_require则不再需要--process-dependency-links

Tested with pip version 19.3.1使用 pip 版本 19.3.1 测试

Example:例子:

$ pip install -e .[graphs]

# setup.py  

from setuptools import setup
setup(
    name='myservice',
    version='0.1.0',
    install_requires=[
        'requests',
    ],
    extras_require={
        'graphs': [
            'graphcommons @ git+ssh://git@github.com/graphcommons/graphcommons-python@master',
        ],
    },
)

By using ssh protocol (instead of https) to access git repo, you can install from your private repos.通过使用 ssh 协议(而不是 https)访问 git repo,您​​可以从您的私有 repos 进行安装。

  1. Not sure about python setup.py install but pip install .[extras] should be good enough?不确定python setup.py installpip install .[extras]应该足够好?

  2. Yes, in pip version 19.是的,在 pip 版本 19 中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM