Skip to content

Commit

Permalink
Prefer wheels over source distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby committed Sep 17, 2022
1 parent d8c05c3 commit abe852b
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/poetry/repositories/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,18 @@ def _get_info_from_sdist(self, url: str) -> PackageInfo:
return PackageInfo.from_sdist(filepath)

def _get_info_from_urls(self, urls: dict[str, list[str]]) -> PackageInfo:
# Checking wheels first as they are more likely to hold
# the necessary information
if "bdist_wheel" in urls:
# Check for a universal wheel
wheels = urls["bdist_wheel"]

# Prefer to read data from wheels: this is faster and more reliable
wheels = urls.get("bdist_wheel")
if wheels:
# We ought just to be able to look at any of the available wheels to read
# metadata, they all should give the same answer.
#
# In practice this hasn't always been true.
#
# Most of the code in here is to deal with cases such as isort 4.3.4 which
# published separate python3 and python2 wheels with quite different
# dependencies. We try to detect such cases and combine the data from the
# two wheels into what ought to have been published in the first place...
universal_wheel = None
universal_python2_wheel = None
universal_python3_wheel = None
Expand Down Expand Up @@ -195,9 +201,9 @@ def _get_info_from_urls(self, urls: dict[str, list[str]]) -> PackageInfo:
if universal_python2_wheel:
return self._get_info_from_wheel(universal_python2_wheel)

if platform_specific_wheels and "sdist" not in urls:
# Pick the first wheel available and hope for the best
return self._get_info_from_wheel(platform_specific_wheels[0])
if platform_specific_wheels:
first_wheel = platform_specific_wheels[0]
return self._get_info_from_wheel(first_wheel)

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

Expand Down

0 comments on commit abe852b

Please sign in to comment.