Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache requires-python checks & skip debug logging #13128

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/13128.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cache ``python-requires`` checks while filtering potential installation candidates.
5 changes: 5 additions & 0 deletions src/pip/_internal/index/package_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,11 @@ def _sort_links(self, links: Iterable[Link]) -> List[Link]:
return no_eggs + eggs

def _log_skipped_link(self, link: Link, result: LinkType, detail: str) -> None:
# This is a hot method so don't waste time hashing links unless we're
# actually going to log 'em.
if not logger.isEnabledFor(logging.DEBUG):
return

entry = (link, result, detail)
if entry not in self._logged_links:
# Put the link at the end so the reason is more visible and because
Expand Down
1 change: 1 addition & 0 deletions src/pip/_internal/utils/packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
logger = logging.getLogger(__name__)


@functools.lru_cache(maxsize=96)
def check_requires_python(
requires_python: Optional[str], version_info: Tuple[int, ...]
) -> bool:
Expand Down
Loading