通过pip安装传递bitbucket依赖项

时间:2013-04-08 04:08:44

标签: python dependencies pip setuptools

我正在尝试解决的问题是从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'],

这失败了,点子日志如下:

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)

关于这个设置的奇怪之处在于,如果我修复了一个项目并运行

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,但我无法解决这个问题。

1 个答案:

答案 0 :(得分:3)

pip创建了VCS安装的概念,因此您可以使用git+https://path/to/repo.git,但setuptools无法理解。

当您创建setup.py文件时,您只使用setuptools(不涉及pip),setuptools无法理解此类网址。

您可以将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

上有类似的问题

参考文献: