mirror of https://github.com/pypa/pip
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
|
@ -557,32 +557,27 @@ exec(compile(
|
|||
dist = self.satisfied_by or self.conflicts_with
|
||||
|
||||
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)
|
||||
|
||||
pip_egg_info_exists = os.path.exists(pip_egg_info_path)
|
||||
debian_egg_info_exists = os.path.exists(debian_egg_info_path)
|
||||
dist_info_exists = os.path.exists(dist_info_path)
|
||||
if pip_egg_info_exists or debian_egg_info_exists:
|
||||
# package installed by pip
|
||||
if pip_egg_info_exists:
|
||||
egg_info_path = pip_egg_info_path
|
||||
else:
|
||||
egg_info_path = debian_egg_info_path
|
||||
paths_to_remove.add(egg_info_path)
|
||||
egg_info_exists = dist.egg_info and os.path.exists(dist.egg_info)
|
||||
if develop_egg_link:
|
||||
# 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 egg_info_exists and dist.egg_info.endswith('.egg-info'):
|
||||
paths_to_remove.add(dist.egg_info)
|
||||
if dist.has_metadata('installed-files.txt'):
|
||||
for installed_file in dist.get_metadata(
|
||||
'installed-files.txt').splitlines():
|
||||
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)
|
||||
# FIXME: need a test for this elif block
|
||||
|
@ -612,19 +607,7 @@ exec(compile(
|
|||
'easy-install.pth')
|
||||
paths_to_remove.add_pth(easy_install_pth, './' + easy_install_egg)
|
||||
|
||||
elif develop_egg_link:
|
||||
# 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:
|
||||
elif egg_info_exists and dist.egg_info.endswith('.dist-info'):
|
||||
for path in pip.wheel.uninstallation_paths(dist):
|
||||
paths_to_remove.add(path)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue