Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include Project-URLs in pip show -v output #10827

Merged
merged 3 commits into from
Apr 23, 2022
Merged
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
1 change: 1 addition & 0 deletions news/10799.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Include Project-URLs in ``pip show`` output.
5 changes: 5 additions & 0 deletions src/pip/_internal/commands/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class _PackageInfo(NamedTuple):
classifiers: List[str]
summary: str
homepage: str
project_urls: List[str]
author: str
author_email: str
license: str
Expand Down Expand Up @@ -126,6 +127,7 @@ def _get_requiring_packages(current_dist: BaseDistribution) -> Iterator[str]:
classifiers=metadata.get_all("Classifier", []),
summary=metadata.get("Summary", ""),
homepage=metadata.get("Home-page", ""),
project_urls=metadata.get_all("Project-URL", []),
author=metadata.get("Author", ""),
author_email=metadata.get("Author-email", ""),
license=metadata.get("License", ""),
Expand Down Expand Up @@ -168,6 +170,9 @@ def print_results(
write_output("Entry-points:")
for entry in dist.entry_points:
write_output(" %s", entry.strip())
write_output("Project-URLs:")
for project_url in dist.project_urls:
write_output(" %s", project_url)
if list_files:
write_output("Files:")
if dist.files is None:
Expand Down
12 changes: 12 additions & 0 deletions tests/functional/test_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,17 @@ def test_show_verbose_installer(script: PipTestEnvironment, data: TestData) -> N
assert "Installer: pip" in lines


def test_show_verbose_project_urls(script: PipTestEnvironment) -> None:
"""
Test that project urls can be listed
"""
result = script.pip("show", "pip", "--verbose")
lines = result.stdout.splitlines()
assert "Name: pip" in lines
assert re.search(r"Project-URLs:\n( .+\n)+", result.stdout)
assert "Source, https://github.com/pypa/pip" in result.stdout


def test_show_verbose(script: PipTestEnvironment) -> None:
"""
Test end to end test for verbose show command.
Expand All @@ -184,6 +195,7 @@ def test_show_verbose(script: PipTestEnvironment) -> None:
assert any(line.startswith("Installer: ") for line in lines)
assert "Entry-points:" in lines
assert "Classifiers:" in lines
assert "Project-URLs:" in lines


def test_all_fields(script: PipTestEnvironment) -> None:
Expand Down