From 2d09741ad67d4fabd94ce6ffd6257c5fec441c12 Mon Sep 17 00:00:00 2001 From: David Hotham Date: Sat, 17 Sep 2022 14:33:47 +0100 Subject: [PATCH] Prefer wheels over source distribution --- src/poetry/repositories/http.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/poetry/repositories/http.py b/src/poetry/repositories/http.py index c63f2b19281..0df9f139011 100644 --- a/src/poetry/repositories/http.py +++ b/src/poetry/repositories/http.py @@ -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 @@ -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])