mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-27 23:21:22 -07:00
pipx: accept python version specs in parameter name
(#10031)
* pipx: accept python version specs in parameter "name" * pipx_info: adjustment for backward compatibility * remove unnecessary comprehension * remove f-str * no shebang for module utils * remove f-str * fix syntax error * fix pipx_info * rollback adjustments in existing tests * docs & test update * add debugging tasks to int test * integration test checks for version of packaging * move assertion to block * fix idempotency when using version specifier * add changelog frag * fix docs * dial down the version of tox used in tests To accommodate old Pythons * Update plugins/modules/pipx.py * Apply suggestions from code review * refactor/rename package requirements code * fix filename in BOTMETA * Update plugins/modules/pipx.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/pipx.py Co-authored-by: Felix Fontein <felix@fontein.de> * pipx mod utils: create make_process_dict and deprecate make_process_list * pkg_req: make method private * make_process_dict is simpler and more specialized * ensure version specifiers are honored when state=install * fix insanity * pipx: reformat yaml blocks * pipx: doc wordsmithing --------- Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
626ee3115d
commit
2b4cb6dabc
8 changed files with 302 additions and 64 deletions
|
@ -6,7 +6,7 @@
|
|||
- name: Determine pipx level
|
||||
block:
|
||||
- name: Install pipx>=1.7.0
|
||||
pip:
|
||||
ansible.builtin.pip:
|
||||
name: pipx>=1.7.0
|
||||
- name: Set has_pipx170 fact true
|
||||
ansible.builtin.set_fact:
|
||||
|
@ -16,9 +16,24 @@
|
|||
ansible.builtin.set_fact:
|
||||
has_pipx170: false
|
||||
- name: Install pipx (no version spec)
|
||||
pip:
|
||||
ansible.builtin.pip:
|
||||
name: pipx
|
||||
|
||||
- name: Determine packaging level
|
||||
block:
|
||||
- name: Install packaging>=22.0
|
||||
ansible.builtin.pip:
|
||||
name: packaging>=22.0
|
||||
- name: Set has_packaging22 fact true
|
||||
ansible.builtin.set_fact:
|
||||
has_packaging22: true
|
||||
rescue:
|
||||
- name: Set has_packaging22 fact false
|
||||
ansible.builtin.set_fact:
|
||||
has_packaging22: false
|
||||
- name: Install has_packaging (no version spec)
|
||||
ansible.builtin.pip:
|
||||
name: packaging
|
||||
|
||||
##############################################################################
|
||||
- name: ensure application tox is uninstalled
|
||||
|
@ -208,26 +223,31 @@
|
|||
community.general.pipx:
|
||||
state: absent
|
||||
name: tox
|
||||
register: uninstall_tox_again
|
||||
register: uninstall_tox_latest_yet_again
|
||||
|
||||
- name: check assertions tox latest
|
||||
assert:
|
||||
that:
|
||||
- install_tox_latest is changed
|
||||
- "'tox' in install_tox_latest.application"
|
||||
- install_tox_latest.application.tox.version != '3.24.0'
|
||||
- uninstall_tox_latest is changed
|
||||
- "'tox' not in uninstall_tox_latest.application"
|
||||
- install_tox_324_for_latest is changed
|
||||
- "'tox' in install_tox_324_for_latest.application"
|
||||
- install_tox_324_for_latest.application.tox.version == '3.24.0'
|
||||
- install_tox_latest_with_preinstall is changed
|
||||
- install_tox_latest_with_preinstall.application.tox.version == latest_tox_version
|
||||
- "'tox' in install_tox_latest_with_preinstall.application"
|
||||
- install_tox_latest_with_preinstall.application.tox.version != '3.24.0'
|
||||
- install_tox_latest_with_preinstall_again is not changed
|
||||
- install_tox_latest_with_preinstall_again.application.tox.version == latest_tox_version
|
||||
- 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"
|
||||
- "'tox' not in uninstall_tox_latest_again.application"
|
||||
|
||||
##############################################################################
|
||||
# Test version specifiers in name parameter
|
||||
- name: Run version specifier tests
|
||||
ansible.builtin.include_tasks: testcase-10031-version-specs.yml
|
||||
|
||||
##############################################################################
|
||||
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# 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
|
||||
|
||||
##############################################################################
|
||||
# Test version specifiers in name parameter
|
||||
|
||||
- name: Ensure tox is uninstalled
|
||||
community.general.pipx:
|
||||
state: absent
|
||||
name: tox
|
||||
register: uninstall_tox
|
||||
|
||||
- name: Install tox with version specifier in name
|
||||
community.general.pipx:
|
||||
name: tox>=3.22.0,<3.27.0
|
||||
register: install_tox_version
|
||||
|
||||
- name: Install tox with same version specifier (idempotency check)
|
||||
community.general.pipx:
|
||||
name: tox>=3.22.0,<3.27.0
|
||||
register: install_tox_version_again
|
||||
|
||||
- name: Ensure tox is uninstalled again
|
||||
community.general.pipx:
|
||||
state: absent
|
||||
name: tox
|
||||
|
||||
- name: Install tox with extras and version
|
||||
community.general.pipx:
|
||||
name: "tox[testing]>=3.22.0,<3.27.0"
|
||||
register: install_tox_extras
|
||||
ignore_errors: true # Some versions might not have this extra
|
||||
|
||||
- name: Install tox with higher version specifier
|
||||
community.general.pipx:
|
||||
name: "tox>=3.27.0"
|
||||
register: install_tox_higher_version
|
||||
|
||||
- name: Install tox with higher version specifier (force)
|
||||
community.general.pipx:
|
||||
name: "tox>=3.27.0"
|
||||
force: true
|
||||
register: install_tox_higher_version_force
|
||||
|
||||
- name: Cleanup tox
|
||||
community.general.pipx:
|
||||
state: absent
|
||||
name: tox
|
||||
register: uninstall_tox_final
|
||||
|
||||
- name: Check version specifier assertions
|
||||
assert:
|
||||
that:
|
||||
- install_tox_version is changed
|
||||
- "'tox' in install_tox_version.application"
|
||||
- "install_tox_version.application.tox.version is version('3.22.0', '>=')"
|
||||
- "install_tox_version.application.tox.version is version('3.27.0', '<')"
|
||||
- install_tox_version_again is not changed
|
||||
- "'tox' in install_tox_extras.application"
|
||||
- "install_tox_extras.application.tox.version is version('3.22.0', '>=')"
|
||||
- "install_tox_extras.application.tox.version is version('3.27.0', '<')"
|
||||
- install_tox_higher_version is changed
|
||||
- install_tox_higher_version_force is changed
|
||||
- uninstall_tox_final is changed
|
||||
- "'tox' not in uninstall_tox_final.application"
|
||||
|
||||
- name: If packaging is recent
|
||||
when:
|
||||
- has_packaging22
|
||||
block:
|
||||
- name: Install tox with invalid version specifier
|
||||
community.general.pipx:
|
||||
name: "tox>>>>>3.27.0"
|
||||
register: install_tox_invalid
|
||||
ignore_errors: true
|
||||
|
||||
- name: Check version specifier assertions
|
||||
assert:
|
||||
that:
|
||||
- install_tox_invalid is failed
|
||||
- "'Invalid package specification' in install_tox_invalid.msg"
|
Loading…
Add table
Add a link
Reference in a new issue