From a3c286bad39829a0380771d28465b08904e493c0 Mon Sep 17 00:00:00 2001 From: "Martin Haase (FDTech GmbH)" Date: Wed, 21 Oct 2026 11:52:04 +0200 Subject: [PATCH] github: install python tools into a virtualenv Installing packages into the system interpreter with "python -m pip install" fails on runner images that enforce PEP 668: error: externally-managed-environment This is the case for Gitea Actions with the default gitea/runner-images:ubuntu-latest image (Ubuntu 24.04, Python 3.12). GitHub hosted runners still work because they ship a separately installed Python that is not marked as externally managed. Create a virtualenv in $RUNNER_TEMP instead and put it into $GITHUB_PATH so that the following steps find the installed tools. This works the same on GitHub and Gitea and does not rely on the Python setup of the runner image. --- .github/workflows/docs.yaml | 5 ++++- .github/workflows/pre-commit.yaml | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 0805dcc6..0b433e15 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -9,7 +9,10 @@ jobs: uses: actions/checkout@v4 - name: Setup Sphinx - run: python -m pip install sphinx sphinx-rtd-theme + run: | + python3 -m venv "$RUNNER_TEMP/venv" + echo "$RUNNER_TEMP/venv/bin" >> "$GITHUB_PATH" + "$RUNNER_TEMP/venv/bin/pip" install sphinx sphinx-rtd-theme - name: Build Sphinx docs run: make -C doc html diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml index acdd7e8d..03769dc7 100644 --- a/.github/workflows/pre-commit.yaml +++ b/.github/workflows/pre-commit.yaml @@ -9,7 +9,10 @@ jobs: uses: actions/checkout@v4 - name: Setup pre-commit - run: python -m pip install pre-commit + run: | + python3 -m venv "$RUNNER_TEMP/venv" + echo "$RUNNER_TEMP/venv/bin" >> "$GITHUB_PATH" + "$RUNNER_TEMP/venv/bin/pip" install pre-commit - name: Cache pre-commit state uses: actions/cache@v4