Skip to content

Commit 16b2aa8

Browse files
committed
Introduce ireq.cached_wheel_source_link
1 parent 63537d0 commit 16b2aa8

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

src/pip/_internal/operations/prepare.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -575,10 +575,7 @@ def _prepare_linked_requirement(
575575
"don't match, ignoring cached built wheel "
576576
"and re-downloading source."
577577
)
578-
# For some reason req.original_link is not set here, even though
579-
# req.is_wheel_from_cache is True. So we get the original
580-
# link from download_info.
581-
req.link = Link(req.download_info.url) # TODO comes_from?
578+
req.link = req.cached_wheel_source_link
582579
link = req.link
583580

584581
self._ensure_link_req_src_dir(req, parallel_builds)

src/pip/_internal/req/req_install.py

+3
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ def __init__(
112112
# When is_wheel_from_cache is True, it means that this InstallRequirement
113113
# is a local wheel file in the cache of locally built wheels.
114114
self.is_wheel_from_cache = False
115+
# When is_wheel_from_cache is True, this is the source link corresponding
116+
# to the cache entry, which was used to download and build the cached wheel.
117+
self.cached_wheel_source_link: Optional[Link] = None
115118

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

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

+1
Original file line numberDiff line numberDiff line change
@@ -431,6 +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.cached_wheel_source_link = req.link
434435
req.is_wheel_from_cache = True
435436
if cache_entry.origin is not None:
436437
req.download_info = cache_entry.origin

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

+1
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ def __init__(
277277
assert ireq.link.is_wheel
278278
assert ireq.link.is_file
279279
if cache_entry.persistent and template.link is template.original_link:
280+
ireq.cached_wheel_source_link = source_link
280281
ireq.is_wheel_from_cache = True
281282
if cache_entry.origin is not None:
282283
ireq.download_info = cache_entry.origin

0 commit comments

Comments
 (0)