Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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
2 changes: 2 additions & 0 deletions news/14193.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix the no-matching-distributions hint being shown for packages that are
installable.
Comment thread
2ykwang marked this conversation as resolved.
Outdated
11 changes: 1 addition & 10 deletions src/pip/_internal/resolution/resolvelib/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,16 +784,7 @@ def _has_any_candidates(self, project_name: str) -> bool:
"""
Check if there are any candidates available for the project name.
"""
return any(
self.find_candidates(
project_name,
requirements={project_name: []},
incompatibilities={},
constraint=Constraint.empty(),
prefers_installed=True,
is_satisfied_by=lambda r, c: True,
)
)
return bool(self._finder.find_all_candidates(project_name))

def get_installation_error(
self,
Expand Down
29 changes: 29 additions & 0 deletions tests/functional/test_new_resolver_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,32 @@ def test_new_resolver_no_versions_available_hint(script: PipTestEnvironment) ->
"matching distributions available for your environment:\n"
" incompatible-dep\n" in result.stdout
), str(result)


def test_new_resolver_hint_not_shown_when_versions_available(
script: PipTestEnvironment,
) -> None:
"""
Test hint is not shown when a package candidate is available,
even though ResolutionImpossible occurs.
"""
create_basic_wheel_for_package(script, "base", "1.0")
create_basic_wheel_for_package(script, "base", "2.0")
create_basic_wheel_for_package(script, "pkga", "1.0", depends=["base==1.0"])
create_basic_wheel_for_package(script, "pkgb", "1.0", depends=["base==2.0"])

result = script.pip(
"install",
"--no-cache-dir",
"--no-index",
"--find-links",
script.scratch_path,
"pkga",
"pkgb",
expect_error=True,
)

assert "ResolutionImpossible" in result.stderr, str(result)
assert "pkga 1.0 depends on base==1.0" in result.stdout, str(result)
assert "pkgb 1.0 depends on base==2.0" in result.stdout, str(result)
assert "have no matching distributions available" not in result.stdout, str(result)
Loading