From 709e0f19f9881bc86df03722efd86ec0bdd12aad Mon Sep 17 00:00:00 2001 From: eight04 Date: Thu, 29 Feb 2024 14:59:48 +0800 Subject: [PATCH] Fix: unable to list global packages if extra is used --- vpip/commands/list.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/vpip/commands/list.py b/vpip/commands/list.py index 89b94bf..0b44868 100644 --- a/vpip/commands/list.py +++ b/vpip/commands/list.py @@ -24,11 +24,13 @@ def iter_global_packages(): :rtype: Iterator[PackageInfo] """ + from packaging.requirements import Requirement from .. import venv, pip_api - for name in venv.iter_global_packages(): - vv = venv.get_global_pkg_venv(name) + for dir_name in venv.iter_global_packages(): + vv = venv.get_global_pkg_venv(dir_name) with vv.activate(): - yield PackageInfo(name, pip_api.show([name])[0].version) + req = Requirement(dir_name) + yield PackageInfo(req.name, pip_api.show([req.name])[0].version) def print_global_packages(check_outdated=False): for info in iter_global_packages(): @@ -116,4 +118,4 @@ def __str__(self): else: lines.append("{} (not installed)".format(self.name)) return "\n".join(lines) - \ No newline at end of file +