diff --git a/news/5439.bugfix b/news/5439.bugfix new file mode 100644 index 00000000000..f0a7838a36a --- /dev/null +++ b/news/5439.bugfix @@ -0,0 +1 @@ +Handle symlinks in req_uninstall.py diff --git a/src/pip/_internal/req/req_uninstall.py b/src/pip/_internal/req/req_uninstall.py index a3cc7bf66b5..b6b136f21ee 100644 --- a/src/pip/_internal/req/req_uninstall.py +++ b/src/pip/_internal/req/req_uninstall.py @@ -19,6 +19,12 @@ ) from pip._internal.utils.temp_dir import TempDirectory +if sys.version_info >= (3, 2): + samefile = os.path.samefile +else: + def samefile(self, other): + return os.stat(self) == os.stat(other) + logger = logging.getLogger(__name__) @@ -359,7 +365,7 @@ def from_dist(cls, dist): # develop egg with open(develop_egg_link, 'r') as fh: link_pointer = os.path.normcase(fh.readline().strip()) - assert (link_pointer == dist.location), ( + assert (samefile(link_pointer, dist.location)), ( 'Egg-link %s does not match installed location of %s ' '(at %s)' % (link_pointer, dist.project_name, dist.location) )