Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit 7598e8f4df876e17a55479c97b79a52cd3534dc4 1 parent 40ec94f
@eevee authored
Showing with 8 additions and 2 deletions.
  1. +8 −2 pip/req.py
View
10 pip/req.py
@@ -417,7 +417,7 @@ def uninstall(self, auto_confirm=False):
raise UninstallationError("Cannot uninstall requirement %s, not installed" % (self.name,))
dist = self.satisfied_by or self.conflicts_with
- paths_to_remove = UninstallPathSet(dist)
+ paths_to_remove = UninstallPathSet(dist, use_user_site=self.use_user_site)
pip_egg_info_path = os.path.join(dist.location,
dist.egg_name()) + '.egg-info'
@@ -1405,13 +1405,14 @@ def parse_editable(editable_req, default_vcs=None):
class UninstallPathSet(object):
"""A set of file paths to be removed in the uninstallation of a
requirement."""
- def __init__(self, dist):
+ def __init__(self, dist, use_user_site=False):
self.paths = set()
self._refuse = set()
self.pth = {}
self.dist = dist
self.save_dir = None
self._moved_paths = []
+ self.use_user_site = use_user_site
def _permitted(self, path):
"""
@@ -1426,6 +1427,11 @@ def _can_uninstall(self):
logger.notify("Not uninstalling %s at %s, outside environment %s"
% (self.dist.project_name, normalize_path(self.dist.location), sys.prefix))
return False
+ if self.use_user_site and not dist_in_usersite(self.dist):
+ logger.notify("Not uninstalling %s at %s, not in user site-packages"
+ % (self.dist.project_name, normalize_path(self.dist.location)))
+ return False
+
return True
def add(self, path):
Please sign in to comment.
Something went wrong with that request. Please try again.