summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStéphane Bidoul <stephane.bidoul@gmail.com>2023-04-11 14:41:54 +0200
committerStéphane Bidoul <stephane.bidoul@gmail.com>2023-04-11 14:49:30 +0200
commit4f6d47d8bc7ad7ab4fbbbb374413cc1aef2f06d3 (patch)
treebb692c86730cc52458677ffb6b19665f4997798e
parent5119d4651e7881401315be7d262a19b762d636c0 (diff)
downloadpip-4f6d47d8bc7ad7ab4fbbbb374413cc1aef2f06d3.tar.gz
Tweak comments
-rw-r--r--src/pip/_internal/models/installation_report.py2
-rw-r--r--src/pip/_internal/operations/prepare.py5
-rw-r--r--src/pip/_internal/resolution/legacy/resolver.py2
-rw-r--r--src/pip/_internal/resolution/resolvelib/candidates.py2
4 files changed, 7 insertions, 4 deletions
diff --git a/src/pip/_internal/models/installation_report.py b/src/pip/_internal/models/installation_report.py
index b54afb109..fef3757f2 100644
--- a/src/pip/_internal/models/installation_report.py
+++ b/src/pip/_internal/models/installation_report.py
@@ -14,7 +14,7 @@ class InstallationReport:
def _install_req_to_dict(cls, ireq: InstallRequirement) -> Dict[str, Any]:
assert ireq.download_info, f"No download_info for {ireq}"
res = {
- # PEP 610 json for the download URL. download_info.archive_info.hash may
+ # PEP 610 json for the download URL. download_info.archive_info.hashes may
# be absent when the requirement was installed from the wheel cache
# and the cache entry was populated by an older pip version that did not
# record origin.json.
diff --git a/src/pip/_internal/operations/prepare.py b/src/pip/_internal/operations/prepare.py
index 343a01bef..dda92d29b 100644
--- a/src/pip/_internal/operations/prepare.py
+++ b/src/pip/_internal/operations/prepare.py
@@ -571,12 +571,15 @@ class RequirementPreparer:
# Make sure we have a hash in download_info. If we got it as part of the
# URL, it will have been verified and we can rely on it. Otherwise we
# compute it from the downloaded file.
+ # FIXME: https://github.com/pypa/pip/issues/11943
if (
isinstance(req.download_info.info, ArchiveInfo)
- and not req.download_info.info.hash
+ and not req.download_info.info.hashes
and local_file
):
hash = hash_file(local_file.path)[0].hexdigest()
+ # We populate info.hash for backward compatibility.
+ # This will automatically populate info.hashes.
req.download_info.info.hash = f"sha256={hash}"
# For use in later processing,
diff --git a/src/pip/_internal/resolution/legacy/resolver.py b/src/pip/_internal/resolution/legacy/resolver.py
index fb49d4169..3a561e6db 100644
--- a/src/pip/_internal/resolution/legacy/resolver.py
+++ b/src/pip/_internal/resolution/legacy/resolver.py
@@ -436,7 +436,7 @@ class Resolver(BaseResolver):
req.download_info = cache_entry.origin
else:
# Legacy cache entry that does not have origin.json.
- # download_info may miss the archive_info.hash field.
+ # download_info may miss the archive_info.hashes field.
req.download_info = direct_url_from_link(
req.link, link_is_in_wheel_cache=cache_entry.persistent
)
diff --git a/src/pip/_internal/resolution/resolvelib/candidates.py b/src/pip/_internal/resolution/resolvelib/candidates.py
index fe83a6123..4d6249944 100644
--- a/src/pip/_internal/resolution/resolvelib/candidates.py
+++ b/src/pip/_internal/resolution/resolvelib/candidates.py
@@ -280,7 +280,7 @@ class LinkCandidate(_InstallRequirementBackedCandidate):
ireq.download_info = cache_entry.origin
else:
# Legacy cache entry that does not have origin.json.
- # download_info may miss the archive_info.hash field.
+ # download_info may miss the archive_info.hashes field.
ireq.download_info = direct_url_from_link(
source_link, link_is_in_wheel_cache=cache_entry.persistent
)