Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install a package with pip from git if it has multiple subdirectories?

I am working with a repo which has the following structure:

  • foo/bar/setup.py
  • foo/bar/mypackage

I am attempting to install this package using something like:

pip install git+ssh://[email protected]/owner/repo-namegit@commithash#egg=mypackage&subdirectory=foo/bar

However, it just hangs here and doesn't seem to respond.

Their documentation doesn't have an example of a multiple nested directory package path like that. However it does say, emphasis mine:

For projects where setup.py is not in the root of project, "subdirectory" component is used. Value of "subdirectory" component should be a path starting from root of the project to where setup.py is located

What does the properly formed installation from pip for a multiple-directory look like?

The above is returning errors such as:

  Could not find a tag or branch 'commit', assuming commit.
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    IOError: [Errno 2] No such file or directory: '/var/folders/wf/89r2567s5hv48lj1g9l65mbw0000gp/T/pip-gAwA3W-build/setup.py'

I see this using all versions of pip I tested (9.0.1 and 8.1.1).

Here is the detailed log:

$ pip install git+ssh://[email protected]/user/repo.git@hash#egg=projectname&subdirectory=lib/python
[1] 4195

Collecting projectname from git+ssh://[email protected]/user/repogit@hash#egg=projectname
  Cloning ssh://[email protected]/user/repo.git (to 8d109c760ae8a9599299924be1b78645e2617a50) to /private/var/folders/wf/89r2567s5hv48lj1g9l65mbw0000gp/T/pip-build-w01D4G/repo
  Could not find a tag or branch 'hash', assuming commit.
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    IOError: [Errno 2] No such file or directory: '/private/var/folders/wf/89r2567s5hv48lj1g9l65mbw0000gp/T/pip-build-w01D4G/repo/setup.py'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/wf/89r2567s5hv48lj1g9l65mbw0000gp/T/pip-build-w01D4G/repo/

[1]+  Exit 1                  pip install git+ssh://[email protected]/user/repo.git@hash#egg=projectname

It looks like after the initial subdirectory line where I call it, that part of the pip command is disappearing?

like image 288
enderland Avatar asked Dec 11 '22 14:12

enderland


1 Answers

When using multiple operators with pip, the entire argument needs to be enclosed in quotes:

pip install git+ssh://[email protected]/owner/repo-name.git@commithash#"egg=mypackage&subdirectory=foo/bar"

Otherwise, pip drops anything after the & and does not successfully recognize this.

like image 190
enderland Avatar answered Dec 31 '22 14:12

enderland