Prepare for version 11: pipx/pipx_info (#10137)

* Remove various deprecated module helper things.

* pipx/pipx_info: pipx 1.7.0 required from c.g. 11.0.0 onwards

* restore chglog frag

* add changelog frag

* fix chglog

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Alexei Znamensky 2025-05-28 08:55:41 +12:00 committed by GitHub
parent 13e3aed86d
commit a249996f91
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 61 additions and 63 deletions

View file

@ -0,0 +1,3 @@
removed_features:
- pipx - module no longer supports ``pipx`` older than 1.7.0 (https://github.com/ansible-collections/community.general/pull/10137).
- pipx_info - module no longer supports ``pipx`` older than 1.7.0 (https://github.com/ansible-collections/community.general/pull/10137).

View file

@ -14,9 +14,6 @@ options:
global: global:
description: description:
- The module will pass the C(--global) argument to C(pipx), to execute actions in global scope. - The module will pass the C(--global) argument to C(pipx), to execute actions in global scope.
- The C(--global) is only available in C(pipx>=1.6.0), so make sure to have a compatible version when using this option.
Moreover, a nasty bug with C(--global) was fixed in C(pipx==1.7.0), so it is strongly recommended you used that version
or newer.
type: bool type: bool
default: false default: false
executable: executable:
@ -25,10 +22,9 @@ options:
- If not specified, the module will use C(python -m pipx) to run the tool, using the same Python interpreter as ansible - If not specified, the module will use C(python -m pipx) to run the tool, using the same Python interpreter as ansible
itself. itself.
type: path type: path
requirements:
- This module requires C(pipx) version 1.7.0 or above. Please note that C(pipx) 1.7.0 requires Python 3.8 or above.
notes: notes:
- This module requires C(pipx) version 0.16.2.1 or above. From community.general 11.0.0 onwards, the module will require
C(pipx>=1.7.0).
- Please note that C(pipx) requires Python 3.6 or above.
- This module does not install the C(pipx) python package, however that can be easily done with the module M(ansible.builtin.pip). - This module does not install the C(pipx) python package, however that can be easily done with the module M(ansible.builtin.pip).
- This module does not require C(pipx) to be in the shell C(PATH), but it must be loadable by Python as a module. - This module does not require C(pipx) to be in the shell C(PATH), but it must be loadable by Python as a module.
- This module will honor C(pipx) environment variables such as but not limited to E(PIPX_HOME) and E(PIPX_BIN_DIR) passed - This module will honor C(pipx) environment variables such as but not limited to E(PIPX_HOME) and E(PIPX_BIN_DIR) passed

View file

@ -211,6 +211,7 @@ version:
from ansible_collections.community.general.plugins.module_utils.module_helper import StateModuleHelper from ansible_collections.community.general.plugins.module_utils.module_helper import StateModuleHelper
from ansible_collections.community.general.plugins.module_utils.pipx import pipx_runner, pipx_common_argspec, make_process_dict from ansible_collections.community.general.plugins.module_utils.pipx import pipx_runner, pipx_common_argspec, make_process_dict
from ansible_collections.community.general.plugins.module_utils.pkg_req import PackageRequirement from ansible_collections.community.general.plugins.module_utils.pkg_req import PackageRequirement
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
from ansible.module_utils.facts.compat import ansible_facts from ansible.module_utils.facts.compat import ansible_facts
@ -293,6 +294,9 @@ class PipX(StateModuleHelper):
rc, out, err = ctx.run() rc, out, err = ctx.run()
self.vars.version = out.strip() self.vars.version = out.strip()
if LooseVersion(self.vars.version) < LooseVersion("1.7.0"):
self.do_raise("The pipx tool must be at least at version 1.7.0")
def __quit_module__(self): def __quit_module__(self):
self.vars.application = self._retrieve_installed() self.vars.application = self._retrieve_installed()

View file

@ -127,6 +127,7 @@ version:
from ansible_collections.community.general.plugins.module_utils.module_helper import ModuleHelper from ansible_collections.community.general.plugins.module_utils.module_helper import ModuleHelper
from ansible_collections.community.general.plugins.module_utils.pipx import pipx_runner, pipx_common_argspec, make_process_dict from ansible_collections.community.general.plugins.module_utils.pipx import pipx_runner, pipx_common_argspec, make_process_dict
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
from ansible.module_utils.facts.compat import ansible_facts from ansible.module_utils.facts.compat import ansible_facts
@ -156,6 +157,9 @@ class PipXInfo(ModuleHelper):
rc, out, err = ctx.run() rc, out, err = ctx.run()
self.vars.version = out.strip() self.vars.version = out.strip()
if LooseVersion(self.vars.version) < LooseVersion("1.7.0"):
self.do_raise("The pipx tool must be at least at version 1.7.0")
def __run__(self): def __run__(self):
output_process = make_process_dict(self.vars.include_injected, self.vars.include_deps) output_process = make_process_dict(self.vars.include_injected, self.vars.include_deps)
with self.runner('_list global', output_process=output_process) as ctx: with self.runner('_list global', output_process=output_process) as ctx:

View file

@ -3,21 +3,13 @@
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
- name: Determine pipx level - name: Bail out if Python < 3.8
block: when: ansible_python_version is version('3.8', '<')
- name: Install pipx>=1.7.0 ansible.builtin.meta: end_play
ansible.builtin.pip: - name: Install pipx>=1.7.0
name: pipx>=1.7.0 ansible.builtin.pip:
- name: Set has_pipx170 fact true name: pipx>=1.7.0
ansible.builtin.set_fact: extra_args: --user
has_pipx170: true
rescue:
- name: Set has_pipx170 fact false
ansible.builtin.set_fact:
has_pipx170: false
- name: Install pipx (no version spec)
ansible.builtin.pip:
name: pipx
- name: Determine packaging level - name: Determine packaging level
block: block:
@ -266,27 +258,23 @@
- name: Include testcase for issue 8656 - name: Include testcase for issue 8656
ansible.builtin.include_tasks: testcase-8656.yml ansible.builtin.include_tasks: testcase-8656.yml
- name: Recent features - name: Include testcase for PR 8793 --global
when: ansible.builtin.include_tasks: testcase-8793-global.yml
- has_pipx170
block:
- name: Include testcase for PR 8793 --global
ansible.builtin.include_tasks: testcase-8793-global.yml
- name: Include testcase for PR 8809 install-all - name: Include testcase for PR 8809 install-all
ansible.builtin.include_tasks: testcase-8809-installall.yml ansible.builtin.include_tasks: testcase-8809-installall.yml
- name: Include testcase for PR 8809 pin - name: Include testcase for PR 8809 pin
ansible.builtin.include_tasks: testcase-8809-pin.yml ansible.builtin.include_tasks: testcase-8809-pin.yml
- name: Include testcase for PR 8809 injectpkg - name: Include testcase for PR 8809 injectpkg
ansible.builtin.include_tasks: testcase-8809-uninjectpkg.yml ansible.builtin.include_tasks: testcase-8809-uninjectpkg.yml
- name: Include testcase for PR 9009 injectpkg --global - name: Include testcase for PR 9009 injectpkg --global
ansible.builtin.include_tasks: testcase-9009-fixglobal.yml ansible.builtin.include_tasks: testcase-9009-fixglobal.yml
- name: Include testcase for PR 9103 upgrade --global - name: Include testcase for PR 9103 upgrade --global
ansible.builtin.include_tasks: testcase-9103-upgrade-global.yml ansible.builtin.include_tasks: testcase-9103-upgrade-global.yml
- name: Include testcase for issue 9619 latest --global - name: Include testcase for issue 9619 latest --global
ansible.builtin.include_tasks: testcase-9619-latest-global.yml ansible.builtin.include_tasks: testcase-9619-latest-global.yml

View file

@ -3,13 +3,16 @@
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
- name: install pipx - name: Bail out if Python < 3.8
pip: when: ansible_python_version is version('3.8', '<')
name: pipx ansible.builtin.meta: end_play
- name: Install pipx>=1.7.0
ansible.builtin.pip:
name: pipx>=1.7.0
extra_args: --user extra_args: --user
############################################################################## ##############################################################################
- name: ensure applications are uninstalled - name: Ensure applications are uninstalled
community.general.pipx: community.general.pipx:
name: "{{ item }}" name: "{{ item }}"
state: absent state: absent
@ -17,36 +20,36 @@
- tox - tox
- pylint - pylint
- name: retrieve applications (empty) - name: Retrieve applications (empty)
community.general.pipx_info: {} community.general.pipx_info: {}
register: info_empty register: info_empty
- name: install application tox - name: Install application tox
community.general.pipx: community.general.pipx:
name: tox name: tox
- name: retrieve applications - name: Retrieve applications
community.general.pipx_info: {} community.general.pipx_info: {}
register: info_all register: info_all
- name: retrieve applications (include_deps=true) - name: Retrieve applications (include_deps=true)
community.general.pipx_info: community.general.pipx_info:
include_deps: true include_deps: true
register: info_all_deps register: info_all_deps
- name: retrieve application tox - name: Retrieve application tox
community.general.pipx_info: community.general.pipx_info:
name: tox name: tox
include_deps: true include_deps: true
register: info_tox register: info_tox
- name: uninstall application tox - name: Uninstall application tox
community.general.pipx: community.general.pipx:
state: absent state: absent
name: tox name: tox
- name: check assertions tox - name: Check assertions tox
assert: ansible.builtin.assert:
that: that:
- info_empty.application|length == 0 - info_empty.application|length == 0
@ -66,8 +69,8 @@
- info_tox.application == info_all_deps.application - info_tox.application == info_all_deps.application
############################################################################## ##############################################################################
- name: set test applications - name: Set test applications
set_fact: ansible.builtin.set_fact:
apps: apps:
- name: tox - name: tox
source: tox==3.24.0 source: tox==3.24.0
@ -75,19 +78,19 @@
inject_packages: inject_packages:
- licenses - licenses
- name: ensure applications are uninstalled - name: Ensure applications are uninstalled
community.general.pipx: community.general.pipx:
name: "{{ item.name }}" name: "{{ item.name }}"
state: absent state: absent
loop: "{{ apps }}" loop: "{{ apps }}"
- name: install applications - name: Install applications
community.general.pipx: community.general.pipx:
name: "{{ item.name }}" name: "{{ item.name }}"
source: "{{ item.source | default(omit) }}" source: "{{ item.source | default(omit) }}"
loop: "{{ apps }}" loop: "{{ apps }}"
- name: inject packages - name: Inject packages
community.general.pipx: community.general.pipx:
state: inject state: inject
name: "{{ item.name }}" name: "{{ item.name }}"
@ -95,31 +98,31 @@
when: "'inject_packages' in item" when: "'inject_packages' in item"
loop: "{{ apps }}" loop: "{{ apps }}"
- name: retrieve applications - name: Retrieve applications
community.general.pipx_info: {} community.general.pipx_info: {}
register: info2_all register: info2_all
- name: retrieve applications (include_deps=true) - name: Retrieve applications (include_deps=true)
community.general.pipx_info: community.general.pipx_info:
include_deps: true include_deps: true
include_injected: true include_injected: true
register: info2_all_deps register: info2_all_deps
- name: retrieve application pylint - name: Retrieve application pylint
community.general.pipx_info: community.general.pipx_info:
name: pylint name: pylint
include_deps: true include_deps: true
include_injected: true include_injected: true
register: info2_lint register: info2_lint
- name: ensure applications are uninstalled - name: Ensure applications are uninstalled
community.general.pipx: community.general.pipx:
name: "{{ item.name }}" name: "{{ item.name }}"
state: absent state: absent
loop: "{{ apps }}" loop: "{{ apps }}"
- name: check assertions multiple apps - name: Check assertions multiple apps
assert: ansible.builtin.assert:
that: that:
- all_apps|length == 2 - all_apps|length == 2
- all_apps[1].name == "tox" - all_apps[1].name == "tox"
@ -138,6 +141,6 @@
- all_apps_deps|length == 2 - all_apps_deps|length == 2
- lint[0] == all_apps_deps[0] - lint[0] == all_apps_deps[0]
vars: vars:
all_apps: "{{ info2_all.application|sort(attribute='name') }}" all_apps: "{{ info2_all.application | sort(attribute='name') }}"
all_apps_deps: "{{ info2_all_deps.application | sort(attribute='name') }}" all_apps_deps: "{{ info2_all_deps.application | sort(attribute='name') }}"
lint: "{{ info2_lint.application | sort(attribute='name') }}" lint: "{{ info2_lint.application | sort(attribute='name') }}"