summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStéphane Bidoul <stephane.bidoul@gmail.com>2023-04-10 14:32:55 +0200
committerStéphane Bidoul <stephane.bidoul@gmail.com>2023-04-14 08:03:48 +0200
commita6ef6485be9512f18121298b058797c578f65d45 (patch)
tree306ca39025bc4c4b90c625f8bc9fe2f210df69b6
parentff8c8e38887880ad81ffd7cfc6a8373213c087b7 (diff)
downloadpip-a6ef6485be9512f18121298b058797c578f65d45.tar.gz
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.
-rw-r--r--src/pip/_internal/operations/prepare.py10
-rw-r--r--src/pip/_internal/req/req_install.py5
-rw-r--r--src/pip/_internal/resolution/legacy/resolver.py2
-rw-r--r--src/pip/_internal/resolution/resolvelib/candidates.py2
-rw-r--r--tests/unit/test_req.py4
5 files changed, 13 insertions, 10 deletions
diff --git a/src/pip/_internal/operations/prepare.py b/src/pip/_internal/operations/prepare.py
index a9ad1558d..10ed17c19 100644
--- a/src/pip/_internal/operations/prepare.py
+++ b/src/pip/_internal/operations/prepare.py
@@ -267,7 +267,7 @@ class RequirementPreparer:
def _log_preparing_link(self, req: InstallRequirement) -> None:
"""Provide context for the requirement being prepared."""
- if req.link.is_file and not req.original_link_is_in_wheel_cache:
+ if req.link.is_file and not req.is_wheel_from_cache:
message = "Processing %s"
information = str(display_path(req.link.file_path))
else:
@@ -288,7 +288,7 @@ class RequirementPreparer:
self._previous_requirement_header = (message, information)
logger.info(message, information)
- if req.original_link_is_in_wheel_cache:
+ if req.is_wheel_from_cache:
with indent_log():
logger.info("Using cached %s", req.link.filename)
@@ -499,7 +499,7 @@ class RequirementPreparer:
# original link, not the cached link. It that case the already
# downloaded file will be removed and re-fetched from cache (which
# implies a hash check against the cache entry's origin.json).
- warn_on_hash_mismatch=not req.original_link_is_in_wheel_cache,
+ warn_on_hash_mismatch=not req.is_wheel_from_cache,
)
if file_path is not None:
@@ -553,7 +553,7 @@ class RequirementPreparer:
hashes = self._get_linked_req_hashes(req)
- if hashes and req.original_link_is_in_wheel_cache:
+ if hashes and req.is_wheel_from_cache:
assert req.download_info is not None
assert link.is_wheel
assert link.is_file
@@ -576,7 +576,7 @@ class RequirementPreparer:
"and re-downloading source."
)
# For some reason req.original_link is not set here, even though
- # req.original_link_is_in_wheel_cache is True. So we get the original
+ # req.is_wheel_from_cache is True. So we get the original
# link from download_info.
req.link = Link(req.download_info.url) # TODO comes_from?
link = req.link
diff --git a/src/pip/_internal/req/req_install.py b/src/pip/_internal/req/req_install.py
index e2353f032..a8f94d4e0 100644
--- a/src/pip/_internal/req/req_install.py
+++ b/src/pip/_internal/req/req_install.py
@@ -108,7 +108,10 @@ class InstallRequirement:
# PEP 508 URL requirement
link = Link(req.url)
self.link = self.original_link = link
- self.original_link_is_in_wheel_cache = False
+
+ # When is_wheel_from_cache is True, it means that this InstallRequirement
+ # is a local wheel file in the cache of locally built wheels.
+ self.is_wheel_from_cache = False
# Information about the location of the artifact that was downloaded . This
# property is guaranteed to be set in resolver results.
diff --git a/src/pip/_internal/resolution/legacy/resolver.py b/src/pip/_internal/resolution/legacy/resolver.py
index 3a561e6db..86d135fca 100644
--- a/src/pip/_internal/resolution/legacy/resolver.py
+++ b/src/pip/_internal/resolution/legacy/resolver.py
@@ -431,7 +431,7 @@ class Resolver(BaseResolver):
if cache_entry is not None:
logger.debug("Using cached wheel link: %s", cache_entry.link)
if req.link is req.original_link and cache_entry.persistent:
- req.original_link_is_in_wheel_cache = True
+ req.is_wheel_from_cache = True
if cache_entry.origin is not None:
req.download_info = cache_entry.origin
else:
diff --git a/src/pip/_internal/resolution/resolvelib/candidates.py b/src/pip/_internal/resolution/resolvelib/candidates.py
index 109fbdaf6..3429f01e1 100644
--- a/src/pip/_internal/resolution/resolvelib/candidates.py
+++ b/src/pip/_internal/resolution/resolvelib/candidates.py
@@ -278,7 +278,7 @@ class LinkCandidate(_InstallRequirementBackedCandidate):
if cache_entry is not None:
if cache_entry.persistent and template.link is template.original_link:
- ireq.original_link_is_in_wheel_cache = True
+ ireq.is_wheel_from_cache = True
if cache_entry.origin is not None:
ireq.download_info = cache_entry.origin
else:
diff --git a/tests/unit/test_req.py b/tests/unit/test_req.py
index a5286c13a..eb486ba0f 100644
--- a/tests/unit/test_req.py
+++ b/tests/unit/test_req.py
@@ -411,7 +411,7 @@ class TestRequirementSet:
reqset = resolver.resolve([ireq], True)
assert len(reqset.all_requirements) == 1
req = reqset.all_requirements[0]
- assert req.original_link_is_in_wheel_cache
+ assert req.is_wheel_from_cache
assert req.download_info
assert req.download_info.url == url
assert isinstance(req.download_info.info, ArchiveInfo)
@@ -437,7 +437,7 @@ class TestRequirementSet:
reqset = resolver.resolve([ireq], True)
assert len(reqset.all_requirements) == 1
req = reqset.all_requirements[0]
- assert req.original_link_is_in_wheel_cache
+ assert req.is_wheel_from_cache
assert req.download_info
assert req.download_info.url == url
assert isinstance(req.download_info.info, ArchiveInfo)