11
11
from pip ._internal .utils .compat import WINDOWS
12
12
from pip ._internal .utils .egg_link import egg_link_path_from_location
13
13
from pip ._internal .utils .logging import getLogger , indent_log
14
- from pip ._internal .utils .misc import ask , is_local , normalize_path , renames , rmtree
14
+ from pip ._internal .utils .misc import ask , is_local , normalize_path , normalize_path_cached , renames , rmtree
15
15
from pip ._internal .utils .temp_dir import AdjacentTempDirectory , TempDirectory
16
16
17
17
logger = getLogger (__name__ )
@@ -312,6 +312,7 @@ def __init__(self, dist: BaseDistribution) -> None:
312
312
self ._pth : Dict [str , UninstallPthEntries ] = {}
313
313
self ._dist = dist
314
314
self ._moved_paths = StashedUninstallPathSet ()
315
+ normalize_path_cached .cache_clear ()
315
316
316
317
def _permitted (self , path : str ) -> bool :
317
318
"""
@@ -326,7 +327,7 @@ def add(self, path: str) -> None:
326
327
327
328
# we normalize the head to resolve parent directory symlinks, but not
328
329
# the tail, since we only want to uninstall symlinks, not their targets
329
- path = os .path .join (normalize_path (head ), os .path .normcase (tail ))
330
+ path = os .path .join (normalize_path_cached (head ), os .path .normcase (tail ))
330
331
331
332
if not os .path .exists (path ):
332
333
return
@@ -341,7 +342,7 @@ def add(self, path: str) -> None:
341
342
self .add (cache_from_source (path ))
342
343
343
344
def add_pth (self , pth_file : str , entry : str ) -> None :
344
- pth_file = normalize_path (pth_file )
345
+ pth_file = normalize_path_cached (pth_file )
345
346
if self ._permitted (pth_file ):
346
347
if pth_file not in self ._pth :
347
348
self ._pth [pth_file ] = UninstallPthEntries (pth_file )
@@ -434,7 +435,7 @@ def from_dist(cls, dist: BaseDistribution) -> "UninstallPathSet":
434
435
)
435
436
return cls (dist )
436
437
437
- normalized_dist_location = normalize_path (dist_location )
438
+ normalized_dist_location = normalize_path_cached (dist_location )
438
439
if not dist .local :
439
440
logger .info (
440
441
"Not uninstalling %s at %s, outside environment %s" ,
@@ -531,7 +532,7 @@ def from_dist(cls, dist: BaseDistribution) -> "UninstallPathSet":
531
532
# above, so this only covers the setuptools-style editable.
532
533
with open (develop_egg_link ) as fh :
533
534
link_pointer = os .path .normcase (fh .readline ().strip ())
534
- normalized_link_pointer = normalize_path (link_pointer )
535
+ normalized_link_pointer = normalize_path_cached (link_pointer )
535
536
assert os .path .samefile (
536
537
normalized_link_pointer , normalized_dist_location
537
538
), (
0 commit comments