@@ -138,11 +138,15 @@ def _get_candidates(self, link, canonical_package_name):
138138 candidates = []
139139 path = self .get_path_for_link (link )
140140 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 )))
142143 # TODO remove legacy path lookup in pip>=21
143144 legacy_path = self .get_path_for_link_legacy (link )
144145 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+ )
146150 return candidates
147151
148152 def get_path_for_link_legacy (self , link ):
@@ -167,13 +171,6 @@ def get(
167171 """
168172 raise NotImplementedError ()
169173
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-
177174 def cleanup (self ):
178175 # type: () -> None
179176 pass
@@ -228,7 +225,9 @@ def get(
228225 return link
229226
230227 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+ ):
232231 try :
233232 wheel = Wheel (wheel_name )
234233 except InvalidWheelFilename :
@@ -245,13 +244,17 @@ def get(
245244 # Built for a different python/arch/etc
246245 continue
247246 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+ )
249252 )
250253
251254 if not candidates :
252255 return link
253256
254- return self . _link_for_candidate ( link , min (candidates )[1 ] )
257+ return Link ( path_to_url ( min (candidates )[2 ]) )
255258
256259
257260class EphemWheelCache (SimpleWheelCache ):
0 commit comments