我试图解决的情况是从 bitbucket 上的私有存储库安装一个包,该包对 bitbucket 中的另一个私有存储库有自己的依赖关系。
我用它来开始安装:
pip install -e git+https://bitbucket.org/myuser/project-one.git/master#egg=django_one
然后尝试从 setup.py 下载它的依赖项,如下所示:
install_requires = ['project-two',],
dependency_links = ['git+https://bitbucket.org/myuser/project-two.git/master#egg=project_two'],
这失败了,pip 日志看起来像:
Downloading/unpacking project-two (from project-one)
Getting page https://pypi.python.org/simple/project-two/
Could not fetch URL https://pypi.python.org/simple/project-two/: HTTP Error 404: Not Found (project-two does not have any releases)
Will skip URL https://pypi.python.org/simple/project-two/ when looking for download links for project-two (from project-one)
Getting page https://pypi.python.org/simple/
URLs to search for versions for project-two (from project-one):
* https://pypi.python.org/simple/project-two/
* git+https://bitbucket.org/myuser/project-two.git/master#egg=project-two
Getting page https://pypi.python.org/simple/project-two/
Cannot look at git URL git+https://bitbucket.org/myuser/project-two.git/master#egg=project-two
Could not fetch URL https://pypi.python.org/simple/project-two/: HTTP Error 404: Not Found (project-two does not have any releases)
Will skip URL https://pypi.python.org/simple/project-two/ when looking for download links for project-two (from project-one)
Skipping link git+https://bitbucket.org/myuser/project-two.git/master#egg=project-two; wrong project name (not project-two)
Could not find any downloads that satisfy the requirement project-two (from project-one)
关于这个设置的奇怪之处在于,如果我克隆 project-one 并运行
python setup install
从那里,项目二从 bitbucket 中获取并安装到我的 virtualenv 中。我的理解是 pip 在后台使用设置工具,所以我的假设是该测试的成功验证了我的方法。
任何建议表示赞赏。
跟进:
所以接受的答案是完全正确的——但我的问题是作为一个私人回购(https + http auth-basic)的额外复杂性。使用语法
dependency_links=["http://user:password@bitbucket.org/myuser/..."]
仍然导致 401。运行 shell 并使用pip.download.py
to runurlopen
演示了潜在的问题(即 pip 需要额外的设置urllib2
才能使其正常工作)。
这里提到了这个问题,但我无法让它工作。