21
21
InstalledWheelDir ,
22
22
VenvDirs ,
23
23
)
24
- from pex .cache .prunable import Prunable , PrunablePipCache
24
+ from pex .cache .prunable import Prunable
25
25
from pex .cli .command import BuildTimeCommand
26
26
from pex .cli .commands .cache .bytes import ByteAmount , ByteUnits
27
27
from pex .cli .commands .cache .du import DiskUsage
33
33
from pex .orderedset import OrderedSet
34
34
from pex .pep_440 import Version
35
35
from pex .pep_503 import ProjectName
36
+ from pex .pip .tool import Pip
36
37
from pex .result import Error , Ok , Result
37
38
from pex .typing import TYPE_CHECKING
38
39
from pex .variables import ENV
@@ -629,21 +630,21 @@ def prune_pip_caches():
629
630
if not prunable_wheels :
630
631
return
631
632
632
- def spawn_list (prunable_pip_cache ):
633
- # type: (PrunablePipCache ) -> SpawnedJob[Tuple[ProjectNameAndVersion, ...]]
633
+ def spawn_list (pip ):
634
+ # type: (Pip ) -> SpawnedJob[Tuple[ProjectNameAndVersion, ...]]
634
635
return SpawnedJob .stdout (
635
- job = prunable_pip_cache . pip .spawn_cache_list (),
636
+ job = pip .spawn_cache_list (),
636
637
result_func = lambda stdout : tuple (
637
638
ProjectNameAndVersion .from_filename (wheel_file )
638
639
for wheel_file in stdout .decode ("utf-8" ).splitlines ()
639
640
if wheel_file
640
641
),
641
642
)
642
643
643
- pip_removes = [] # type: List[Tuple[PrunablePipCache , str]]
644
- for prunable_pip_cache , project_name_and_versions in zip (
645
- prunable .pips .caches ,
646
- execute_parallel (inputs = prunable .pips .caches , spawn_func = spawn_list ),
644
+ pip_removes = [] # type: List[Tuple[Pip , str]]
645
+ for pip , project_name_and_versions in zip (
646
+ prunable .pips .pips ,
647
+ execute_parallel (inputs = prunable .pips .pips , spawn_func = spawn_list ),
647
648
):
648
649
for pnav in project_name_and_versions :
649
650
if (
@@ -652,7 +653,7 @@ def spawn_list(prunable_pip_cache):
652
653
) in prunable_wheels :
653
654
pip_removes .append (
654
655
(
655
- prunable_pip_cache ,
656
+ pip ,
656
657
"{project_name}-{version}*" .format (
657
658
project_name = pnav .project_name , version = pnav .version
658
659
),
@@ -673,22 +674,19 @@ def parse_remove(stdout):
673
674
return 0
674
675
675
676
def spawn_remove (args ):
676
- # type: (Tuple[PrunablePipCache , str]) -> SpawnedJob[int]
677
- prunable_pip_cache , wheel_name_glob = args
677
+ # type: (Tuple[Pip , str]) -> SpawnedJob[int]
678
+ pip , wheel_name_glob = args
678
679
return SpawnedJob .stdout (
679
- job = prunable_pip_cache . pip .spawn_cache_remove (wheel_name_glob ),
680
+ job = pip .spawn_cache_remove (wheel_name_glob ),
680
681
result_func = parse_remove ,
681
682
)
682
683
683
684
removes_by_pip = Counter () # type: typing.Counter[str]
684
- for prunable_pip_cache , remove_count in zip (
685
- [prunable_pip_cache for prunable_pip_cache , _ in pip_removes ],
685
+ for pip , remove_count in zip (
686
+ [pip for pip , _ in pip_removes ],
686
687
execute_parallel (inputs = pip_removes , spawn_func = spawn_remove ),
687
688
):
688
- removes_by_pip [prunable_pip_cache .pip .version .value ] += remove_count
689
- cache_access .record_access (
690
- prunable_pip_cache .pex_dir , last_access = prunable_pip_cache .last_access
691
- )
689
+ removes_by_pip [pip .version .value ] += remove_count
692
690
if removes_by_pip :
693
691
total = sum (removes_by_pip .values ())
694
692
print (
0 commit comments