diff options
author | Pradyun Gedam <3275593+pradyunsg@users.noreply.github.com> | 2020-10-02 03:41:43 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-02 03:41:43 +0530 |
commit | d0f80a44c9810a133d7258a72910844c3c3334f6 (patch) | |
tree | 77fdcff51ebbaa5167a0915da48009aed6a5cb71 /src/pip/_internal/operations/prepare.py | |
parent | fe2075b6861cfd4d9a21fcb1328ca8baa89c15f9 (diff) | |
parent | 2ef8040495711c7e7e695f80a35e208f7404f879 (diff) | |
download | pip-d0f80a44c9810a133d7258a72910844c3c3334f6.tar.gz |
Merge pull request #8804 from McSinyx/fast-deps-check-dl-dir
Diffstat (limited to 'src/pip/_internal/operations/prepare.py')
-rw-r--r-- | src/pip/_internal/operations/prepare.py | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/pip/_internal/operations/prepare.py b/src/pip/_internal/operations/prepare.py index 37f84f47e..3060bafa1 100644 --- a/src/pip/_internal/operations/prepare.py +++ b/src/pip/_internal/operations/prepare.py @@ -491,26 +491,32 @@ class RequirementPreparer(object): 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 + # Check if the relevant file is already available + # in the download directory + file_path = None + download_dir = self._get_download_dir(req.link) + if download_dir is not None and link.is_wheel: + hashes = self._get_linked_req_hashes(req) + file_path = _check_download_dir(req.link, download_dir, hashes) + + if file_path is not None: + # The file is already available, so mark it as downloaded + self._downloaded[req.link.url] = file_path, None + else: + # The file is not available, attempt to fetch only metadata + wheel_dist = self._fetch_metadata_using_lazy_wheel(link) + if wheel_dist is not None: + req.needs_more_preparation = True + return wheel_dist + + # None of the optimizations worked, fully prepare the requirement 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 |