diff --git a/news/421.misc.md b/news/421.misc.md new file mode 100644 index 0000000000..86dcc7b6ec --- /dev/null +++ b/news/421.misc.md @@ -0,0 +1 @@ +Add log output about found candidates and their origin. diff --git a/pdm/models/candidates.py b/pdm/models/candidates.py index 7c97b07536..74ac38da97 100644 --- a/pdm/models/candidates.py +++ b/pdm/models/candidates.py @@ -215,7 +215,8 @@ def get_metadata( return self.metadata def __repr__(self) -> str: - return f"" + source = getattr(self.link, "comes_from", "unknown") + return f"" @classmethod def from_installation_candidate( diff --git a/pdm/models/repositories.py b/pdm/models/repositories.py index 1f14ec2ae7..c8c410a071 100644 --- a/pdm/models/repositories.py +++ b/pdm/models/repositories.py @@ -112,6 +112,9 @@ def find_candidates( reverse=True, ) + if not sorted_cans: + termui.logger.debug("\tCould not find any matching candidates.") + if not sorted_cans and allow_prereleases is None: # No non-pre-releases is found, force pre-releases now sorted_cans = sorted( @@ -124,6 +127,35 @@ def find_candidates( key=lambda c: c.version, reverse=True, ) + + if not sorted_cans: + termui.logger.debug( + "\tCould not find any matching candidates even when considering " + "pre-releases.", + ) + + def print_candidates( + title: str, candidates: List[Candidate], max_lines: int = 10 + ) -> None: + termui.logger.debug("\t" + title) + logged_lines = set() + for can in candidates: + new_line = f"\t {can}" + if new_line not in logged_lines: + logged_lines.add(new_line) + if len(logged_lines) > max_lines: + termui.logger.debug( + f"\t ... [{len(candidates)-max_lines} more candidate(s)]" + ) + break + else: + termui.logger.debug(new_line) + + if sorted_cans: + print_candidates("Found matching candidates:", sorted_cans) + elif cans: + print_candidates("Found but non-matching candidates:", cans) + return sorted_cans def _get_dependencies_from_cache(self, candidate: Candidate) -> CandidateInfo: