diff --git a/news/13112.feature.rst b/news/13112.feature.rst new file mode 100644 index 00000000000..e2c85ea5629 --- /dev/null +++ b/news/13112.feature.rst @@ -0,0 +1 @@ +Prefer to display ``License-Expression`` in ``pip show`` if metadata version is at least 2.4. \ No newline at end of file diff --git a/src/pip/_internal/commands/show.py b/src/pip/_internal/commands/show.py index c54d548f5fb..77a96652454 100644 --- a/src/pip/_internal/commands/show.py +++ b/src/pip/_internal/commands/show.py @@ -66,6 +66,7 @@ class _PackageInfo(NamedTuple): author: str author_email: str license: str + license_expression: str entry_points: List[str] files: Optional[List[str]] @@ -161,6 +162,7 @@ def _get_requiring_packages(current_dist: BaseDistribution) -> Iterator[str]: author=metadata.get("Author", ""), author_email=metadata.get("Author-email", ""), license=metadata.get("License", ""), + license_expression=metadata.get("License-Expression", ""), entry_points=entry_points, files=files, ) @@ -186,7 +188,10 @@ def print_results( write_output("Home-page: %s", dist.homepage) write_output("Author: %s", dist.author) write_output("Author-email: %s", dist.author_email) - write_output("License: %s", dist.license) + if dist.metadata_version >= "2.4" and dist.license_expression: + write_output("License-Expression: %s", dist.license_expression) + else: + write_output("License: %s", dist.license) write_output("Location: %s", dist.location) if dist.editable_project_location is not None: write_output(