pipx/pipx_info: multiple fixes (#9044)

* pipx_info: factored process_list out

* pipx_info: no need to pass param to _list

* pipx_info: minor adjustment

* pipx mod utils: make_process_list parameters

* fix test for state=install_all

* fix assertions

* pipx tests: fix detection of pipx 1.7.0

* pipx: use make_process_output

* add testcase

* pipx: remove import json

* pinned in pipx list is not always there

* Update plugins/modules/pipx_info.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* remove ensurepath and --user from pipx install

* add changelog frag

* Update changelogs/fragments/9044-pipx-fixes.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update changelogs/fragments/9044-pipx-fixes.yml

* Update changelogs/fragments/9044-pipx-fixes.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update changelogs/fragments/9044-pipx-fixes.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Alexei Znamensky 2024-11-03 05:50:24 +13:00 committed by GitHub
commit 2429e228a4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 165 additions and 176 deletions

View file

@ -1,91 +0,0 @@
{
"pipx_spec_version": "0.1",
"venvs": {
"black": {
"metadata": {
"injected_packages": {},
"main_package": {
"app_paths": [
{
"__Path__": "/home/az/.local/pipx/venvs/black/bin/black",
"__type__": "Path"
},
{
"__Path__": "/home/az/.local/pipx/venvs/black/bin/blackd",
"__type__": "Path"
}
],
"app_paths_of_dependencies": {},
"apps": [
"black",
"blackd"
],
"apps_of_dependencies": [],
"include_apps": true,
"include_dependencies": false,
"man_pages": [],
"man_pages_of_dependencies": [],
"man_paths": [],
"man_paths_of_dependencies": {},
"package": "black",
"package_or_url": "black",
"package_version": "24.8.0",
"pinned": false,
"pip_args": [],
"suffix": ""
},
"pipx_metadata_version": "0.5",
"python_version": "Python 3.11.9",
"source_interpreter": {
"__Path__": "/home/az/.pyenv/versions/3.11.9/bin/python3.11",
"__type__": "Path"
},
"venv_args": []
}
},
"pycowsay": {
"metadata": {
"injected_packages": {},
"main_package": {
"app_paths": [
{
"__Path__": "/home/az/.local/pipx/venvs/pycowsay/bin/pycowsay",
"__type__": "Path"
}
],
"app_paths_of_dependencies": {},
"apps": [
"pycowsay"
],
"apps_of_dependencies": [],
"include_apps": true,
"include_dependencies": false,
"man_pages": [
"man6/pycowsay.6"
],
"man_pages_of_dependencies": [],
"man_paths": [
{
"__Path__": "/home/az/.local/pipx/venvs/pycowsay/share/man/man6/pycowsay.6",
"__type__": "Path"
}
],
"man_paths_of_dependencies": {},
"package": "pycowsay",
"package_or_url": "pycowsay",
"package_version": "0.0.0.2",
"pinned": false,
"pip_args": [],
"suffix": ""
},
"pipx_metadata_version": "0.5",
"python_version": "Python 3.11.9",
"source_interpreter": {
"__Path__": "/home/az/.pyenv/versions/3.11.9/bin/python3.11",
"__type__": "Path"
},
"venv_args": []
}
},
}
}

View file

@ -1,3 +0,0 @@
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

View file

@ -0,0 +1,7 @@
---
# 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
dependencies:
- setup_remote_tmp_dir

View file

@ -3,10 +3,22 @@
# 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
- name: install pipx
pip:
name: pipx
extra_args: --user
- name: Determine pipx level
block:
- name: Install pipx>=1.7.0
pip:
name: pipx>=1.7.0
- name: Set has_pipx170 fact true
ansible.builtin.set_fact:
has_pipx170: true
rescue:
- name: Set has_pipx170 fact false
ansible.builtin.set_fact:
has_pipx170: false
- name: Install pipx (no version spec)
pip:
name: pipx
##############################################################################
- name: ensure application tox is uninstalled
@ -233,26 +245,21 @@
- name: Include testcase for issue 8656
ansible.builtin.include_tasks: testcase-8656.yml
- name: install pipx
pip:
name: pipx>=1.7.0
extra_args: --user
ignore_errors: true
register: pipx170_install
- name: Recent features
when:
- pipx170_install is not failed
- pipx170_install is changed
- 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
ansible.builtin.include_tasks: testcase-8809-install-all.yml
ansible.builtin.include_tasks: testcase-8809-installall.yml
- name: Include testcase for PR 8809 pin
ansible.builtin.include_tasks: testcase-8809-pin.yml
- name: Include testcase for PR 8809 injectpkg
ansible.builtin.include_tasks: testcase-8809-uninjectpkg.yml
- name: Include testcase for PR 9009 injectpkg --global
ansible.builtin.include_tasks: testcase-9009-fixglobal.yml

View file

@ -24,10 +24,39 @@
- pycowsay
register: uninstall_all_1
- name: Install pycowsay and black
community.general.pipx:
state: install
name: "{{ item }}"
loop:
- black
- pycowsay
register: install_all_1
- name: Generate JSON spec
community.general.pipx_info:
include_raw: true
register: pipx_list
- name: Copy content
ansible.builtin.copy:
content: "{{ pipx_list.raw_output }}"
dest: "{{ remote_tmp_dir }}/spec.json"
mode: "0644"
- name: Uninstall pycowsay and black (again)
community.general.pipx:
state: uninstall
name: "{{ item }}"
loop:
- black
- pycowsay
register: uninstall_all_2
- name: Use install-all
community.general.pipx:
state: install-all
spec_metadata: spec.json
state: install_all
spec_metadata: "{{ remote_tmp_dir }}/spec.json"
register: install_all
- name: Run pycowsay (should succeed)
@ -47,13 +76,14 @@
loop:
- black
- pycowsay
register: uninstall_all_2
register: uninstall_all_3
- name: Assert uninstall-all
ansible.builtin.assert:
that:
- uninstall_all_1 is not changed
- install_all_1 is changed
- uninstall_all_2 is changed
- install_all is changed
- "'Moooooooo!' in what_the_cow_said.stdout"
- "'/usr/local/bin/pycowsay' in which_cow.stdout"
- uninstall_all_2 is changed
- uninstall_all_3 is changed

View file

@ -60,10 +60,10 @@
- pycowsay
register: uninstall_all_2
- name: Assert uninstall-all
- name: Assert pin/unpin
ansible.builtin.assert:
that:
- pin_cow is changed
- cow_info_1 == "0.0.0.1"
- cow_info_1.application.0.version == "0.0.0.1"
- unpin_cow is changed
- cow_info_2 != "0.0.0.1"
- cow_info_2.application.0.version != "0.0.0.1"

View file

@ -64,6 +64,6 @@
ansible.builtin.assert:
that:
- pin_cow is changed
- cow_info_1 == "0.0.0.1"
- cow_info_1.application.0.version == "0.0.0.1"
- unpin_cow is changed
- cow_info_2 != "0.0.0.1"
- cow_info_2.application.0.version != "0.0.0.1"

View file

@ -0,0 +1,30 @@
---
# 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
- name: 9009-Ensure application pylint is uninstalled
community.general.pipx:
name: pylint
state: absent
global: true
- name: 9009-Install application pylint
community.general.pipx:
name: pylint
global: true
register: install_pylint
- name: 9009-Inject packages
community.general.pipx:
state: inject
name: pylint
global: true
inject_packages:
- licenses
- name: 9009-Ensure application pylint is uninstalled
community.general.pipx:
name: pylint
state: absent
global: true