From d393b16064bc2a76f7729954ef54ba67f5bca888 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Thu, 20 Apr 2023 05:21:40 +0000 Subject: [PATCH] [PR #6303/996fc8c1 backport][stable-6] pipx: fix state=latest w/ install_deps=true (#6377) pipx: fix state=latest w/ install_deps=true (#6303) * pipx and pipx_info: Document that modules require pipx 0.16.2.1 or above Since their introduction, these modules rely on 'pipx list --json' to return machine-readable output about installed pipx applications. That functionality was introduced in 0.16.2, along with a critical bug fix (invalid json) in 0.16.2.1. * pipx: fix state=latest with install_deps=true "pipx upgrade" stopped supporting the "--include-deps" option ("install_deps" in the ansible module) in pipx 0.15 (https://pypa.github.io/pipx/changelog/#01500). The lack of support causes the pipx module to fail if attempting to use state=latest with install_deps, since the parameter is passed to both pipx install (fine) and pipx upgrade (fails). * Add changelog fragment (cherry picked from commit 996fc8c18e43dcadf32c06ef6179d8b1d0c3bae5) Co-authored-by: Paul Aurich --- ...tate-latest-and-add-system-site-packages.yml | 2 ++ plugins/modules/pipx.py | 7 ++++--- plugins/modules/pipx_info.py | 1 + tests/integration/targets/pipx/tasks/main.yml | 17 +++++++++++++++++ 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/6303-pipx-fix-state-latest-and-add-system-site-packages.yml diff --git a/changelogs/fragments/6303-pipx-fix-state-latest-and-add-system-site-packages.yml b/changelogs/fragments/6303-pipx-fix-state-latest-and-add-system-site-packages.yml new file mode 100644 index 0000000000..1600c8252c --- /dev/null +++ b/changelogs/fragments/6303-pipx-fix-state-latest-and-add-system-site-packages.yml @@ -0,0 +1,2 @@ +bugfixes: + - pipx - fixed handling of ``install_deps=true`` with ``state=latest`` and ``state=upgrade`` (https://github.com/ansible-collections/community.general/pull/6303). diff --git a/plugins/modules/pipx.py b/plugins/modules/pipx.py index 9c1c74470d..dfa2f4300f 100644 --- a/plugins/modules/pipx.py +++ b/plugins/modules/pipx.py @@ -57,7 +57,7 @@ options: install_deps: description: - Include applications of dependent packages. - - Only used when I(state=install), I(state=latest), I(state=upgrade), or I(state=inject). + - Only used when I(state=install), I(state=latest), or I(state=inject). type: bool default: false inject_packages: @@ -120,6 +120,7 @@ notes: - > This module will honor C(pipx) environment variables such as but not limited to C(PIPX_HOME) and C(PIPX_BIN_DIR) passed using the R(environment Ansible keyword, playbooks_environment). + - This module requires C(pipx) version 0.16.2.1 or above. - Please note that C(pipx) requires Python 3.6 or above. - > This first implementation does not verify whether a specified version constraint has been installed or not. @@ -263,7 +264,7 @@ class PipX(StateModuleHelper): if self.vars.force: self.changed = True - with self.runner('state include_injected index_url install_deps force editable pip_args name', check_mode_skip=True) as ctx: + with self.runner('state include_injected index_url force editable pip_args name', check_mode_skip=True) as ctx: ctx.run() self._capture_results(ctx) @@ -316,7 +317,7 @@ class PipX(StateModuleHelper): ctx.run(state='install', name_source=[self.vars.name, self.vars.source]) self._capture_results(ctx) - with self.runner('state include_injected index_url install_deps force editable pip_args name', check_mode_skip=True) as ctx: + with self.runner('state include_injected index_url force editable pip_args name', check_mode_skip=True) as ctx: ctx.run(state='upgrade') self._capture_results(ctx) diff --git a/plugins/modules/pipx_info.py b/plugins/modules/pipx_info.py index 4487cdab5a..e2bb7fdaef 100644 --- a/plugins/modules/pipx_info.py +++ b/plugins/modules/pipx_info.py @@ -53,6 +53,7 @@ notes: - > This module will honor C(pipx) environment variables such as but not limited to C(PIPX_HOME) and C(PIPX_BIN_DIR) passed using the R(environment Ansible keyword, playbooks_environment). + - This module requires C(pipx) version 0.16.2.1 or above. - Please note that C(pipx) requires Python 3.6 or above. - See also the C(pipx) documentation at U(https://pypa.github.io/pipx/). author: diff --git a/tests/integration/targets/pipx/tasks/main.yml b/tests/integration/targets/pipx/tasks/main.yml index cb74d47ac2..567405ec49 100644 --- a/tests/integration/targets/pipx/tasks/main.yml +++ b/tests/integration/targets/pipx/tasks/main.yml @@ -184,6 +184,19 @@ name: tox register: uninstall_tox_latest_again +- name: install application tox with deps + community.general.pipx: + state: latest + name: tox + install_deps: true + register: install_tox_with_deps + +- name: cleanup tox latest yet again + community.general.pipx: + state: absent + name: tox + register: uninstall_tox_again + - name: check assertions tox latest assert: that: @@ -198,6 +211,10 @@ - install_tox_latest_with_preinstall_again_force is changed - install_tox_latest_with_preinstall_again_force.application.tox.version == latest_tox_version - uninstall_tox_latest_again is changed + - install_tox_with_deps is changed + - install_tox_with_deps.application.tox.version == latest_tox_version + - uninstall_tox_again is changed + - "'tox' not in uninstall_tox_again.application" ############################################################################## - name: ensure application ansible-lint is uninstalled