Skip to content

Commit

Permalink
display the package name only if the version is not found.
Browse files Browse the repository at this point in the history
  • Loading branch information
rmmancom committed Jun 27, 2024
1 parent 862bfbc commit 9e5603e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/pip/_internal/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,23 +476,26 @@ def run(self, options: Values, args: List[str]) -> int:
# Display a summary of installed packages, with extra care to
# display a package name as it was requested by the user.
installed.sort(key=operator.attrgetter("name"))
items = []
summary = []
installed_versions = {}
for distribution in env.iter_all_distributions():
installed_versions[distribution.canonical_name] = distribution.version
for package in installed:
display_name = package.name
version = installed_versions.get(canonicalize_name(display_name), None)
item = f"{display_name}-{version}"
items.append(item)
if version:
text = f"{display_name}-{version}"
else:
text = display_name
summary.append(text)

if conflicts is not None:
self._warn_about_conflicts(
conflicts,
resolver_variant=self.determine_resolver_variant(options),
)

installed_desc = " ".join(items)
installed_desc = " ".join(summary)
if installed_desc:
write_output(
"Successfully installed %s",
Expand Down

0 comments on commit 9e5603e

Please sign in to comment.