From 24bee84f44f76981641e5e5daa51a79e2984fa65 Mon Sep 17 00:00:00 2001 From: q0w <43147888+q0w@users.noreply.github.com> Date: Tue, 25 Jan 2022 18:26:06 +0300 Subject: [PATCH 1/3] Show Project-URLs --- src/pip/_internal/commands/show.py | 5 +++++ tests/functional/test_show.py | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/src/pip/_internal/commands/show.py b/src/pip/_internal/commands/show.py index d5540d68b..e7e0c5bf7 100644 --- a/src/pip/_internal/commands/show.py +++ b/src/pip/_internal/commands/show.py @@ -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 @@ -126,6 +127,7 @@ def search_packages_info(query: List[str]) -> Iterator[_PackageInfo]: 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", ""), @@ -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: diff --git a/tests/functional/test_show.py b/tests/functional/test_show.py index a704911e6..0c8f4c762 100644 --- a/tests/functional/test_show.py +++ b/tests/functional/test_show.py @@ -174,6 +174,14 @@ def test_show_verbose_installer(script: PipTestEnvironment, data: TestData) -> N assert "Installer: pip" in lines +def test_show_verbose_project_urls(script: PipTestEnvironment) -> None: + 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. @@ -184,6 +192,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: From ebdab7cdb6abf683e2763ce6e8016f2f7c479a7f Mon Sep 17 00:00:00 2001 From: q0w <43147888+q0w@users.noreply.github.com> Date: Tue, 25 Jan 2022 18:29:05 +0300 Subject: [PATCH 2/3] Add changelog --- news/10799.feature.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/10799.feature.rst diff --git a/news/10799.feature.rst b/news/10799.feature.rst new file mode 100644 index 000000000..4616b370e --- /dev/null +++ b/news/10799.feature.rst @@ -0,0 +1 @@ +Include Project-URLs in ``pip show`` output. From 8749d0baad3bc37960eb2a509c296cbad776c588 Mon Sep 17 00:00:00 2001 From: q0w <43147888+q0w@users.noreply.github.com> Date: Wed, 2 Feb 2022 21:11:23 +0300 Subject: [PATCH 3/3] Add docstring --- tests/functional/test_show.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/functional/test_show.py b/tests/functional/test_show.py index 0c8f4c762..6b434e51c 100644 --- a/tests/functional/test_show.py +++ b/tests/functional/test_show.py @@ -175,6 +175,9 @@ def test_show_verbose_installer(script: PipTestEnvironment, data: TestData) -> N 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