如何在使用pbr时将git repo包含为依赖项

时间:2017-09-21 11:13:42

标签: python git python-pbr

我正在使用pbr,它使用requirements.txt文件来查找依赖项。

我在requirements.txt中有一行,如git+ssh://git@github.com/user/repo.git,当我运行pip install -r requirements.txt

时它会起作用

然而,当我运行python setup.py build时,我遇到了错误:

error in setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Invalid requirement, parse error at "'+ssh://g'"

many Stack Overflow answers个问题仅在使用setuptools时处理此问题,并且所有这些都建议将Git依赖项放入dependency_links中的setup.py列表中。

我希望pbr能够直接从requirements.txt处理我的Git依赖关系,这种方式在我同时运行python setup.py buildpip install -r requirements.txt时都有效。

这可能吗?有没有紧密的解决方法?

1 个答案:

答案 0 :(得分:1)

在您提供的示例中,pbr会将整行传播到install_requires,这将生成无效行。

通过#egg = name提供需求名称

要使其按预期工作,该URL需要一个static void Main(string[] args) { string jsonText = @" { ""PropertyOne"": ""PropOne"", ""PropertyTwo"": ""PropTwo"", ""PropertyThree"": ""PropThree"" }"; string jsonText2 = @" { ""MyObject"": { ""PropertyOne"": ""PropOne"", ""PropertyTwo"": ""PropTwo"", ""PropertyThree"": ""PropThree"" } }"; var JsonObj = JObject.Parse(jsonText); var JsonObj2 = JObject.Parse(jsonText2); JObject MyObject = JsonObj as JObject; MyObject.Add("MyObject", JsonObj2["MyObject"]); Console.WriteLine(JsonObj.ToString()); } 后缀来告诉pbr该URL提供了什么要求。如果该网址看起来像这样,则pbr将从#egg部分中scrape a requirement,仅将#egg传播到repo

install_requires

版本限制

如果包含版本,则对其pbr will add施加git+ssh://git@github.com/user/repo.git#egg=repo 约束。因此,它将在>=中变成repo>=1.2.3

install_requires

依赖链接

还将extract a dependency_link item包含完整的URL。您可以通过将git+ssh://git@github.com/user/repo.git#egg=repo-1.2.3 传递给点来使用它。默认情况下,除非该软件包也可以通过PyPI获得,否则pip将返回错误--process-dependency-links。如果指定了Could not find a version that satisfies the requirement repo,那么它将从Git URL中获取它。

使用-e标志,或要求--process-dependency-links

在1.9.0版之前,pbr仅识别pbr>=1.9.0http URL,除非该行以https开头。它在this commit中增加了对-egit://git+ssh://(不含git+https://)的支持。

相关问题