出于开发原因,我正在编写一个依赖于另一个托管在 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 或分发项目)。
setuptools
或 distribute
都不理解那种 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/