Skip to content

Commit 8a1b5bf

Browse files
dimblebyneersighted
authored andcommitted
Prefer wheels over source distribution
1 parent cc97101 commit 8a1b5bf

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/poetry/repositories/http.py

+15-9
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,18 @@ def _get_info_from_sdist(self, url: str) -> PackageInfo:
102102
return PackageInfo.from_sdist(filepath)
103103

104104
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...
111117
universal_wheel = None
112118
universal_python2_wheel = None
113119
universal_python3_wheel = None
@@ -195,9 +201,9 @@ def _get_info_from_urls(self, urls: dict[str, list[str]]) -> PackageInfo:
195201
if universal_python2_wheel:
196202
return self._get_info_from_wheel(universal_python2_wheel)
197203

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)
201207

202208
return self._get_info_from_sdist(urls["sdist"][0])
203209

0 commit comments

Comments
 (0)