zuul-jobs/roles/ensure-python-command
Aurelio Jargas b03e50c3d1 ensure-python-command: Install venv in Zuul-scoped path
To avoid possible clashes with tooling already using `~/.local/<name>`,
let's create a new `.local/_zuul_venv/` parent directory for all the
Zuul-created venvs.

Change-Id: I62a7bff927a5d337fbb05ae8bcd70c530bce4de4
2025-04-08 21:20:52 +00:00
..

Ensure a pip-installed command is available

This role checks for the specified command, and if not found, installs it via pip into a virtual environment for the current user.

The minimal required input is the command name. Additionally, you can specify a version or a path to a local venv, among other things.

Example:

- role: ensure-python-command
  vars:
    ensure_python_command_name: poetry
    ensure_python_command_version: ==1.8.5  # omit to install latest

In this case, if the poetry command is not already available, pip will install it in a new venv. Either way, after running this role, the ensure_python_command_executable variable will hold the full path to the command.

Role Variables

Required. The name of the command to ensure is available.

Output Variables

The full path to the command executable, whether it was detected or installed by the role.