我在Github上有一个带有setup.py
和requirements.txt
的Python回购。最初,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]
)
当我为此repo执行pip install git+https://github.com/foo/bar.git@branch#egg=foo
时,它正确安装了install_requires
依赖项,但忽略了dependency_links
中其他基于Github的依赖项。
经过大量调查 - StackOverflow,#python和文档(FWIW) - 有一个建议是{@ 1}}已被弃用,所有内容都应放入dependency_links
。所以我将install_requires
更改为:
setup.py
现在pip抱怨,只要它到达基于Github的依赖 - 让我们称之为setup(
...
install_requires=open("requirements.txt").read().splitlines()
)
- 它期待“版本规范”。我试过了:
quux
git+https://github.com/foo/quux.git@branch#egg=quux==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
中有和没有前面的-e
并且我一直收到此错误。我也为URL方案尝试了不同的格式,也没有任何区别。
如何格式化requirements.txt
和requirements.txt
以处理基于Git的依赖项?
答案 0 :(得分:0)
对我有用的是使用此conf/wrapper.conf
文件运行pip install --process-dependency-links ...
:
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',
]
)
已弃用,并且将在未来的pip版本中删除。在那种情况下,我不知道解决方案是什么。