Skip to content

Commit

Permalink
role ibridges: use pipx to install ibridges
Browse files Browse the repository at this point in the history
  • Loading branch information
dometto committed Jul 1, 2024
1 parent df8710b commit 4bc0835
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

## Summary

Installs `pip` packages to a common location so that the can be used by all users on a machine. **An ordinary `pip install` as user `root` is not recommended, as it may interfere with `pip` packages installed by the system package manager (e.g. `apt`). So instead, use this role** to install packages to `/usr/local/pip` (by default).
Installs python-based applications to a common location that can be used by all users on a machine, using [pipx](https://pipx.pypa.io/stable/). **An ordinary `pip install` as user `root` is not recommended, as it may interfere with `pip` packages installed by the system package manager (e.g. `apt`). So instead, use this role** to install applications to `/usr/local/uu-pip` (by default).

Note: `pipx` should only be used to install (GUI or command line) applications, not libraries!

## Requires

Expand All @@ -23,6 +25,7 @@ This role:
- `pipx_install_systemwide_executable`: String. Path to the Python executable to use for installing. Default: omitted.
- `pipx_install_systemwide_location`: String. Default: `/usr/local/pip`.
- `pipx_install_systemwide_profile`: String. Name of the script to be placed in `/etc/profile.d` updating the user's path. Default: `uu-custom-pip.sh`. Will not be created when empty.
- `pipx_install_systemwide_python`: String. Optinal. Path to the location of a python interpreter to be used for installing the app.

Note that if you first use this role to install something to `/usr/local/uu-pip`, and then again to install something else to `/var/pip`, this would cause the default `pipx_install_systemwide_location` (`/etc/profile.d/uu-custom-pip.sh`) to be overwritten, so that only `/var/pip` will be on the path. To remedy this, be sure to specify a custom `pipx_install_systemwide_profile` when you use a `pipx_install_systemwide_location` other than the default.

Expand Down
11 changes: 5 additions & 6 deletions playbooks/roles/ibridges/tasks/gui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
include_tasks: 'ubuntu.yml'

- name: Install iBridges GUI to systemwide location
pip:
name:
- setuptools
- wheel
- ibridgesgui
executable: "{{ ibridges_gui_pip_path }}"
include_role:
name: pipx_install_systemwide
vars:
pipx_install_systemwide_packages: ibridgesgui
pipx_install_systemwide_python: "{{ ibridges_python_path | default(omit) }}"

- name: Install desktop file menu item through role
include_role:
Expand Down
13 changes: 7 additions & 6 deletions playbooks/roles/ibridges/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
- name: Install iBridges to systemwide location
include_role:
name: pip_install_systemwide
vars:
pip_install_systemwide_packages: ibridges

- name: Install iBridges GUI
when: fact_desktop_workspace
include_tasks: gui.yml

- name: Install iBridges to systemwide location
include_role:
name: pipx_install_systemwide
vars:
pipx_install_systemwide_packages: ibridges
pipx_install_systemwide_python: "{{ ibridges_python_path | default(omit) }}"
16 changes: 2 additions & 14 deletions playbooks/roles/ibridges/tasks/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
include_role:
name: system_python

- name: Set ibridges_gui_python_version
- name: Set ibridges_python_path
set_fact:
ibridges_gui_python_version: '3.9'
ibridges_python_path: "/usr/bin/python3.9"

- name: Install GUI dependencies
package:
Expand All @@ -17,15 +17,3 @@
with_items:
- libxcb-cursor0
- software-properties-common

- name: Set ibridges_gui_python_path
set_fact:
ibridges_gui_python_path: "/usr/bin/python{{ ibridges_gui_python_version | default('3') }}"

- name: Set ibridges_gui_pip_path
set_fact:
ibridges_gui_pip_path: "/usr/local/bin/pip{{ ibridges_gui_python_version | default('') }}"

- name: Set ibridges_gui_install_location
set_fact:
ibridges_gui_install_location: "/usr/local/uu-pip"
2 changes: 1 addition & 1 deletion playbooks/roles/ibridges/templates/ibridges-gui.desktop.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Desktop Entry]
Encoding=UTF-8
Name=iBridges
Exec={{ ibridges_gui_python_path }} /usr/local/bin/ibridges-gui
Exec=/usr/local/uu-pip/bin/ibridges-gui
Icon={{ desktopfile_app_name }}
Terminal=False
Type=Application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
include_role:
name: pipx_install_systemwide
vars:
pipx_install_systemwide_packages: 'docker'
pipx_install_systemwide_packages:
- ibridges
- pycowsay

0 comments on commit 4bc0835

Please sign in to comment.