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.)
Fix `pip install --user` when upgrading an existing system package.
thanks for reporting. I'll look at this later tonight.
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)
pip install --user pkg==version
close due to fix in pull #705
1.2.1 works as advertised with --user --upgrade. Thanks!
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
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
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
File ".../pip/req.py", line 1162, in install
File ".../pip/req.py", line 495, in uninstall
File ".../pip/req.py", line 1492, in remove
File ".../pip/util.py", line 273, in renames
File ".../shutil.py", line 296, in move
File ".../shutil.py", line 249, in rmtree
onerror(os.remove, fullname, sys.exc_info())
File ".../shutil.py", line 247, in rmtree
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)