【问题标题】:Install transitive bitbucket dependencies via pip通过 pip 安装传递位桶依赖项
【发布时间】:2013-03-30 01:28:41
【问题描述】:

我正在尝试解决的情况是从 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 运行 urlopen 说明了根本问题(即 pip 需要在 urllib2 中进行额外设置才能使其正常工作)。

here 提到了这个问题,但我无法让它工作。

【问题讨论】:

  • 你确定bitbubket上的repo是git repo吗? bitbucket 也支持 mecurial。
  • @markdsievers 你找到解决方案了吗?我也在找!
  • Assembla 在这种情况下存在 pip 升级问题,不确定是否直接相关,但这个问题和答案确实对我有帮助。

标签: python dependencies pip setuptools


【解决方案1】:

pip 提出了安装 VCS 的想法,因此您可以使用 git+https://path/to/repo.git,但 setuptools 不理解。

当您创建setup.py 文件时,您只使用setuptools(不涉及pip),而setuptools 不理解这种URL。

您可以将 dependency_links 与 tarball 或 zip 文件一起使用,但不能与 git 存储库一起使用。

将您的 depencency_links 替换为:

dependency_links=["https://bitbucket.org/myuser/project-two/get/master.zip#egg=project-two"]

并检查它是否有效。

https://stackoverflow.com/a/14928126/565999也有类似的问题


参考资料:

【讨论】:

  • 感谢您的信息。由于提到的私人/身份验证回购问题,我最终没有解决这个问题 - 但你的信息非常正确,让我走上了正确的道路。非常感谢!
  • 我也被困在这一点上。马克,你有没有办法避免这个 401 错误?我已经尝试过基本身份验证,但我完全不知道为什么它似乎无法识别我提供的用户凭据。
猜你喜欢
  • 2021-08-05
  • 2017-04-18
  • 2016-08-21
  • 2018-09-27
  • 2011-01-20
  • 2014-10-31
  • 2014-10-06
  • 2021-05-29
  • 2023-04-03
相关资源
最近更新 更多