Skip to content

Commit

Permalink
Further refactor is_wheel_from_cache
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Apr 14, 2023
1 parent 4beca6b commit efe2d27
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
14 changes: 9 additions & 5 deletions src/pip/_internal/req/req_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,9 @@ def __init__(
link = Link(req.url)
self.link = self.original_link = link

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

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

@property
def is_wheel_from_cache(self) -> bool:
# When True, it means that this InstallRequirement is a local wheel file in the
# cache of locally built wheels.
return self.cached_wheel_source_link is not None

# Things valid for sdists
@property
def unpacked_source_directory(self) -> str:
Expand Down
1 change: 0 additions & 1 deletion src/pip/_internal/resolution/legacy/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,6 @@ def _populate_link(self, req: InstallRequirement) -> None:
logger.debug("Using cached wheel link: %s", cache_entry.link)
if req.link is req.original_link and cache_entry.persistent:
req.cached_wheel_source_link = req.link
req.is_wheel_from_cache = True
if cache_entry.origin is not None:
req.download_info = cache_entry.origin
else:
Expand Down
1 change: 0 additions & 1 deletion src/pip/_internal/resolution/resolvelib/candidates.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ def __init__(
assert ireq.link.is_file
if cache_entry.persistent and template.link is template.original_link:
ireq.cached_wheel_source_link = source_link
ireq.is_wheel_from_cache = True
if cache_entry.origin is not None:
ireq.download_info = cache_entry.origin
else:
Expand Down

0 comments on commit efe2d27

Please sign in to comment.