From b4b50d5f677afca4ddbff4bbb3f58c8724e6e3db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Gia=20Phong?= Date: Tue, 25 Aug 2020 22:06:44 +0700 Subject: [PATCH] [fast-deps] Check download directory before making requests --- src/pip/_internal/operations/prepare.py | 27 ++++++++++++------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/pip/_internal/operations/prepare.py b/src/pip/_internal/operations/prepare.py index 5eb71ce073f..ccc92fc9f69 100644 --- a/src/pip/_internal/operations/prepare.py +++ b/src/pip/_internal/operations/prepare.py @@ -486,26 +486,25 @@ def prepare_linked_requirement(self, req, parallel_builds=False): link = req.link self._log_preparing_link(req) with indent_log(): - wheel_dist = self._fetch_metadata_using_lazy_wheel(link) - if wheel_dist is not None: - req.needs_more_preparation = True - return wheel_dist + download_dir = self._get_download_dir(req.link) + if download_dir is not None: + hashes = self._get_linked_req_hashes(req) + file_path = _check_download_dir(req.link, download_dir, hashes) + if file_path is not None: + self._downloaded[req.link.url] = file_path, None + + if download_dir is None or file_path is None: + wheel_dist = self._fetch_metadata_using_lazy_wheel(link) + if wheel_dist is not None: + req.needs_more_preparation = True + return wheel_dist return self._prepare_linked_requirement(req, parallel_builds) def prepare_linked_requirements_more(self, reqs, parallel_builds=False): # type: (Iterable[InstallRequirement], bool) -> None """Prepare a linked requirement more, if needed.""" reqs = [req for req in reqs if req.needs_more_preparation] - links = [] # type: List[Link] - for req in reqs: - download_dir = self._get_download_dir(req.link) - if download_dir is not None: - hashes = self._get_linked_req_hashes(req) - file_path = _check_download_dir(req.link, download_dir, hashes) - if download_dir is None or file_path is None: - links.append(req.link) - else: - self._downloaded[req.link.url] = file_path, None + links = [req.link for req in reqs] # Let's download to a temporary directory. tmpdir = TempDirectory(kind="unpack", globally_managed=True).path