Fix `pip install --user` when upgrading an existing system package. #704

Closed
wants to merge 1 commit into
from

Projects

None yet

4 participants

@eevee
eevee commented Oct 16, 2012

I'm on a machine with old system packages and I want to install newer versions in my user-site. Despite all the recent work on --user, no combination of --upgrade and --ignore-installed completed successfully; pip would always try to remove the system package and, naturally, fail.

This is a somewhat dumb patch that fixes the behavior for me. I can't imagine how to write a test for it, and the existing user-site tests confirm this is unsupported, but it's simple enough.

(fwiw, the existing code didn't cover this case because while check_if_exists has some use_user_site guards, they only come into play when there's a version conflict; a simple upgrade instead causes an assignment to .satisfied_by, which is later assigned to .conflicts_with and then triggers the uninstallation.)

@qwcode
Collaborator
qwcode commented Oct 16, 2012

thanks for reporting. I'll look at this later tonight.

@qwcode
Collaborator
qwcode commented Oct 17, 2012

yes, this scenario got overlooked (using --user and --upgrade together).
I'll probably tweak your fix and add a test tomorrow.
I assume you know you can successfully use:
pip install --user pkg==version (of course you have to go find the latest version)
thanks again.

@qwcode
Collaborator
qwcode commented Oct 18, 2012

close due to fix in pull #705

@qwcode qwcode closed this Oct 18, 2012
@eevee
eevee commented Oct 18, 2012

awesome, thanks!

@reece
reece commented Nov 20, 2012

1.2.1 works as advertised with --user --upgrade. Thanks!

@glyph
glyph commented Dec 14, 2012

I could have sworn that this worked somewhere, but I am now seeing the same error with 1.2.1:

glyph@jaina:~/tmp★ pip --version
 ↩ Fri Dec 14 12:38:32 PST 2012
pip 1.2.1 from ~/Library/Python/2.7/lib/python/site-packages (python 2.7)
 ↪ Fri Dec 14 12:38:32 PST 2012 (★ pip --version)
glyph@jaina:~/tmp★ pip install --user --upgrade --ignore-installed zope.interface
 ↩ Fri Dec 14 12:39:07 PST 2012
Downloading/unpacking zope.interface
  Running setup.py egg_info for package zope.interface

Downloading/unpacking setuptools (from zope.interface)
  Downloading setuptools-0.6c12dev-r88846.tar.gz (257kB): 257kB downloaded
  Running setup.py egg_info for package setuptools

Installing collected packages: zope.interface, setuptools
  Found existing installation: zope.interface 3.5.1
    Uninstalling zope.interface:
Exception:
Traceback (most recent call last):
  File ".../pip/basecommand.py", line 107, in main
    status = self.run(options, args)
  File ".../pip/commands/install.py", line 261, in run
    requirement_set.install(install_options, global_options)
  File ".../pip/req.py", line 1162, in install
    requirement.uninstall(auto_confirm=True)
  File ".../pip/req.py", line 495, in uninstall
    paths_to_remove.remove(auto_confirm)
  File ".../pip/req.py", line 1492, in remove
    renames(path, new_path)
  File ".../pip/util.py", line 273, in renames
    shutil.move(old, new)
  File ".../shutil.py", line 296, in move
    rmtree(src)
  File ".../shutil.py", line 249, in rmtree
    onerror(os.remove, fullname, sys.exc_info())
  File ".../shutil.py", line 247, in rmtree
    os.remove(fullname)
OSError: [Errno 13] Permission denied: '.../zope/__init__.py'

Storing complete log in ~/Library/Logs/pip.log
 ↪ Fri Dec 14 12:39:10 PST 2012 (★ pip install --user --upgrade --ignore-installed zope.interface) (3 seconds elapsed)
[Error: 2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment