Playbook

Install Python Tools

uv, Poetry or Pipenv through pipx, with a compiler and the headers database drivers need.

Category

Runtimes

Time limit per server

20 minutes

Temporary failures

Retried automatically, up to 2 times

Version

1.0

Supported systems

Ubuntu 22.04+, Debian 12+, RHEL-compatible 8+ (AlmaLinux, Rocky Linux, RHEL, CentOS Stream, Oracle Linux), Amazon Linux 2023+

Options

As they appear on the run form, with their defaults.

Python

One choice

On Ubuntu and Debian, both choices install the release's one Python 3.

  • Newest Python 3 in the distribution's repositories
  • The distribution's default python3

Default: Newest Python 3 in the distribution's repositories

Tools

Any of the choices

  • uv
  • Poetry
  • Pipenv

Default: uv

Install a compiler and build headers

On or off

For Python packages that must be compiled on this server.

Default: On

Client headers

Any of the choices

  • PostgreSQL (psycopg)
  • MySQL and MariaDB (mysqlclient)
  • libxml2 and libxslt (lxml)
  • JPEG and zlib (Pillow)

Default: None

When to use it

When your deployment uses uv, Poetry or Pipenv, or when your application's dependencies compile native code (database drivers, lxml, Pillow) and have no prebuilt wheel for the server. Run Install Python first with the same Python choice.

Choosing the options

Python — the same choice you made in Install Python. The tools run on that interpreter.

Tools — choose the ones your project uses:

  • uv — a fast installer and project manager. uv sync or uv pip install -r requirements.txt.
  • Poetry — for projects with pyproject.toml and poetry.lock.
  • Pipenv — for projects with a Pipfile.

Install a compiler and build headers — installs a C compiler, make, pkg-config and the OpenSSL and libffi headers. Keep it on unless every dependency ships a wheel for the server's platform.

Client headers — add the ones your dependencies need:

  • PostgreSQL (psycopg)libpq-dev or libpq-devel, for psycopg built from source.
  • MySQL and MariaDB (mysqlclient) — the MySQL or MariaDB client headers.
  • libxml2 and libxslt (lxml) — for lxml.
  • JPEG and zlib (Pillow) — for Pillow built from source.

What it does on the server

  1. Installs the compiler and headers you chose from the server's repositories. Where a distribution names a package differently, the playbook uses the name it offers.
  2. Installs pipx in its own virtual environment at /opt/pipx/venv.
  3. Installs each chosen tool with pipx, each in its own environment, and links its commands into /usr/local/bin so every account can run them.

A command in /usr/local/bin that pipx did not install is never replaced.

After the run

Run the tools as the account that deploys your application, for example uv sync --frozen in the project directory. To upgrade the tools later, run on the server:

PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin /opt/pipx/venv/bin/pipx upgrade-all

Common problems

"None of … is available from this server's repositories. Nothing was changed." — A header package the playbook needs is not offered by the server's repositories. On the RHEL family, several -devel packages come from the CodeReady Builder (CRB) repository: enable it and run the playbook again.

"… already exists and was not installed by this playbook." — A command with the same name, such as uv, was installed another way. The playbook leaves it alone; remove it if you want pipx to manage it.