pyinfra.modules.util.packaging¶
-
pyinfra.modules.util.packaging.
ensure_packages
(packages, current_packages, present, install_command, uninstall_command, latest=False, upgrade_command=None, version_join=None, lower=True)¶ Handles this common scenario:
- We have a list of packages(/versions) to ensure
- We have a map of existing package -> versions
- We have the common command bits (install, uninstall, version “joiner”)
- Outputs commands to ensure our desired packages/versions
- Optionally upgrades packages w/o specified version when present
Parameters: - packages (list) – list of packages or package/versions
- current_packages (fact) – fact returning dict of package names -> version
- present (bool) – whether packages should exist or not
- install_command (str) – command to prefix to list of packages to install
- uninstall_command (str) – as above for uninstalling packages
- latest (bool) – whether to upgrade installed packages when present
- upgrade_command (str) – as above for upgrading
- version_join (str) – the package manager specific “joiner”, ie
=
for<apt_pkg>=<version>
- lower (bool) – whether to lowercase package names