Skip to content

Commit 32634e5

Browse files
authored
Merge pull request pypa#11639 from doronz88/bugfix/pip_show_location
show: show editable location instead if package is editable (pypa#11638)
2 parents 26d914f + e59ff2f commit 32634e5

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

news/11638.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Make ``pip show`` show the editable location if package is editable

src/pip/_internal/commands/show.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class _PackageInfo(NamedTuple):
5353
name: str
5454
version: str
5555
location: str
56+
editable_project_location: Optional[str]
5657
requires: List[str]
5758
required_by: List[str]
5859
installer: str
@@ -120,6 +121,7 @@ def _get_requiring_packages(current_dist: BaseDistribution) -> Iterator[str]:
120121
name=dist.raw_name,
121122
version=str(dist.version),
122123
location=dist.location or "",
124+
editable_project_location=dist.editable_project_location,
123125
requires=requires,
124126
required_by=required_by,
125127
installer=dist.installer,
@@ -158,6 +160,10 @@ def print_results(
158160
write_output("Author-email: %s", dist.author_email)
159161
write_output("License: %s", dist.license)
160162
write_output("Location: %s", dist.location)
163+
if dist.editable_project_location is not None:
164+
write_output(
165+
"Editable project location: %s", dist.editable_project_location
166+
)
161167
write_output("Requires: %s", ", ".join(dist.requires))
162168
write_output("Required-by: %s", ", ".join(dist.required_by))
163169

tests/functional/test_show.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def test_basic_show(script: PipTestEnvironment) -> None:
1717
"""
1818
result = script.pip("show", "pip")
1919
lines = result.stdout.splitlines()
20-
assert len(lines) == 10
20+
assert len(lines) == 11
2121
assert "Name: pip" in lines
2222
assert f"Version: {__version__}" in lines
2323
assert any(line.startswith("Location: ") for line in lines)
@@ -33,7 +33,7 @@ def test_show_with_files_not_found(script: PipTestEnvironment, data: TestData) -
3333
script.pip("install", "-e", editable)
3434
result = script.pip("show", "-f", "SetupPyUTF8")
3535
lines = result.stdout.splitlines()
36-
assert len(lines) == 12
36+
assert len(lines) == 13
3737
assert "Name: SetupPyUTF8" in lines
3838
assert "Version: 0.0.0" in lines
3939
assert any(line.startswith("Location: ") for line in lines)
@@ -128,7 +128,7 @@ def test_report_mixed_not_found(script: PipTestEnvironment) -> None:
128128
result = script.pip("show", "Abcd3", "A-B-C", "pip", allow_stderr_warning=True)
129129
assert "WARNING: Package(s) not found: A-B-C, Abcd3" in result.stderr
130130
lines = result.stdout.splitlines()
131-
assert len(lines) == 10
131+
assert len(lines) == 11
132132
assert "Name: pip" in lines
133133

134134

@@ -213,6 +213,7 @@ def test_all_fields(script: PipTestEnvironment) -> None:
213213
"Author-email",
214214
"License",
215215
"Location",
216+
"Editable project location",
216217
"Requires",
217218
"Required-by",
218219
}
@@ -226,7 +227,7 @@ def test_pip_show_is_short(script: PipTestEnvironment) -> None:
226227
"""
227228
result = script.pip("show", "pip")
228229
lines = result.stdout.splitlines()
229-
assert len(lines) <= 10
230+
assert len(lines) <= 11
230231

231232

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

0 commit comments

Comments
 (0)