to_pkg_install_commands should skip already installed sys packages.

This commit is contained in:
Fabio Manganiello 2023-08-23 11:51:53 +02:00
parent 449821673c
commit f230fa79bb
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -353,22 +353,28 @@ class Dependencies:
wants_sudo = not (self._is_docker or os.getuid() == 0) wants_sudo = not (self._is_docker or os.getuid() == 0)
pkg_manager = self.pkg_manager or PackageManagers.scan() pkg_manager = self.pkg_manager or PackageManagers.scan()
if self.packages and pkg_manager: if self.packages and pkg_manager:
yield ' '.join( installed_packages = pkg_manager.value.get_installed()
[ to_install = sorted(
*(['sudo'] if wants_sudo else []), pkg
*pkg_manager.value.install, for pkg in self.packages # type: ignore
*sorted( if pkg not in installed_packages
pkg and not (
for pkg in self.packages # type: ignore self.install_context == InstallContext.VENV
if not ( and self._is_python_pkg(pkg)
self.install_context == InstallContext.VENV )
and self._is_python_pkg(pkg)
)
),
]
) )
if to_install:
yield ' '.join(
[
*(['sudo'] if wants_sudo else []),
*pkg_manager.value.install,
*to_install,
]
)
def to_pip_install_commands(self, full_command=True) -> Generator[str, None, None]: def to_pip_install_commands(self, full_command=True) -> Generator[str, None, None]:
""" """
Generates the pip commands required to install the given dependencies on Generates the pip commands required to install the given dependencies on