Skip to content
This repository was archived by the owner on Mar 30, 2025. It is now read-only.

Commit 489fa91

Browse files
authored
Merge pull request #255 from staticdev/bugfix/install-pipx-without-pip
Fix pipx install for Debian 12
2 parents 2b96f3f + f247337 commit 489fa91

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

meta/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ galaxy_info:
2929
- pyenv
3030
- pipx
3131
- precommit
32+
- tox
3233
- workstation
3334

3435
dependencies:

tasks/custom_facts.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
- name: Set command path based on distribution
3+
ansible.builtin.set_fact:
4+
pipx_path: "{{ '/usr/bin' if ansible_distribution_release == 'bookworm' else ansible_env.HOME + '/.local/bin' }}"

tasks/main.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
---
2+
- name: Load custom facts
3+
ansible.builtin.import_tasks: custom_facts.yml
4+
25
- name: Install pyenv
36
ansible.builtin.import_role:
47
name: staticdev.pyenv
@@ -17,16 +20,21 @@
1720
- python3-venv # needed for nox
1821

1922
- name: Check if pipx is installed
20-
ansible.builtin.command: "{{ ansible_env.HOME }}/.local/bin/pipx --version"
23+
ansible.builtin.command: "{{ pipx_path }}/pipx --version"
2124
register: pipx_version_cmd
2225
changed_when: false
2326
ignore_errors: true
2427

25-
- name: Install pipx
28+
- name: Install pipx on Debian Bookworm
29+
ansible.builtin.package:
30+
name: pipx
31+
when: pipx_version_cmd is failed and ansible_distribution_release == 'bookworm'
32+
33+
- name: Install pipx on non-Bookworm OS
2634
ansible.builtin.pip:
2735
name: pipx
2836
extra_args: --user
29-
when: pipx_version_cmd is failed
37+
when: pipx_version_cmd is failed and ansible_distribution_release != 'bookworm'
3038

3139
- name: Check if pre-commit is installed
3240
ansible.builtin.command: "{{ ansible_env.HOME }}/.local/bin/pre-commit --version"
@@ -35,7 +43,7 @@
3543
ignore_errors: true
3644

3745
- name: Install pre-commit
38-
ansible.builtin.command: "{{ ansible_env.HOME }}/.local/bin/pipx install pre-commit"
46+
ansible.builtin.command: "{{ pipx_path }}/pipx install pre-commit"
3947
register: output
4048
changed_when: "output.rc == 0"
4149
when: pre_commit_check is failed
@@ -44,9 +52,10 @@
4452
ansible.builtin.stat:
4553
path: "{{ ansible_env.HOME }}/.local/pipx/venvs/cookiecutter"
4654
register: cookiecutter_folder_check
55+
ignore_errors: true
4756

4857
- name: Install cookiecutter
49-
ansible.builtin.command: "{{ ansible_env.HOME }}/.local/bin/pipx install cookiecutter"
58+
ansible.builtin.command: "{{ pipx_path }}/pipx install cookiecutter"
5059
register: output
5160
changed_when: "output.rc == 0"
5261
when: cookiecutter_folder_check is failed
@@ -79,13 +88,13 @@
7988
ignore_errors: true
8089

8190
- name: Install nox
82-
ansible.builtin.command: "{{ ansible_env.HOME }}/.local/bin/pipx install nox"
91+
ansible.builtin.command: "{{ pipx_path }}/pipx install nox"
8392
register: output
8493
changed_when: "output.rc == 0"
8594
when: nox_version_cmd is failed
8695

8796
- name: Install nox-poetry
88-
ansible.builtin.command: "{{ ansible_env.HOME }}/.local/bin/pipx inject nox nox-poetry"
97+
ansible.builtin.command: "{{ pipx_path }}/pipx inject nox nox-poetry"
8998
register: output
9099
changed_when: "output.rc == 0"
91100
when: nox_version_cmd is failed
@@ -97,7 +106,7 @@
97106
ignore_errors: true
98107

99108
- name: Install tox
100-
ansible.builtin.command: "{{ ansible_env.HOME }}/.local/bin/pipx install tox"
109+
ansible.builtin.command: "{{ pipx_path }}/pipx install tox"
101110
register: output
102111
changed_when: "output.rc == 0"
103112
when: tox_version_cmd is failed

0 commit comments

Comments
 (0)