Python 使用pip安装依赖于Github的软件包

Python 使用pip安装依赖于Github的软件包,python,git,pip,python-3.5,Python,Git,Pip,Python 3.5,我在Github上有一个Python repo,带有setup.py和requirements.txt。最初,setup.py包含以下内容: setup( ... install_requires=[x for x in open("requirements.txt").read().splitlines() if "://" not in x], dependency_links=[x for x in open("requirements.txt").read().splitli

我在Github上有一个Python repo,带有
setup.py
requirements.txt
。最初,
setup.py
包含以下内容:

setup(
  ...
  install_requires=[x for x in open("requirements.txt").read().splitlines() if "://" not in x],
  dependency_links=[x for x in open("requirements.txt").read().splitlines() if "://" in x]
)
当我安装git时+https://github.com/foo/bar.git@branch#egg=foo对于此回购,它正确安装了
install\u所需的
依赖项,但忽略了
dependency\u链接中其他基于Github的依赖项

经过大量的调查——StackOverflow、#python和docs(FWIW)——有人建议不推荐使用
依赖关系链接
,所有内容都应该放入
install\u requires
。因此,我将我的
setup.py
更改为:

setup(
  ...
  install_requires=open("requirements.txt").read().splitlines()
)
现在,pip抱怨说,每当它遇到基于Github的依赖项时——我们称之为
quux
——它都在期待一个“版本规范”。我试过:

  • git+https://github.com/foo/quux.git@分支#egg=quox==0.1.0
  • git+https://github.com/foo/quux.git@branch#egg=quux#version==0.1.0
  • git+https://github.com/foo/quux.git@branch#egg=quux&version==0.1.0
…以及没有指定任何版本,包括我的
requirements.txt
中前面的
-e
,我一直收到此错误。我也尝试了不同格式的URL方案,也没有任何区别


如何格式化我的
requirements.txt
setup.py
以处理基于Git的依赖关系?

对我有用的是运行
pip安装--进程依赖关系链接…
setup.py
文件:

setup(
    ...
    install_requires=[
        'my_lib==0.1.0',
    ],
    dependency_links=[
        'git+ssh://git@github.com/foo/quux.git@branch#egg=my_lib-0.1.0',
    ]
)

请注意,正如您所说,
--dependency\u links
已被弃用,它将在pip的未来版本中被删除。在这种情况下,我不知道解决方案是什么。

我还尝试了使用原始的
setup.py
安装不推荐的
pip安装--进程依赖项链接…
:它没有任何区别,仍然没有安装基于Github的依赖项。