Skip to content

Commit 659f0dc

Browse files
committed
Set download_info also when the cache miss origin.json
1 parent e744949 commit 659f0dc

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
from pip._internal.resolution.base import BaseResolver, InstallRequirementProvider
4646
from pip._internal.utils import compatibility_tags
4747
from pip._internal.utils.compatibility_tags import get_supported
48+
from pip._internal.utils.direct_url_helpers import direct_url_from_link
4849
from pip._internal.utils.logging import indent_log
4950
from pip._internal.utils.misc import normalize_version_info
5051
from pip._internal.utils.packaging import check_requires_python
@@ -431,8 +432,14 @@ def _populate_link(self, req: InstallRequirement) -> None:
431432
logger.debug("Using cached wheel link: %s", cache_entry.link)
432433
if req.link is req.original_link and cache_entry.persistent:
433434
req.original_link_is_in_wheel_cache = True
434-
if cache_entry.origin is not None:
435-
req.download_info = cache_entry.origin
435+
if cache_entry.origin is not None:
436+
req.download_info = cache_entry.origin
437+
else:
438+
# Legacy cache entry that does not have origin.json.
439+
# download_info may miss the archive_info.hash field.
440+
req.download_info = direct_url_from_link(
441+
req.link, link_is_in_wheel_cache=True
442+
)
436443
req.link = cache_entry.link
437444

438445
def _get_dist_for(self, req: InstallRequirement) -> BaseDistribution:

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
install_req_from_line,
1919
)
2020
from pip._internal.req.req_install import InstallRequirement
21+
from pip._internal.utils.direct_url_helpers import direct_url_from_link
2122
from pip._internal.utils.misc import normalize_version_info
2223

2324
from .base import Candidate, CandidateVersion, Requirement, format_name
@@ -281,14 +282,17 @@ def __init__(
281282
version, wheel_version, name
282283
)
283284

284-
if (
285-
cache_entry is not None
286-
and cache_entry.persistent
287-
and template.link is template.original_link
288-
):
289-
ireq.original_link_is_in_wheel_cache = True
285+
if cache_entry is not None:
286+
if cache_entry.persistent and template.link is template.original_link:
287+
ireq.original_link_is_in_wheel_cache = True
290288
if cache_entry.origin is not None:
291289
ireq.download_info = cache_entry.origin
290+
else:
291+
# Legacy cache entry that does not have origin.json.
292+
# download_info may miss the archive_info.hash field.
293+
ireq.download_info = direct_url_from_link(
294+
source_link, link_is_in_wheel_cache=True
295+
)
292296

293297
super().__init__(
294298
link=link,

0 commit comments

Comments
 (0)