Skip to content

Commit

Permalink
show: add editable location if package is editable (pypa#11638)
Browse files Browse the repository at this point in the history
  • Loading branch information
doronz88 committed Dec 17, 2022
1 parent 26d914f commit e59ff2f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions news/11638.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make ``pip show`` show the editable location if package is editable
6 changes: 6 additions & 0 deletions src/pip/_internal/commands/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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))

Expand Down
9 changes: 5 additions & 4 deletions tests/functional/test_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_basic_show(script: PipTestEnvironment) -> None:
"""
result = script.pip("show", "pip")
lines = result.stdout.splitlines()
assert len(lines) == 10
assert len(lines) == 11
assert "Name: pip" in lines
assert f"Version: {__version__}" in lines
assert any(line.startswith("Location: ") for line in lines)
Expand All @@ -33,7 +33,7 @@ def test_show_with_files_not_found(script: PipTestEnvironment, data: TestData) -
script.pip("install", "-e", editable)
result = script.pip("show", "-f", "SetupPyUTF8")
lines = result.stdout.splitlines()
assert len(lines) == 12
assert len(lines) == 13
assert "Name: SetupPyUTF8" in lines
assert "Version: 0.0.0" in lines
assert any(line.startswith("Location: ") for line in lines)
Expand Down Expand Up @@ -128,7 +128,7 @@ def test_report_mixed_not_found(script: PipTestEnvironment) -> None:
result = script.pip("show", "Abcd3", "A-B-C", "pip", allow_stderr_warning=True)
assert "WARNING: Package(s) not found: A-B-C, Abcd3" in result.stderr
lines = result.stdout.splitlines()
assert len(lines) == 10
assert len(lines) == 11
assert "Name: pip" in lines


Expand Down Expand Up @@ -213,6 +213,7 @@ def test_all_fields(script: PipTestEnvironment) -> None:
"Author-email",
"License",
"Location",
"Editable project location",
"Requires",
"Required-by",
}
Expand All @@ -226,7 +227,7 @@ def test_pip_show_is_short(script: PipTestEnvironment) -> None:
"""
result = script.pip("show", "pip")
lines = result.stdout.splitlines()
assert len(lines) <= 10
assert len(lines) <= 11


def test_pip_show_divider(script: PipTestEnvironment, data: TestData) -> None:
Expand Down

0 comments on commit e59ff2f

Please sign in to comment.