mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
change uninstallation logic
check develop_egg_link case first and map distribution types based on dist.egg_info attribute close #2346 #2348 #2350
This commit is contained in:
parent
a0cd939a12
commit
c509c5c4ab
1 changed files with 17 additions and 34 deletions
|
@ -557,32 +557,27 @@ exec(compile(
|
||||||
dist = self.satisfied_by or self.conflicts_with
|
dist = self.satisfied_by or self.conflicts_with
|
||||||
|
|
||||||
paths_to_remove = UninstallPathSet(dist)
|
paths_to_remove = UninstallPathSet(dist)
|
||||||
|
|
||||||
pip_egg_info_path = os.path.join(dist.location,
|
|
||||||
dist.egg_name()) + '.egg-info'
|
|
||||||
dist_info_path = os.path.join(dist.location,
|
|
||||||
'-'.join(dist.egg_name().split('-')[:2])
|
|
||||||
) + '.dist-info'
|
|
||||||
# Workaround - http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=618367
|
|
||||||
debian_egg_info_path = pip_egg_info_path.replace(
|
|
||||||
'-py%s' % pkg_resources.PY_MAJOR, '')
|
|
||||||
develop_egg_link = egg_link_path(dist)
|
develop_egg_link = egg_link_path(dist)
|
||||||
|
egg_info_exists = dist.egg_info and os.path.exists(dist.egg_info)
|
||||||
pip_egg_info_exists = os.path.exists(pip_egg_info_path)
|
if develop_egg_link:
|
||||||
debian_egg_info_exists = os.path.exists(debian_egg_info_path)
|
# develop egg
|
||||||
dist_info_exists = os.path.exists(dist_info_path)
|
with open(develop_egg_link, 'r') as fh:
|
||||||
if pip_egg_info_exists or debian_egg_info_exists:
|
link_pointer = os.path.normcase(fh.readline().strip())
|
||||||
# package installed by pip
|
assert (link_pointer == dist.location), (
|
||||||
if pip_egg_info_exists:
|
'Egg-link %s does not match installed location of %s '
|
||||||
egg_info_path = pip_egg_info_path
|
'(at %s)' % (link_pointer, self.name, dist.location)
|
||||||
else:
|
)
|
||||||
egg_info_path = debian_egg_info_path
|
paths_to_remove.add(develop_egg_link)
|
||||||
paths_to_remove.add(egg_info_path)
|
easy_install_pth = os.path.join(os.path.dirname(develop_egg_link),
|
||||||
|
'easy-install.pth')
|
||||||
|
paths_to_remove.add_pth(easy_install_pth, dist.location)
|
||||||
|
elif egg_info_exists and dist.egg_info.endswith('.egg-info'):
|
||||||
|
paths_to_remove.add(dist.egg_info)
|
||||||
if dist.has_metadata('installed-files.txt'):
|
if dist.has_metadata('installed-files.txt'):
|
||||||
for installed_file in dist.get_metadata(
|
for installed_file in dist.get_metadata(
|
||||||
'installed-files.txt').splitlines():
|
'installed-files.txt').splitlines():
|
||||||
path = os.path.normpath(
|
path = os.path.normpath(
|
||||||
os.path.join(egg_info_path, installed_file)
|
os.path.join(dist.egg_info, installed_file)
|
||||||
)
|
)
|
||||||
paths_to_remove.add(path)
|
paths_to_remove.add(path)
|
||||||
# FIXME: need a test for this elif block
|
# FIXME: need a test for this elif block
|
||||||
|
@ -612,19 +607,7 @@ exec(compile(
|
||||||
'easy-install.pth')
|
'easy-install.pth')
|
||||||
paths_to_remove.add_pth(easy_install_pth, './' + easy_install_egg)
|
paths_to_remove.add_pth(easy_install_pth, './' + easy_install_egg)
|
||||||
|
|
||||||
elif develop_egg_link:
|
elif egg_info_exists and dist.egg_info.endswith('.dist-info'):
|
||||||
# develop egg
|
|
||||||
with open(develop_egg_link, 'r') as fh:
|
|
||||||
link_pointer = os.path.normcase(fh.readline().strip())
|
|
||||||
assert (link_pointer == dist.location), (
|
|
||||||
'Egg-link %s does not match installed location of %s '
|
|
||||||
'(at %s)' % (link_pointer, self.name, dist.location)
|
|
||||||
)
|
|
||||||
paths_to_remove.add(develop_egg_link)
|
|
||||||
easy_install_pth = os.path.join(os.path.dirname(develop_egg_link),
|
|
||||||
'easy-install.pth')
|
|
||||||
paths_to_remove.add_pth(easy_install_pth, dist.location)
|
|
||||||
elif dist_info_exists:
|
|
||||||
for path in pip.wheel.uninstallation_paths(dist):
|
for path in pip.wheel.uninstallation_paths(dist):
|
||||||
paths_to_remove.add(path)
|
paths_to_remove.add(path)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue