python

The distribution's own Python 3, together with pip and the venv module.

Installs the distribution’s Python 3, with pip and venv.

devtools:
  - name: python

You get whichever Python 3 the workstation’s distribution ships, ready to make virtual environments. Use one for your project; recent Debian and Ubuntu releases refuse pip install into the system interpreter, and a virtual environment is where installs go:

python3 -m venv ~/.venvs/app
. ~/.venvs/app/bin/activate
pip install -r requirements.txt

This devtool means “this workstation runs Python”, not “this workstation runs Python 3.12”. If you need a specific interpreter, see Version behavior.

Version behavior

versionResult
omittedthe distribution’s python3, with pip and venv
anything elserefused, with a message explaining the alternatives

Pinning a version is refused because Python publishes no official Linux binary release and no per-minor package repository, so there is nothing to install a pinned minor from that works the same on every distribution Ringleader supports. If you need a specific interpreter, either declare it in packages with a packageRepositories entry for a repository that publishes it, or pick a base image that already carries it.

What is installed

DistributionPackages
Debian / Ubuntupython3, python3-pip, python3-venv
Alpinepython3, py3-pip

Example

Install Python and create the project’s virtual environment as the login user:

apiVersion: workstations.ringleader.dev/v1
kind: WorkstationConfig
metadata:
  name: python-box
  namespace: dev
spec:
  selector:
    matchLabels:
      tier: dev
  devtools:
    - name: python
  scripts:
    - name: project-venv
      phase: user
      content: |
        set -e
        python3 -m venv "$HOME/.venvs/app"
        "$HOME/.venvs/app/bin/pip" install -r "$HOME/src/app/requirements.txt"

Notes

  • The workstation counts as having this devtool once python3 -m pip runs, so a workstation that lost pip or venv is repaired on the next setup run.
  • Works on Debian, Ubuntu and Alpine.