python - 让 pip 与 git 和 github 存储库一起工作

标签 python django git github pip

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

让我们称呼他们:

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

在 App 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

有趣的是,这只发生在 Jenkins 中,它在我的电脑上运行完美。我尝试了 github 提供的其他两个 SSH url,但这些 url 甚至都不考虑下载。

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

有没有办法让 pip 和 git 与 github url 一起工作?

任何帮助将不胜感激:)

提前致谢!

最佳答案

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

setuptoolsdistribute 都不理解那种 url,他们理解 tarballs/zip 文件。

尝试指向 Github 的下载 url - 通常是一个 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

关于python - 让 pip 与 git 和 github 存储库一起工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14737500/

相关文章:

Windows 上的 Git 1.6.4 beta (msysgit) - Unix 或 DOS 行终止

python - 无法安装用 C 编写的链接 OpenSSL 的 python 模块

python - 如何从 AWS 中的 SQS 队列接收多于 1 条消息?

python - Django 和 App Engine - 2012 更新

python - AttributeError at/'tuple' 对象没有属性 '_meta'

git - 如何让 git 停止跟踪文件的更改,同时将其保留在索引中?

python - 在 Jupyter 中切换内核

python - 如果任务没有运行超过 10 分钟,如何重新安排任务?

python - django form.as_p 中的表单不同

git - Gerrit 作为审查工具,而不是记录存储库