From cb782fead0ea8d77c1b4e9bcd14a96908ebe500d Mon Sep 17 00:00:00 2001 From: doron zarhi Date: Tue, 6 Dec 2022 14:20:18 +0200 Subject: [PATCH] show: add editable location if package is editable (#11638) --- news/11638.bugfix.rst | 1 + src/pip/_internal/commands/show.py | 6 ++++++ tests/functional/test_show.py | 16 ++++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 news/11638.bugfix.rst diff --git a/news/11638.bugfix.rst b/news/11638.bugfix.rst new file mode 100644 index 00000000000..04ef930bc1b --- /dev/null +++ b/news/11638.bugfix.rst @@ -0,0 +1 @@ +Make ``pip show`` show the editable location if package is editable diff --git a/src/pip/_internal/commands/show.py b/src/pip/_internal/commands/show.py index 212167c9d1e..3f10701f6b2 100644 --- a/src/pip/_internal/commands/show.py +++ b/src/pip/_internal/commands/show.py @@ -53,6 +53,7 @@ class _PackageInfo(NamedTuple): name: str version: str location: str + editable_project_location: Optional[str] requires: List[str] required_by: List[str] installer: str @@ -120,6 +121,7 @@ def _get_requiring_packages(current_dist: BaseDistribution) -> Iterator[str]: name=dist.raw_name, version=str(dist.version), location=dist.location or "", + editable_project_location=dist.editable_project_location, requires=requires, required_by=required_by, installer=dist.installer, @@ -158,6 +160,10 @@ def print_results( write_output("Author-email: %s", dist.author_email) write_output("License: %s", dist.license) write_output("Location: %s", dist.location) + if dist.editable_project_location is not None: + write_output( + "Editable project location: %s", dist.editable_project_location + ) write_output("Requires: %s", ", ".join(dist.requires)) write_output("Required-by: %s", ", ".join(dist.required_by)) diff --git a/tests/functional/test_show.py b/tests/functional/test_show.py index 2fc8ca24270..9478b4bffcd 100644 --- a/tests/functional/test_show.py +++ b/tests/functional/test_show.py @@ -24,6 +24,22 @@ def test_basic_show(script: PipTestEnvironment) -> None: assert "Requires: " in lines +def test_show_with_editable_project_location(script: PipTestEnvironment) -> None: + """ + Test for show command with an editable project installation + """ + script.pip( + "install", + "-e", + "git+https://github.com/pypa/pip-test-package.git#egg=pip-test-package", + ) + result = script.pip( + "show", + "pip_test_package", + ) + assert "Editable project location:" in result.stdout + + def test_show_with_files_not_found(script: PipTestEnvironment, data: TestData) -> None: """ Test for show command with installed files listing enabled and