@@ -138,11 +138,15 @@ def _get_candidates(self, link, canonical_package_name):
138
138
candidates = []
139
139
path = self .get_path_for_link (link )
140
140
if os .path .isdir (path ):
141
- candidates .extend (os .listdir (path ))
141
+ for candidate in os .listdir (path ):
142
+ candidates .append ((candidate , os .path .join (path , candidate )))
142
143
# TODO remove legacy path lookup in pip>=21
143
144
legacy_path = self .get_path_for_link_legacy (link )
144
145
if os .path .isdir (legacy_path ):
145
- candidates .extend (os .listdir (legacy_path ))
146
+ for candidate in os .listdir (legacy_path ):
147
+ candidates .append (
148
+ (candidate , os .path .join (legacy_path , candidate ))
149
+ )
146
150
return candidates
147
151
148
152
def get_path_for_link_legacy (self , link ):
@@ -167,13 +171,6 @@ def get(
167
171
"""
168
172
raise NotImplementedError ()
169
173
170
- def _link_for_candidate (self , link , candidate ):
171
- # type: (Link, str) -> Link
172
- root = self .get_path_for_link (link )
173
- path = os .path .join (root , candidate )
174
-
175
- return Link (path_to_url (path ))
176
-
177
174
def cleanup (self ):
178
175
# type: () -> None
179
176
pass
@@ -228,7 +225,9 @@ def get(
228
225
return link
229
226
230
227
canonical_package_name = canonicalize_name (package_name )
231
- for wheel_name in self ._get_candidates (link , canonical_package_name ):
228
+ for wheel_name , wheel_path in self ._get_candidates (
229
+ link , canonical_package_name
230
+ ):
232
231
try :
233
232
wheel = Wheel (wheel_name )
234
233
except InvalidWheelFilename :
@@ -245,13 +244,17 @@ def get(
245
244
# Built for a different python/arch/etc
246
245
continue
247
246
candidates .append (
248
- (wheel .support_index_min (supported_tags ), wheel_name )
247
+ (
248
+ wheel .support_index_min (supported_tags ),
249
+ wheel_name ,
250
+ wheel_path ,
251
+ )
249
252
)
250
253
251
254
if not candidates :
252
255
return link
253
256
254
- return self . _link_for_candidate ( link , min (candidates )[1 ] )
257
+ return Link ( path_to_url ( min (candidates )[2 ]) )
255
258
256
259
257
260
class EphemWheelCache (SimpleWheelCache ):
0 commit comments