From a2c57948b654d79bc52fa5580bd9e8dc1f75d701 Mon Sep 17 00:00:00 2001 From: Blazej Michalik Date: Thu, 31 Dec 2020 03:09:05 +0100 Subject: [PATCH 1/2] Bring back the "from versions:" message In the new resolver the "(from versions ...)" message, shown on failure to resolve a package, has been removed. This commit brings it back. --- news/9139.feature.rst | 1 + src/pip/_internal/resolution/resolvelib/factory.py | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 news/9139.feature.rst diff --git a/news/9139.feature.rst b/news/9139.feature.rst new file mode 100644 index 00000000000..98dc133a1d6 --- /dev/null +++ b/news/9139.feature.rst @@ -0,0 +1 @@ +Bring back the "(from versions: ...)" message, that was shown on resolution failures. diff --git a/src/pip/_internal/resolution/resolvelib/factory.py b/src/pip/_internal/resolution/resolvelib/factory.py index 3181d575336..f49288c83ef 100644 --- a/src/pip/_internal/resolution/resolvelib/factory.py +++ b/src/pip/_internal/resolution/resolvelib/factory.py @@ -410,10 +410,17 @@ def _report_single_requirement_conflict(self, req, parent): req_disp = str(req) else: req_disp = f"{req} (from {parent.name})" + + cands = self._finder.find_all_candidates(req.project_name) + versions = [str(v) for v in sorted(set(c.version for c in cands))] + logger.critical( - "Could not find a version that satisfies the requirement %s", + "Could not find a version that satisfies the requirement %s " + "(from versions: %s)", req_disp, + ", ".join(versions) or "none", ) + return DistributionNotFound(f"No matching distribution found for {req}") def get_installation_error( From d1d914597c9bedef22cd30422f04ca4ea6799f3c Mon Sep 17 00:00:00 2001 From: Blazej Michalik Date: Sun, 28 Feb 2021 00:41:04 +0100 Subject: [PATCH 2/2] =?UTF-8?q?Refactor=20`set(...)`=20=E2=86=92=20`{...}`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Tzu-ping Chung --- src/pip/_internal/resolution/resolvelib/factory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pip/_internal/resolution/resolvelib/factory.py b/src/pip/_internal/resolution/resolvelib/factory.py index f49288c83ef..fbf04fa4f09 100644 --- a/src/pip/_internal/resolution/resolvelib/factory.py +++ b/src/pip/_internal/resolution/resolvelib/factory.py @@ -412,7 +412,7 @@ def _report_single_requirement_conflict(self, req, parent): req_disp = f"{req} (from {parent.name})" cands = self._finder.find_all_candidates(req.project_name) - versions = [str(v) for v in sorted(set(c.version for c in cands))] + versions = [str(v) for v in sorted({c.version for c in cands})] logger.critical( "Could not find a version that satisfies the requirement %s "