Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install transitive bitbucket dependencies via pip

The situation I'm trying to resolve is installing a package from a private repository on bitbucket which has it's own dependency on another private repository in bitbucket.

I use this to kick off the install:

pip install -e git+https://bitbucket.org/myuser/project-one.git/master#egg=django_one 

which then attempts to download it's dependencies from setup.py that look like:

install_requires = ['project-two',],
dependency_links = ['git+https://bitbucket.org/myuser/project-two.git/master#egg=project_two'],

This fails, the pip log looks like:

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)

The curious thing about this setup is, if I take a clone of project-one and run

python setup install

from there, project-two is fetched from bitbucket and installed into my virtualenv. My understanding was that pip was using setup tools under the hood, so my assumption was the success of that test validated my approach.

Any suggestions appreciated.

FOLLOW UP:

So the accepted answer is quite right - but my problem had the additional complexity of being a private repo (https + http auth-basic). Using the syntax

dependency_links=["http://user:[email protected]/myuser/..."]

still caused a 401. Running up a shell and using pip.download.py to run urlopen demonstrates the underlying problem (ie pip needs additional setup in urllib2 to get this working).

The problem is mentioned here but I couldn't get that working.

like image 931
markdsievers Avatar asked Apr 08 '13 04:04

markdsievers


1 Answers

pip created the idea of a VCS installation, so you can use git+https://path/to/repo.git, but setuptools does not understand that.

When you create a setup.py file you are using only setuptools (no pip involved), and setuptools does not understand that kind of URL.

You can use dependency_links with tarballs or zip files, but not with git repositories.

Replace your depencency_links by:

dependency_links=["https://bitbucket.org/myuser/project-two/get/master.zip#egg=project-two"]

And check if it works.

There is a similar question at https://stackoverflow.com/a/14928126/565999


References:

  • http://peak.telecommunity.com/DevCenter/setuptools#dependencies-that-aren-t-in-pypi
like image 101
Hugo Tavares Avatar answered Oct 29 '22 03:10

Hugo Tavares