获取pip以使用git和github存储库


问题内容

由于开发原因,我正在编写一个依赖于托管在github存储库中的另一个应用程序(从来没有在pypi中使用)的python应用程序。

让我们称它们为:

  • 正在编写的应用程序: AppA
  • github中的应用程序: AppB

在应用程序A中,setup.py类似于:

# coding=utf-8
import sys
try:
    from setuptools import setup, find_packages
except ImportError:
    import distribute_setup
    distribute_setup.use_setuptools()
    from setuptools import setup, find_packages

setup(
    ...
    install_requires=[
        # other requirements that install correctly
        'app_b==0.1.1'
    ],
    dependency_links=[
        'git+https://github.com/user/app_b.git@0.1.1#egg=app_b-0.1.1'
    ]
)

现在每按一次AppA都在构建,Jenkins CI由于抛出下一个错误,我失败了:

error: Download error for git+https://github.com/user/app_b.git@0.1.1: unknown url type: git+https

有趣的是,这仅发生在詹金斯身上,在我的计算机上可以正常工作。我尝试了github提供的其他两个SSH URL,甚至都不考虑下载。

现在,AppA包含在同样由Jenkins构建的项目的需求文件中,因此pip install AppA pip install AppB不能手动通过安装依赖项,而是通过将包含项自动安装依赖项requirements.txt

有什么方法可以使pip和git与github url一起工作吗?

任何帮助将不胜感激:)

提前致谢!


问题答案:

问题不pip在于,在于setuptools。负责setup()调用的是setuptools程序包(setuptools或分发项目)。

无论是setuptoolsdistribute理解的网址类型,他们了解压缩包/ zip文件。

尝试指向Github的下载网址-通常是一个zip文件。

您的dependency_links输入可能看起来像:

dependency_links=[
    'https://github.com/user/app_b/archive/0.1.1.zip#egg=app_b-0.1.1'
]

有关更多信息,请访问http://peak.telecommunity.com/DevCenter/setuptools#dependencies-
that-aren-t-in-
pypi