Skip to content

Commit

Permalink
Merge pull request #10827 from q0w/project-urls
Browse files Browse the repository at this point in the history
Include Project-URLs in `pip show -v` output
  • Loading branch information
pradyunsg authored Apr 23, 2022
2 parents 24ffdaa + 8749d0b commit 7164b1a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
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

0 comments on commit 7164b1a

Please sign in to comment.