Skip to content

Commit efe2d27

Browse files
committed
Further refactor is_wheel_from_cache
1 parent 4beca6b commit efe2d27

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/pip/_internal/req/req_install.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,9 @@ def __init__(
109109
link = Link(req.url)
110110
self.link = self.original_link = link
111111

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
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.
112+
# When this InstallRequirement is a wheel obtained from the cache of locally
113+
# built wheels, this is the source link corresponding to the cache entry, which
114+
# was used to download and build the cached wheel.
117115
self.cached_wheel_source_link: Optional[Link] = None
118116

119117
# Information about the location of the artifact that was downloaded . This
@@ -443,6 +441,12 @@ def is_wheel(self) -> bool:
443441
return False
444442
return self.link.is_wheel
445443

444+
@property
445+
def is_wheel_from_cache(self) -> bool:
446+
# When True, it means that this InstallRequirement is a local wheel file in the
447+
# cache of locally built wheels.
448+
return self.cached_wheel_source_link is not None
449+
446450
# Things valid for sdists
447451
@property
448452
def unpacked_source_directory(self) -> str:

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

-1
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,6 @@ def _populate_link(self, req: InstallRequirement) -> None:
432432
logger.debug("Using cached wheel link: %s", cache_entry.link)
433433
if req.link is req.original_link and cache_entry.persistent:
434434
req.cached_wheel_source_link = req.link
435-
req.is_wheel_from_cache = True
436435
if cache_entry.origin is not None:
437436
req.download_info = cache_entry.origin
438437
else:

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

-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@ def __init__(
281281
assert ireq.link.is_file
282282
if cache_entry.persistent and template.link is template.original_link:
283283
ireq.cached_wheel_source_link = source_link
284-
ireq.is_wheel_from_cache = True
285284
if cache_entry.origin is not None:
286285
ireq.download_info = cache_entry.origin
287286
else:

0 commit comments

Comments
 (0)