Skip to content

Commit 2ef8040

Browse files
McSinyxpradyunsg
andcommitted
Comment and rework conditionals in download dir check
Co-authored-by: Pradyun Gedam <[email protected]>
1 parent c947d00 commit 2ef8040

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/pip/_internal/operations/prepare.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -486,20 +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+
# Check if the relevant file is already available
490+
# in the download directory
491+
file_path = None
489492
download_dir = self._get_download_dir(req.link)
490493
if download_dir is not None and link.is_wheel:
491494
hashes = self._get_linked_req_hashes(req)
492495
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-
else:
496-
file_path = None
497496

498-
if file_path is None:
497+
if file_path is not None:
498+
# The file is already available, so mark it as downloaded
499+
self._downloaded[req.link.url] = file_path, None
500+
else:
501+
# The file is not available, attempt to fetch only metadata
499502
wheel_dist = self._fetch_metadata_using_lazy_wheel(link)
500503
if wheel_dist is not None:
501504
req.needs_more_preparation = True
502505
return wheel_dist
506+
507+
# None of the optimizations worked, fully prepare the requirement
503508
return self._prepare_linked_requirement(req, parallel_builds)
504509

505510
def prepare_linked_requirements_more(self, reqs, parallel_builds=False):

0 commit comments

Comments
 (0)