简体   繁体   English

pip install软件包仍未遵循依赖关系链接

[英]pip install package still not following dependency links

I'm having serious trouble with using setup.py to pip install my package which also has dependency links. 我在使用setup.py pip安装我的软件包时遇到了麻烦,该软件包也具有依赖项链接。 I have read this answer and this one thoroughly and none of the answers including the accepted ones help. 我已经仔细阅读了这个答案这个答案,所有答案(包括已接受的答案)都没有帮助。

Here is the setup.py for the package trying to install. 这是尝试安装的软件包的setup.py Basically, it reads the requirements.txt to fill install_requires and dependency_links, most of the rest of the code is boilerplate from cookie-cutter. 基本上,它会读取requirements.txt来填充install_requires和dependency_links,其余大部分代码都是cookie-cutter的样板。 requirements.txt has a private github repo in it which is causing the issues. requirements.txt中有一个私人的github存储库,这是导致问题的原因。 eg git+https://${GITHUB_OAUTH_TOKEN}@github.com/jmerkow/pripy.git#egg=pripy 例如git+https://${GITHUB_OAUTH_TOKEN}@github.com/jmerkow/pripy.git#egg=pripy

When I run pip install -r requirements.txt everything works great, it installs the private repository. 当我运行pip install -r requirements.txt一切正常,它将安装专用存储库。 However, if I try to install using pip install . --process-dependency-links 但是,如果我尝试使用pip install . --process-dependency-links pip install . --process-dependency-links , I get this error: pip install . --process-dependency-links ,出现此错误:

Could not find a version that satisfies the requirement pripy (from mypackage==<sha>) (from versions: )
No matching distribution found for pripy (from mypackage==<sha>)

If I take off the #egg=xxx from the link in requirements, the private repo package is completely ignored by pip install . 如果我从需求中的链接中pip install . #egg=xxx ,则pip install .会完全忽略私有repo软件包pip install . but not by pip install -r requirements.txt . 但是不是pip install -r requirements.txt

I have confirmed that dependency_links contains 'git+https://<actual-token>@github.com/jmerkow/pripy.git#egg=pripy' and that install_requires includes 'pripy' 我已经确认dependency_links包含'git+https://<actual-token>@github.com/jmerkow/pripy.git#egg=pripy' ,并且install_requires包含'pripy'

How do you get setup to properly Is this a problem with the sub-package? 如何正确设置安装程序这是子软件包的问题吗? setup.py in that repo is done pretty much the same, except there are no private links. 除了没有私有链接外,该存储库中的setup.py几乎相同。

Ugh, this always happens. gh,这总是发生。 I put in all the work to the question, then I figure it out myself. 我把所有工作都放在了问题上,然后我自己弄清楚了。

The issue is two things, first, all dependeny_links need to have a version, second to pull the version from the requirements file properly you need to do some magic on the string. 问题有两点,首先,所有dependeny_links需要一个版本,其次要从需求文件中正确提取版本,您需要对字符串做一些魔术。

Comparing to the above setup.py, I changes the way requirements are added to the two lists (updated here ). 与上面的setup.py相比,我更改了将需求添加到两个列表( 在此处更新)的方式。 Then add the version to #egg=xxx on the link eg git+https://${GITHUB_OAUTH_TOKEN}@github.com/jmerkow/pripy.git#egg=pripy-0 . 然后将版本添加到链接上的git+https://${GITHUB_OAUTH_TOKEN}@github.com/jmerkow/pripy.git#egg=pripy-0 #egg=xxx ,例如git+https://${GITHUB_OAUTH_TOKEN}@github.com/jmerkow/pripy.git#egg=pripy-0

Now setup.py will parse that file, take the egg version info, convert it to a pip version (basically replace the first '-' with an '==' ) for the install_requires, and you're good to go. 现在setup.py将解析该文件,获取egg版本信息,将其转换为pip版本(基本上将第一个'-'替换为'==' )以进行install_requires,您可以开始使用了。

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

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