Skip to content

Commit a6ef648

Browse files
committed
Rename original_link_is_in_wheel_cache to is_wheel_from_cache
This more accurately reflects that it is not necessarily related to original_link, original_link being the direct URL link, and the wheel cache can also be populated from sdists URL discovered by the finder.
1 parent ff8c8e3 commit a6ef648

File tree

5 files changed

+13
-10
lines changed

5 files changed

+13
-10
lines changed

src/pip/_internal/operations/prepare.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def __init__(
267267

268268
def _log_preparing_link(self, req: InstallRequirement) -> None:
269269
"""Provide context for the requirement being prepared."""
270-
if req.link.is_file and not req.original_link_is_in_wheel_cache:
270+
if req.link.is_file and not req.is_wheel_from_cache:
271271
message = "Processing %s"
272272
information = str(display_path(req.link.file_path))
273273
else:
@@ -288,7 +288,7 @@ def _log_preparing_link(self, req: InstallRequirement) -> None:
288288
self._previous_requirement_header = (message, information)
289289
logger.info(message, information)
290290

291-
if req.original_link_is_in_wheel_cache:
291+
if req.is_wheel_from_cache:
292292
with indent_log():
293293
logger.info("Using cached %s", req.link.filename)
294294

@@ -499,7 +499,7 @@ def prepare_linked_requirement(
499499
# original link, not the cached link. It that case the already
500500
# downloaded file will be removed and re-fetched from cache (which
501501
# implies a hash check against the cache entry's origin.json).
502-
warn_on_hash_mismatch=not req.original_link_is_in_wheel_cache,
502+
warn_on_hash_mismatch=not req.is_wheel_from_cache,
503503
)
504504

505505
if file_path is not None:
@@ -553,7 +553,7 @@ def _prepare_linked_requirement(
553553

554554
hashes = self._get_linked_req_hashes(req)
555555

556-
if hashes and req.original_link_is_in_wheel_cache:
556+
if hashes and req.is_wheel_from_cache:
557557
assert req.download_info is not None
558558
assert link.is_wheel
559559
assert link.is_file
@@ -576,7 +576,7 @@ def _prepare_linked_requirement(
576576
"and re-downloading source."
577577
)
578578
# For some reason req.original_link is not set here, even though
579-
# req.original_link_is_in_wheel_cache is True. So we get the original
579+
# req.is_wheel_from_cache is True. So we get the original
580580
# link from download_info.
581581
req.link = Link(req.download_info.url) # TODO comes_from?
582582
link = req.link

src/pip/_internal/req/req_install.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ def __init__(
108108
# PEP 508 URL requirement
109109
link = Link(req.url)
110110
self.link = self.original_link = link
111-
self.original_link_is_in_wheel_cache = False
111+
112+
# When is_wheel_from_cache is True, it means that this InstallRequirement
113+
# is a local wheel file in the cache of locally built wheels.
114+
self.is_wheel_from_cache = False
112115

113116
# Information about the location of the artifact that was downloaded . This
114117
# property is guaranteed to be set in resolver results.

src/pip/_internal/resolution/legacy/resolver.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ def _populate_link(self, req: InstallRequirement) -> None:
431431
if cache_entry is not None:
432432
logger.debug("Using cached wheel link: %s", cache_entry.link)
433433
if req.link is req.original_link and cache_entry.persistent:
434-
req.original_link_is_in_wheel_cache = True
434+
req.is_wheel_from_cache = True
435435
if cache_entry.origin is not None:
436436
req.download_info = cache_entry.origin
437437
else:

src/pip/_internal/resolution/resolvelib/candidates.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def __init__(
278278

279279
if cache_entry is not None:
280280
if cache_entry.persistent and template.link is template.original_link:
281-
ireq.original_link_is_in_wheel_cache = True
281+
ireq.is_wheel_from_cache = True
282282
if cache_entry.origin is not None:
283283
ireq.download_info = cache_entry.origin
284284
else:

tests/unit/test_req.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ def test_download_info_archive_legacy_cache(
411411
reqset = resolver.resolve([ireq], True)
412412
assert len(reqset.all_requirements) == 1
413413
req = reqset.all_requirements[0]
414-
assert req.original_link_is_in_wheel_cache
414+
assert req.is_wheel_from_cache
415415
assert req.download_info
416416
assert req.download_info.url == url
417417
assert isinstance(req.download_info.info, ArchiveInfo)
@@ -437,7 +437,7 @@ def test_download_info_archive_cache_with_origin(
437437
reqset = resolver.resolve([ireq], True)
438438
assert len(reqset.all_requirements) == 1
439439
req = reqset.all_requirements[0]
440-
assert req.original_link_is_in_wheel_cache
440+
assert req.is_wheel_from_cache
441441
assert req.download_info
442442
assert req.download_info.url == url
443443
assert isinstance(req.download_info.info, ArchiveInfo)

0 commit comments

Comments
 (0)