Skip to content

Commit 4f64f64

Browse files
committed
[fast-deps] Check download directory before making requests
1 parent ffbe932 commit 4f64f64

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

news/8804.feature

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Check the download directory for existing distributions to avoid fetching
2+
metadata if possible when the ``fast-deps`` feature is used with
3+
``pip wheel`` and ``pip download``.

src/pip/_internal/operations/prepare.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -486,26 +486,25 @@ def prepare_linked_requirement(self, req, parallel_builds=False):
486486
link = req.link
487487
self._log_preparing_link(req)
488488
with indent_log():
489-
wheel_dist = self._fetch_metadata_using_lazy_wheel(link)
490-
if wheel_dist is not None:
491-
req.needs_more_preparation = True
492-
return wheel_dist
489+
download_dir = self._get_download_dir(req.link)
490+
if download_dir is not None:
491+
hashes = self._get_linked_req_hashes(req)
492+
file_path = _check_download_dir(req.link, download_dir, hashes)
493+
if file_path is not None:
494+
self._downloaded[req.link.url] = file_path, None
495+
496+
if download_dir is None or file_path is None:
497+
wheel_dist = self._fetch_metadata_using_lazy_wheel(link)
498+
if wheel_dist is not None:
499+
req.needs_more_preparation = True
500+
return wheel_dist
493501
return self._prepare_linked_requirement(req, parallel_builds)
494502

495503
def prepare_linked_requirements_more(self, reqs, parallel_builds=False):
496504
# type: (Iterable[InstallRequirement], bool) -> None
497505
"""Prepare a linked requirement more, if needed."""
498506
reqs = [req for req in reqs if req.needs_more_preparation]
499-
links = [] # type: List[Link]
500-
for req in reqs:
501-
download_dir = self._get_download_dir(req.link)
502-
if download_dir is not None:
503-
hashes = self._get_linked_req_hashes(req)
504-
file_path = _check_download_dir(req.link, download_dir, hashes)
505-
if download_dir is None or file_path is None:
506-
links.append(req.link)
507-
else:
508-
self._downloaded[req.link.url] = file_path, None
507+
links = [req.link for req in reqs]
509508

510509
# Let's download to a temporary directory.
511510
tmpdir = TempDirectory(kind="unpack", globally_managed=True).path

0 commit comments

Comments
 (0)