6
6
import logging
7
7
import os
8
8
from pathlib import Path
9
- from typing import Any , Dict , List , Optional , Set
9
+ from typing import Any , Dict , List , Optional
10
10
11
11
from pip ._vendor .packaging .tags import Tag , interpreter_name , interpreter_version
12
12
from pip ._vendor .packaging .utils import canonicalize_name
13
13
14
14
from pip ._internal .exceptions import InvalidWheelFilename
15
15
from pip ._internal .models .direct_url import DirectUrl
16
- from pip ._internal .models .format_control import FormatControl
17
16
from pip ._internal .models .link import Link
18
17
from pip ._internal .models .wheel import Wheel
19
18
from pip ._internal .utils .temp_dir import TempDirectory , tempdir_kinds
@@ -33,25 +32,13 @@ def _hash_dict(d: Dict[str, str]) -> str:
33
32
class Cache :
34
33
"""An abstract class - provides cache directories for data from links
35
34
36
-
37
35
:param cache_dir: The root of the cache.
38
- :param format_control: An object of FormatControl class to limit
39
- binaries being read from the cache.
40
- :param allowed_formats: which formats of files the cache should store.
41
- ('binary' and 'source' are the only allowed values)
42
36
"""
43
37
44
- def __init__ (
45
- self , cache_dir : str , format_control : FormatControl , allowed_formats : Set [str ]
46
- ) -> None :
38
+ def __init__ (self , cache_dir : str ) -> None :
47
39
super ().__init__ ()
48
40
assert not cache_dir or os .path .isabs (cache_dir )
49
41
self .cache_dir = cache_dir or None
50
- self .format_control = format_control
51
- self .allowed_formats = allowed_formats
52
-
53
- _valid_formats = {"source" , "binary" }
54
- assert self .allowed_formats .union (_valid_formats ) == _valid_formats
55
42
56
43
def _get_cache_path_parts (self , link : Link ) -> List [str ]:
57
44
"""Get parts of part that must be os.path.joined with cache_dir"""
@@ -91,10 +78,6 @@ def _get_candidates(self, link: Link, canonical_package_name: str) -> List[Any]:
91
78
if can_not_cache :
92
79
return []
93
80
94
- formats = self .format_control .get_allowed_formats (canonical_package_name )
95
- if not self .allowed_formats .intersection (formats ):
96
- return []
97
-
98
81
candidates = []
99
82
path = self .get_path_for_link (link )
100
83
if os .path .isdir (path ):
@@ -121,8 +104,8 @@ def get(
121
104
class SimpleWheelCache (Cache ):
122
105
"""A cache of wheels for future installs."""
123
106
124
- def __init__ (self , cache_dir : str , format_control : FormatControl ) -> None :
125
- super ().__init__ (cache_dir , format_control , { "binary" } )
107
+ def __init__ (self , cache_dir : str ) -> None :
108
+ super ().__init__ (cache_dir )
126
109
127
110
def get_path_for_link (self , link : Link ) -> str :
128
111
"""Return a directory to store cached wheels for link
@@ -191,13 +174,13 @@ def get(
191
174
class EphemWheelCache (SimpleWheelCache ):
192
175
"""A SimpleWheelCache that creates it's own temporary cache directory"""
193
176
194
- def __init__ (self , format_control : FormatControl ) -> None :
177
+ def __init__ (self ) -> None :
195
178
self ._temp_dir = TempDirectory (
196
179
kind = tempdir_kinds .EPHEM_WHEEL_CACHE ,
197
180
globally_managed = True ,
198
181
)
199
182
200
- super ().__init__ (self ._temp_dir .path , format_control )
183
+ super ().__init__ (self ._temp_dir .path )
201
184
202
185
203
186
class CacheEntry :
@@ -221,14 +204,10 @@ class WheelCache(Cache):
221
204
when a certain link is not found in the simple wheel cache first.
222
205
"""
223
206
224
- def __init__ (
225
- self , cache_dir : str , format_control : Optional [FormatControl ] = None
226
- ) -> None :
227
- if format_control is None :
228
- format_control = FormatControl ()
229
- super ().__init__ (cache_dir , format_control , {"binary" })
230
- self ._wheel_cache = SimpleWheelCache (cache_dir , format_control )
231
- self ._ephem_cache = EphemWheelCache (format_control )
207
+ def __init__ (self , cache_dir : str ) -> None :
208
+ super ().__init__ (cache_dir )
209
+ self ._wheel_cache = SimpleWheelCache (cache_dir )
210
+ self ._ephem_cache = EphemWheelCache ()
232
211
233
212
def get_path_for_link (self , link : Link ) -> str :
234
213
return self ._wheel_cache .get_path_for_link (link )
0 commit comments