Get pip to work with git and github repository

2019-01-26 10:42发布

I'm writting a python app that depends on another one that is hosted on a github repository (never in pypi) for development reasons.

Lets call them:

  • App being written: AppA
  • App in github: AppB

In App A, the setup.py is like:

# 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'
    ]
)

Now AppA is being built by Jenkins CI with every push and I get a failure because of the next error is thrown:

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

Funny thing is that this only happens in Jenkins, it works perfectly on my computer. I tried both of the other SSH urls that github gives and those are not even considered for download.

Now, AppA is included in the requirements file of a project also being built by Jenkins, so installing the dependencies manually via pip install AppA pip install AppB is not an option, the dependencies are automatically installed by being included in the requirements.txt.

Is there any way to make pip and git with github urls work together?

Any help will be very appreciated :)

Thanks in advance!

2条回答
萌系小妹纸
2楼-- · 2019-01-26 11:10

The problem is not with pip, is with setuptools. The responsible for the setup() call is setuptools package (setuptools or distribute project).

Neither setuptools or distribute understand that kind of url, they understand tarballs/zip files.

Try pointing to Github's download url - usually a zip file.

Your dependency_links entry is probably going to look like:

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

For more information take a look at http://peak.telecommunity.com/DevCenter/setuptools#dependencies-that-aren-t-in-pypi

查看更多
一夜七次
3楼-- · 2019-01-26 11:18

From pip documentation -

pip currently supports cloning over git, git+http and git+ssh:

git+git://git.myproject.org/MyProject#egg=MyProject
git+http://git.myproject.org/MyProject#egg=MyProject
git+ssh://git.myproject.org/MyProject#egg=MyProject

Try replacing git+https with git+git.

查看更多
登录 后发表回答