From a53b81ce4e649dd637a217686745a6f6c6c81ca5 Mon Sep 17 00:00:00 2001 From: will Date: Wed, 4 Feb 2026 10:45:21 +0000 Subject: [PATCH] lint: switch to uv for python management in linter https://docs.astral.sh/uv/ Install python in the linter using uv and a venv. This is faster and more simple than building pyenv. --- ci/lint/01_install.sh | 21 +++++---------------- ci/lint/06_script.sh | 2 +- ci/lint_imagefile | 4 ++++ 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/ci/lint/01_install.sh b/ci/lint/01_install.sh index 573dbca5fe5..50615030336 100755 --- a/ci/lint/01_install.sh +++ b/ci/lint/01_install.sh @@ -22,25 +22,14 @@ ${CI_RETRY_EXE} apt-get update # - moreutils (used by scripted-diff) ${CI_RETRY_EXE} apt-get install -y cargo curl xz-utils git gpg moreutils -PYTHON_PATH="/python_build" -if [ ! -d "${PYTHON_PATH}/bin" ]; then - ( - ${CI_RETRY_EXE} git clone --depth=1 https://github.com/pyenv/pyenv.git - cd pyenv/plugins/python-build || exit 1 - ./install.sh - ) - # For dependencies see https://github.com/pyenv/pyenv/wiki#suggested-build-environment - ${CI_RETRY_EXE} apt-get install -y build-essential libssl-dev zlib1g-dev \ - libbz2-dev libreadline-dev libsqlite3-dev curl llvm \ - libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev \ - clang - env CC=clang python-build "$(cat "/.python-version")" "${PYTHON_PATH}" -fi -export PATH="${PYTHON_PATH}/bin:${PATH}" +# Install Python and create venv using uv (reads version from .python-version) +uv venv /python_env + +export PATH="/python_env/bin:${PATH}" command -v python3 python3 --version -${CI_RETRY_EXE} pip3 install \ +uv pip install --python /python_env \ lief==0.17.5 \ mypy==1.19.1 \ pyzmq==27.1.0 \ diff --git a/ci/lint/06_script.sh b/ci/lint/06_script.sh index 1b36fada9fc..a0f2dc88bc4 100755 --- a/ci/lint/06_script.sh +++ b/ci/lint/06_script.sh @@ -12,7 +12,7 @@ set -o errexit -o pipefail -o xtrace # of the mounted bitcoin src dir. git config --global --add safe.directory /bitcoin -export PATH="/python_build/bin:${PATH}" +export PATH="/python_env/bin:${PATH}" if [ -n "${LINT_CI_IS_PR}" ]; then export COMMIT_RANGE="HEAD~..HEAD" diff --git a/ci/lint_imagefile b/ci/lint_imagefile index 77e9688c650..d050153f8ad 100644 --- a/ci/lint_imagefile +++ b/ci/lint_imagefile @@ -6,6 +6,10 @@ FROM mirror.gcr.io/ubuntu:24.04 +# Pin uv to minor version to avoid breaking changes: +# https://docs.astral.sh/uv/reference/policies/versioning/ +COPY --from=ghcr.io/astral-sh/uv:0.10 /uv /uvx /bin/ + COPY ./ci/retry/retry /ci_retry COPY ./.python-version /.python-version COPY ./ci/lint/01_install.sh /install.sh