pipx/pipx_info: add parameter global (#8793)

* pipx/pipx_info: add new parameters

* add test for --global, refactor int test main file

* ensure initial state of test

* ensure PATH includes /usr/local/bin

* ensure PATH includes /usr/local/bin for entire block

* ensure minimum version of pip

* ensure pipx 1.6.0 is installed

* push recommendation for pipx 1.7.0 instead of 1.6.0

* add changelog frag

* add deprecatons to changelog frag

* add deprecatons to changelog frag, better

* Update changelogs/fragments/8793-pipx-global.yml

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

* Update changelogs/fragments/8793-pipx-global.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-08-26 20:21:09 +12:00 committed by GitHub
commit 9c9c4cbc3e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 355 additions and 207 deletions

View file

@ -217,158 +217,33 @@
- "'tox' not in uninstall_tox_again.application"
##############################################################################
- name: ensure application pylint is uninstalled
community.general.pipx:
name: pylint
state: absent
- name: install application pylint
community.general.pipx:
name: pylint
register: install_pylint
- name: Include testcase for inject packages
ansible.builtin.include_tasks: testcase-injectpkg.yml
- name: inject packages
community.general.pipx:
state: inject
name: pylint
inject_packages:
- licenses
register: inject_pkgs_pylint
- name: Include testcase for jupyter
ansible.builtin.include_tasks: testcase-jupyter.yml
- name: inject packages with apps
community.general.pipx:
state: inject
name: pylint
inject_packages:
- black
install_apps: true
register: inject_pkgs_apps_pylint
- name: Include testcase for old site-wide
ansible.builtin.include_tasks: testcase-oldsitewide.yml
- name: cleanup pylint
community.general.pipx:
state: absent
name: pylint
register: uninstall_pylint
- name: Include testcase for issue 7497
ansible.builtin.include_tasks: testcase-7497.yml
- name: check assertions inject_packages
assert:
that:
- install_pylint is changed
- inject_pkgs_pylint is changed
- '"pylint" in inject_pkgs_pylint.application'
- '"licenses" in inject_pkgs_pylint.application["pylint"]["injected"]'
- inject_pkgs_apps_pylint is changed
- '"pylint" in inject_pkgs_apps_pylint.application'
- '"black" in inject_pkgs_apps_pylint.application["pylint"]["injected"]'
- uninstall_pylint is changed
- name: Include testcase for issue 8656
ansible.builtin.include_tasks: testcase-8656.yml
##############################################################################
- name: install jupyter - not working smoothly in freebsd
# when: ansible_system != 'FreeBSD'
- 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
block:
- name: ensure application mkdocs is uninstalled
community.general.pipx:
name: mkdocs
state: absent
- name: install application mkdocs
community.general.pipx:
name: mkdocs
install_deps: true
register: install_mkdocs
- name: cleanup mkdocs
community.general.pipx:
state: absent
name: mkdocs
- name: check assertions
assert:
that:
- install_mkdocs is changed
- '"markdown_py" in install_mkdocs.stdout'
##############################################################################
- name: ensure /opt/pipx
ansible.builtin.file:
path: /opt/pipx
state: directory
mode: 0755
- name: install tox site-wide
community.general.pipx:
name: tox
state: latest
register: install_tox_sitewide
environment:
PIPX_HOME: /opt/pipx
PIPX_BIN_DIR: /usr/local/bin
- name: stat /usr/local/bin/tox
ansible.builtin.stat:
path: /usr/local/bin/tox
register: usrlocaltox
- name: check assertions
ansible.builtin.assert:
that:
- install_tox_sitewide is changed
- usrlocaltox.stat.exists
##############################################################################
# Test for issue 7497
- name: ensure application pyinstaller is uninstalled
community.general.pipx:
name: pyinstaller
state: absent
- name: Install Python Package pyinstaller
community.general.pipx:
name: pyinstaller
state: present
system_site_packages: true
pip_args: "--no-cache-dir"
register: install_pyinstaller
- name: cleanup pyinstaller
community.general.pipx:
name: pyinstaller
state: absent
- name: check assertions
assert:
that:
- install_pyinstaller is changed
##############################################################################
# Test for issue 8656
- name: ensure application conan2 is uninstalled
community.general.pipx:
name: conan2
state: absent
- name: Install Python Package conan with suffix 2 (conan2)
community.general.pipx:
name: conan
state: install
suffix: "2"
register: install_conan2
- name: Install Python Package conan with suffix 2 (conan2) again
community.general.pipx:
name: conan
state: install
suffix: "2"
register: install_conan2_again
- name: cleanup conan2
community.general.pipx:
name: conan2
state: absent
- name: check assertions
assert:
that:
- install_conan2 is changed
- "' - conan2' in install_conan2.stdout"
- install_conan2_again is not changed
- name: Include testcase for PR 8793 --global
ansible.builtin.include_tasks: testcase-8793-global.yml

View file

@ -0,0 +1,27 @@
---
# 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: ensure application pyinstaller is uninstalled
community.general.pipx:
name: pyinstaller
state: absent
- name: Install Python Package pyinstaller
community.general.pipx:
name: pyinstaller
state: present
system_site_packages: true
pip_args: "--no-cache-dir"
register: install_pyinstaller
- name: cleanup pyinstaller
community.general.pipx:
name: pyinstaller
state: absent
- name: check assertions
assert:
that:
- install_pyinstaller is changed

View file

@ -0,0 +1,35 @@
---
# 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: ensure application conan2 is uninstalled
community.general.pipx:
name: conan2
state: absent
- name: Install Python Package conan with suffix 2 (conan2)
community.general.pipx:
name: conan
state: install
suffix: "2"
register: install_conan2
- name: Install Python Package conan with suffix 2 (conan2) again
community.general.pipx:
name: conan
state: install
suffix: "2"
register: install_conan2_again
- name: cleanup conan2
community.general.pipx:
name: conan2
state: absent
- name: check assertions
assert:
that:
- install_conan2 is changed
- "' - conan2' in install_conan2.stdout"
- install_conan2_again is not changed

View file

@ -0,0 +1,58 @@
---
# 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: Set up environment
environment:
PATH: /usr/local/bin:{{ ansible_env.PATH }}
block:
- name: Remove global pipx dir
ansible.builtin.file:
path: /opt/pipx
state: absent
force: true
- name: Create global pipx dir
ansible.builtin.file:
path: /opt/pipx
state: directory
mode: '0755'
- name: Uninstall pycowsay
community.general.pipx:
state: uninstall
name: pycowsay
- name: Uninstall pycowsay (global)
community.general.pipx:
state: uninstall
name: pycowsay
global: true
- name: Run pycowsay (should fail)
ansible.builtin.command: pycowsay Moooooooo!
changed_when: false
ignore_errors: true
- name: Install pycowsay (global)
community.general.pipx:
state: install
name: pycowsay
global: true
- name: Run pycowsay (should succeed)
ansible.builtin.command: pycowsay Moooooooo!
changed_when: false
register: what_the_cow_said
- name: Which cow?
ansible.builtin.command: which pycowsay
changed_when: false
register: which_cow
- name: Assert Moooooooo
ansible.builtin.assert:
that:
- "'Moooooooo!' in what_the_cow_said.stdout"
- "'/usr/local/bin/pycowsay' in which_cow.stdout"

View file

@ -0,0 +1,49 @@
---
# 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: ensure application pylint is uninstalled
community.general.pipx:
name: pylint
state: absent
- name: install application pylint
community.general.pipx:
name: pylint
register: install_pylint
- name: inject packages
community.general.pipx:
state: inject
name: pylint
inject_packages:
- licenses
register: inject_pkgs_pylint
- name: inject packages with apps
community.general.pipx:
state: inject
name: pylint
inject_packages:
- black
install_apps: true
register: inject_pkgs_apps_pylint
- name: cleanup pylint
community.general.pipx:
state: absent
name: pylint
register: uninstall_pylint
- name: check assertions inject_packages
assert:
that:
- install_pylint is changed
- inject_pkgs_pylint is changed
- '"pylint" in inject_pkgs_pylint.application'
- '"licenses" in inject_pkgs_pylint.application["pylint"]["injected"]'
- inject_pkgs_apps_pylint is changed
- '"pylint" in inject_pkgs_apps_pylint.application'
- '"black" in inject_pkgs_apps_pylint.application["pylint"]["injected"]'
- uninstall_pylint is changed

View file

@ -0,0 +1,28 @@
---
# 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: install jupyter
block:
- name: ensure application mkdocs is uninstalled
community.general.pipx:
name: mkdocs
state: absent
- name: install application mkdocs
community.general.pipx:
name: mkdocs
install_deps: true
register: install_mkdocs
- name: cleanup mkdocs
community.general.pipx:
state: absent
name: mkdocs
- name: check assertions
assert:
that:
- install_mkdocs is changed
- '"markdown_py" in install_mkdocs.stdout'

View file

@ -0,0 +1,40 @@
---
# 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: Ensure /opt/pipx
ansible.builtin.file:
path: /opt/pipx
state: directory
mode: 0755
- name: Install tox site-wide
community.general.pipx:
name: tox
state: latest
register: install_tox_sitewide
environment:
PIPX_HOME: /opt/pipx
PIPX_BIN_DIR: /usr/local/bin
- name: stat /usr/local/bin/tox
ansible.builtin.stat:
path: /usr/local/bin/tox
register: usrlocaltox
- name: Uninstall tox site-wide
community.general.pipx:
name: tox
state: uninstall
register: uninstall_tox_sitewide
environment:
PIPX_HOME: /opt/pipx
PIPX_BIN_DIR: /usr/local/bin
- name: check assertions
ansible.builtin.assert:
that:
- install_tox_sitewide is changed
- usrlocaltox.stat.exists
- uninstall_tox_sitewide is changed