Skip to content

Commit 4d28139

Browse files
committed
Attempt to fix uninstallation of zipped eggs
1 parent 6ef7731 commit 4d28139

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/pip/_internal/metadata/base.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,9 @@ def installed_as_egg(self) -> bool:
231231
location = self.location
232232
if not location:
233233
return False
234-
return location.endswith(".egg")
234+
# XXX if the distribution is a zipped egg, location has a trailing /
235+
# so we resort to pathlib.Path to check the suffix in a reliable way.
236+
return pathlib.Path(location).suffix == ".egg"
235237

236238
@property
237239
def installed_with_setuptools_egg_info(self) -> bool:

src/pip/_internal/req/req_uninstall.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -505,10 +505,13 @@ def from_dist(cls, dist: BaseDistribution) -> "UninstallPathSet":
505505
# package installed by easy_install
506506
# We cannot match on dist.egg_name because it can slightly vary
507507
# i.e. setuptools-0.6c11-py2.6.egg vs setuptools-0.6rc11-py2.6.egg
508-
paths_to_remove.add(dist_location)
509-
easy_install_egg = os.path.split(dist_location)[1]
508+
# XXX We use normalized_dist_location because dist_location my contain
509+
# a trailing / if the distribution is a zipped egg
510+
# (which is not a directory).
511+
paths_to_remove.add(normalized_dist_location)
512+
easy_install_egg = os.path.split(normalized_dist_location)[1]
510513
easy_install_pth = os.path.join(
511-
os.path.dirname(dist_location),
514+
os.path.dirname(normalized_dist_location),
512515
"easy-install.pth",
513516
)
514517
paths_to_remove.add_pth(easy_install_pth, "./" + easy_install_egg)

0 commit comments

Comments
 (0)