@@ -102,12 +102,18 @@ def _get_info_from_sdist(self, url: str) -> PackageInfo:
102
102
return PackageInfo .from_sdist (filepath )
103
103
104
104
def _get_info_from_urls (self , urls : dict [str , list [str ]]) -> PackageInfo :
105
- # Checking wheels first as they are more likely to hold
106
- # the necessary information
107
- if "bdist_wheel" in urls :
108
- # Check for a universal wheel
109
- wheels = urls ["bdist_wheel" ]
110
-
105
+ # Prefer to read data from wheels: this is faster and more reliable
106
+ wheels = urls .get ("bdist_wheel" )
107
+ if wheels :
108
+ # We ought just to be able to look at any of the available wheels to read
109
+ # metadata, they all should give the same answer.
110
+ #
111
+ # In practice this hasn't always been true.
112
+ #
113
+ # Most of the code in here is to deal with cases such as isort 4.3.4 which
114
+ # published separate python3 and python2 wheels with quite different
115
+ # dependencies. We try to detect such cases and combine the data from the
116
+ # two wheels into what ought to have been published in the first place...
111
117
universal_wheel = None
112
118
universal_python2_wheel = None
113
119
universal_python3_wheel = None
@@ -195,9 +201,9 @@ def _get_info_from_urls(self, urls: dict[str, list[str]]) -> PackageInfo:
195
201
if universal_python2_wheel :
196
202
return self ._get_info_from_wheel (universal_python2_wheel )
197
203
198
- if platform_specific_wheels and "sdist" not in urls :
199
- # Pick the first wheel available and hope for the best
200
- return self ._get_info_from_wheel (platform_specific_wheels [ 0 ] )
204
+ if platform_specific_wheels :
205
+ first_wheel = platform_specific_wheels [ 0 ]
206
+ return self ._get_info_from_wheel (first_wheel )
201
207
202
208
return self ._get_info_from_sdist (urls ["sdist" ][0 ])
203
209
0 commit comments