Skip to content

Pip fails to clean up build/ files after egg_info exception, preventing re|un-installation #602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ejucovy opened this issue Jul 15, 2012 · 1 comment
Labels
auto-locked Outdated issues that have been locked by automation type: bug A confirmed bug or unintended behavior

Comments

@ejucovy
Copy link

ejucovy commented Jul 15, 2012

If you try to install a package whose setup.py egg_info causes a SyntaxError, pip doesn't catch that exception, and terminates without cleaning up the partial installation in build/. This will then prevent any subsequent installation of that package, because pip will always detect that partial installation, try to run egg_info on it, and terminate again with a SyntaxError.

Pip should probably catch the errors in both of those cases. In the first step, it should probably remove the failed installation from build/ and exit with a nicer error message. In the second step, if bad files somehow still exist in build/, it should probably catch exceptions in egg_info and proceed as though no existing files were in build/; or perhaps ask the user whether it should remove the files or cancel the command altogether.

This can be reproduced by installing a non-python-2.4-compatible package in a py2.4 environment, and then trying to install an earlier py2.4-compatible version of the same package. For example:

$ virtualenv.py --python=python2.4 /tmp/django24
$ /tmp/django24/bin/pip install Django
(tmpv)egj@alcibiades:/tmp$ /tmp/django24/bin/pip install Django
Downloading/unpacking Django
  Downloading Django-1.4.tar.gz (7.6Mb): 7.6Mb downloaded
  Running setup.py egg_info for package Django
    Traceback (most recent call last):
      File "<string>", line 14, in ?
      File "/tmp/django24/build/Django/setup.py", line 69, in ?
        version = __import__('django').get_version()
      File "django/__init__.py", line 15
        parts = 2 if version[2] == 0 else 3
                   ^
    SyntaxError: invalid syntax
----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in /home/egj/.pip/pip.log

$ ls /tmp/django24/build/
Django  pip-delete-this-directory.txt

$ /tmp/django24/bin/pip install Django==1.2
Downloading/unpacking Django==1.2
  Running setup.py egg_info for package Django
    Traceback (most recent call last):
      File "<string>", line 14, in ?
      File "/tmp/django24/build/Django/setup.py", line 69, in ?
        version = __import__('django').get_version()
      File "django/__init__.py", line 15
        parts = 2 if version[2] == 0 else 3
               ^
    SyntaxError: invalid syntax
----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in /home/egj/.pip/pip.log

You can't uninstall it because it never finished getting installed:

$ /tmp/django24/bin/pip uninstall Django
Cannot uninstall requirement Django, not installed
Storing complete log in /home/egj/.pip/pip.log

So you have to (know how to) remove the partial installation yourself to proceed:

$ rm -rf /tmp/django24/build/
$ /tmp/django24/bin/pip install Django==1.2
Downloading/unpacking Django==1.2
  Downloading Django-1.2.tar.gz (6.2Mb): 6.2Mb downloaded
  Running setup.py egg_info for package Django
    warning: no files found matching '*' under directory 'examples'
Installing collected packages: Django
  Running setup.py install for Django
    changing mode of build/scripts-2.4/django-admin.py from 644 to 755
    warning: no files found matching '*' under directory 'examples'
changing mode of /tmp/django24/bin/django-admin.py to 755
Successfully installed Django
Cleaning up...
@qwcode
Copy link
Contributor

qwcode commented Apr 20, 2013

closing due to merge of #865

@qwcode qwcode closed this as completed Apr 20, 2013
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 6, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants