install of identical code fails if it's installing from a VCS subdirectory #1600

Closed
rory opened this Issue Feb 27, 2014 · 3 comments

2 participants

@rory

carrot is a AMQP messaging framework, and an editable install be done with pip:

pip install -e "git+https://github.com/ask/carrot.git#egg=carrot"

However, if I move the whole source code to a different subdirectory, you cannot install it using pip 1.5+'s new 'subdirectory' option.

Here's a recent fork of carrot, the only change I made was that I moved everything into my-carrot-subdirectory. Now when I try to install from that subdirectory I get this error:

$ pip install -e "git+https://github.com/rory/carrot.git#egg=carrot&subdirectory=my-carrot-subdirectory"
Obtaining carrot from git+https://github.com/rory/carrot.git#egg=carrot&subdirectory=my-carrot-subdirectory
  Cloning https://github.com/rory/carrot.git to /tmp/ve/src/carrot
  Running setup.py (path:/tmp/ve/src/carrot/my-carrot-subdirectory/setup.py) egg_info for package carrot
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/ve/src/carrot/my-carrot-subdirectory/setup.py", line 17, in <module>
        import carrot
    ImportError: No module named carrot
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/tmp/ve/src/carrot/my-carrot-subdirectory/setup.py", line 17, in <module>

    import carrot

ImportError: No module named carrot

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/ve/src/carrot
Storing debug log for failure in /home/rory/.pip/pip.log

It does not make sense that the same code should install fine without a subdirectory, but will fail with it.

@Ivoz
Python Packaging Authority member

As a side note, this can be avoided by avoiding the brittle practice of importing the package you're trying to install. i.e, import carrot.

It creates exactly the sort of problems you see here, e.g when setup.py isn't run from the current directory.

@rory

Maybe pip should cd to the subdirectory first?

@Ivoz
Python Packaging Authority member

@rory could you confirm that my pull #1601 works for you

Edit: tested myself, worksforme

 tmp-48226ea2f001540 ivo·ivosung ~/.virtualenvs/tmp-48226ea2f001540 » pip list
pip (1.6.dev1, /home/ivo/code/pypa/pip)
setuptools (2.2)
 tmp-48226ea2f001540 ivo·ivosung ~/.virtualenvs/tmp-48226ea2f001540 » pip install -e "git+https://github.com/ask/carrot.git#egg=carrot"
Obtaining carrot from git+https://github.com/ask/carrot.git#egg=carrot
  Cloning https://github.com/ask/carrot.git to ./src/carrot
  Running setup.py (path:/home/ivo/.virtualenvs/tmp-48226ea2f001540/src/carrot/setup.py) egg_info for package carrot

  Installing extra requirements: 'egg'
Downloading/unpacking anyjson (from carrot)
  Downloading anyjson-0.3.3.tar.gz
  Running setup.py (path:/home/ivo/.virtualenvs/tmp-48226ea2f001540/build/anyjson/setup.py) egg_info for package anyjson

Downloading/unpacking amqplib>=0.6 (from carrot)
  Downloading amqplib-1.0.2.tgz (58kB): 58kB downloaded
  Running setup.py (path:/home/ivo/.virtualenvs/tmp-48226ea2f001540/build/amqplib/setup.py) egg_info for package amqplib

Installing collected packages: carrot, anyjson, amqplib
  Running setup.py develop for carrot

    Creating /home/ivo/.virtualenvs/tmp-48226ea2f001540/lib/python2.7/site-packages/carrot.egg-link (link to .)
    Adding carrot 0.10.7 to easy-install.pth file

    Installed /home/ivo/.virtualenvs/tmp-48226ea2f001540/src/carrot
  Running setup.py install for anyjson

  Running setup.py install for amqplib

Successfully installed carrot anyjson amqplib
Cleaning up...
@qwcode qwcode closed this in #1601 Mar 11, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment