Skip to content
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
2 changes: 2 additions & 0 deletions news/10216.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Allow installing a package as editable alongside another package that
depends on it, via a direct URL reference to the same location.
2 changes: 2 additions & 0 deletions src/pip/_internal/resolution/resolvelib/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ def _make_base_candidate_from_link(
self._build_failures[link] = e
return None

return self._editable_candidate_cache[link]
elif link in self._editable_candidate_cache:
return self._editable_candidate_cache[link]
Comment on lines +223 to 224
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't come up with this -- I tried using Claude Code to resolve this one and it ended up coming up with this... and, like I don't see anything wrong with this particular change logically and it's too nice and small to not consider. 😅

else:
if link not in self._link_candidate_cache:
Expand Down
47 changes: 47 additions & 0 deletions tests/functional/test_new_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,53 @@ def test_new_resolver_installs_editable(script: PipTestEnvironment) -> None:
script.assert_installed_editable("dep")


def test_new_resolver_editable_satisfies_direct_url_dep(
script: PipTestEnvironment,
) -> None:
"""Regression test for https://github.com/pypa/pip/issues/10216.

Installing ``-e A -e B`` used to fail with ``ResolutionImpossible`` when ``A``
depends on ``B`` via a direct URL (PEP 440) reference pointing at the same
location as the editable ``B``:

> Cannot install package-a and package-b because these package versions have
> conflicting dependencies.

This was because the resolver created both an ``EditableCandidate`` (from the
user-supplied ``-e B``) and a ``LinkCandidate`` (from ``A``'s transitive
direct-URL dependency) for the same link, and treated them as conflicting.
"""
dep_path = create_test_package_with_setup(script, name="dep", version="0.1.0")
dep_url = dep_path.as_uri()
base_path = script.scratch_path / "base"
base_path.mkdir()
base_path.joinpath("setup.py").write_text(
textwrap.dedent(
f"""
from setuptools import setup
setup(
name="base",
version="0.1.0",
install_requires=["dep @ {dep_url}"],
)
"""
)
)
script.pip(
"install",
"--no-build-isolation",
"--no-cache-dir",
"--no-index",
"-e",
base_path,
"-e",
dep_path,
)
script.assert_installed(base="0.1.0", dep="0.1.0")
script.assert_installed_editable("base")
script.assert_installed_editable("dep")


@pytest.mark.parametrize(
"requires_python, ignore_requires_python, dep_version",
[
Expand Down