From 79d845b7105ca65fd5af2a4dcb536395c308ce68 Mon Sep 17 00:00:00 2001 From: Dawa Ometto Date: Mon, 11 Nov 2024 16:07:51 +0100 Subject: [PATCH] role poetry: remove and install via pipx instead --- docs/index.md | 1 - docs/playbooks/python-workbench.md | 4 ++-- molecule/playbook-python-workbench/verify.yml | 4 +++- playbooks/python-workbench.yml | 5 ++++- playbooks/roles/poetry/defaults/main.yml | 3 --- playbooks/roles/poetry/files/10-poetry.sh | 15 ------------- playbooks/roles/poetry/meta/main.yml | 5 ----- .../poetry/molecule/default/converge.yml | 8 ------- .../poetry/molecule/default/molecule.yml | 9 -------- .../roles/poetry/molecule/default/verify.yml | 18 ---------------- playbooks/roles/poetry/tasks/main.yml | 11 ---------- playbooks/roles/poetry/tasks/system_wide.yml | 21 ------------------- 12 files changed, 9 insertions(+), 95 deletions(-) delete mode 100644 playbooks/roles/poetry/defaults/main.yml delete mode 100644 playbooks/roles/poetry/files/10-poetry.sh delete mode 100644 playbooks/roles/poetry/meta/main.yml delete mode 100644 playbooks/roles/poetry/molecule/default/converge.yml delete mode 100644 playbooks/roles/poetry/molecule/default/molecule.yml delete mode 100644 playbooks/roles/poetry/molecule/default/verify.yml delete mode 100644 playbooks/roles/poetry/tasks/main.yml delete mode 100644 playbooks/roles/poetry/tasks/system_wide.yml diff --git a/docs/index.md b/docs/index.md index 3ceb0230..50c67d4a 100644 --- a/docs/index.md +++ b/docs/index.md @@ -100,7 +100,6 @@ The status of a role is either Experimental or Supported. Supported roles are su - [miniconda](roles/miniconda.md) - [nginx_reverse_proxy](roles/nginx_reverse_proxy.md) - [nginx_uwsgi](roles/nginx_uwsgi.md) -- [poetry](roles/poetry.md) - [pip](roles/pip.md) install pip - [pipx_install_systemwide](roles/pipx_install_systemwide.md) install pip packages in a shared directory for all users - [pyenv](roles/pyenv.md) install pyenv and use it to install custom python version diff --git a/docs/playbooks/python-workbench.md b/docs/playbooks/python-workbench.md index 4d216ff8..ad9ef107 100644 --- a/docs/playbooks/python-workbench.md +++ b/docs/playbooks/python-workbench.md @@ -16,7 +16,7 @@ Ubuntu . ## Description The Linux distribution influences which Python3 and pip3 versions are installed system-wide. Users should not install python packages using the system python interpreter, since this may break system packages. This component therefore installs `pyenv` and via the `runonce` role, so that each user on the system can manage their own Python environment. `pyenv` and `poetry` are installed (in userspace) the first time the user logs in. -For additional development convenience, `poetry` and `miniconda` are also intalled on a per-user basis. If users want to use `miniconda`, they have to manually run `conda init` in their shell (this is not done by default, because it may interfere with users' workflows if they do not want to use `conda`). +For additional development convenience, `poetry` (via [pipx](../roles/pipx_install_systemwide.md)) and `miniconda` (via [runonce](../roles/runonce.md)) are also installed. If users want to use `miniconda`, they have to manually run `conda init` in their shell (this is not done by default, because it may interfere with users' workflows if they do not want to use `conda`). ## Variables @@ -26,7 +26,7 @@ For additional development convenience, `poetry` and `miniconda` are also intall - role [runonce](../roles/runonce.md) - role [pyenv](../roles/pyenv.md) -- role [runonce](../roles/poetry.md) +- role [runonce](../roles/pipx_install_systemwide.md) - role [miniconda](../roles/miniconda.md) ## History diff --git a/molecule/playbook-python-workbench/verify.yml b/molecule/playbook-python-workbench/verify.yml index 44d3fcc4..52156728 100644 --- a/molecule/playbook-python-workbench/verify.yml +++ b/molecule/playbook-python-workbench/verify.yml @@ -11,7 +11,6 @@ register: expected_files with_items: - 01_pyenv-install.sh - - 10-poetry.sh - name: Assert expected files exist ansible.builtin.assert: @@ -27,3 +26,6 @@ ansible.builtin.assert: that: - '"3.8" in python_version.stdout_lines[0]' + + - name: Test poetry + ansible.builtin.shell: su -c "bash -ic 'poetry about'" - testuser diff --git a/playbooks/python-workbench.yml b/playbooks/python-workbench.yml index c88498c9..2b41bf2c 100644 --- a/playbooks/python-workbench.yml +++ b/playbooks/python-workbench.yml @@ -8,4 +8,7 @@ - role: pyenv vars: pyenv_default_python: "{{ default_python_version | default('system-latest') }}" - - role: poetry + - role: pipx_install_systemwide + vars: + pipx_install_systemwide_packages: + - poetry diff --git a/playbooks/roles/poetry/defaults/main.yml b/playbooks/roles/poetry/defaults/main.yml deleted file mode 100644 index b94940bd..00000000 --- a/playbooks/roles/poetry/defaults/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -poetry_per_user: true -poetry_system_wide: false diff --git a/playbooks/roles/poetry/files/10-poetry.sh b/playbooks/roles/poetry/files/10-poetry.sh deleted file mode 100644 index 72cfe58e..00000000 --- a/playbooks/roles/poetry/files/10-poetry.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -# install python module poetry -# -echo "Installing Python poetry" -export POETRY_ROOT="~/.local/bin" -curl -sSL https://install.python-poetry.org | python3 - -export PATH="$POETRY_ROOT:$PATH" -# -cat >> ~/.bashrc <<'INPUTEND' -# added by runonce as poetry config -if [ -z "$POETRY_ROOT" ]; then -export POETRY_ROOT="~/.local/bin" -export PATH="$POETRY_ROOT:$PATH" -fi -INPUTEND diff --git a/playbooks/roles/poetry/meta/main.yml b/playbooks/roles/poetry/meta/main.yml deleted file mode 100644 index 89085e8e..00000000 --- a/playbooks/roles/poetry/meta/main.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -dependencies: - - role: pip - - role: runonce - when: poetry_per_user diff --git a/playbooks/roles/poetry/molecule/default/converge.yml b/playbooks/roles/poetry/molecule/default/converge.yml deleted file mode 100644 index fb6147d0..00000000 --- a/playbooks/roles/poetry/molecule/default/converge.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -- name: Converge - hosts: all - gather_facts: true - tasks: - - name: Testing userspace poetry role - include_role: - name: poetry diff --git a/playbooks/roles/poetry/molecule/default/molecule.yml b/playbooks/roles/poetry/molecule/default/molecule.yml deleted file mode 100644 index 413487ef..00000000 --- a/playbooks/roles/poetry/molecule/default/molecule.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -provisioner: - name: ansible - playbooks: - converge: ./converge.yml - prepare: - env: - ANSIBLE_ROLES_PATH: ../../../ -role_name_check: 1 diff --git a/playbooks/roles/poetry/molecule/default/verify.yml b/playbooks/roles/poetry/molecule/default/verify.yml deleted file mode 100644 index fb25f87c..00000000 --- a/playbooks/roles/poetry/molecule/default/verify.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- -- name: Verify - hosts: all - gather_facts: false - tasks: - - name: Get all runonce scripts - find: - paths: /etc/runonce.d - recurse: no - register: found_scripts - - - name: Run runonce scripts - ansible.builtin.command: su -c "{{ item.path }}" - testuser - with_items: "{{ found_scripts.files }}" - - - name: Test poetry - ansible.builtin.shell: su -c "bash -ic 'poetry about'" - testuser - \ No newline at end of file diff --git a/playbooks/roles/poetry/tasks/main.yml b/playbooks/roles/poetry/tasks/main.yml deleted file mode 100644 index ad3e43bf..00000000 --- a/playbooks/roles/poetry/tasks/main.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -- name: Install poetry system-wide - when: poetry_system_wide - include_tasks: system_wide.yml - -- name: Install poetry per user through runonce.d - when: poetry_per_user - copy: - src: 10-poetry.sh - dest: /etc/runonce.d - mode: "0755" diff --git a/playbooks/roles/poetry/tasks/system_wide.yml b/playbooks/roles/poetry/tasks/system_wide.yml deleted file mode 100644 index d998d891..00000000 --- a/playbooks/roles/poetry/tasks/system_wide.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- -- name: Download poetry installer - get_url: - url: https://install.python-poetry.org - dest: /tmp/install-poetry.py - mode: "0777" - timeout: 20 - -- name: Install venv dependency - apt: - name: python3-venv - -- name: Install poetry system-wide - command: python3 /tmp/install-poetry.py - environment: - POETRY_HOME: /opt/poetry - -- name: Clean installation file - file: - path: /tmp/install-poetry.py - state: absent