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.
This commit is contained in:
will
2026-02-04 10:45:21 +00:00
parent f80bf5128d
commit a53b81ce4e
3 changed files with 10 additions and 17 deletions

View File

@@ -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 \

View File

@@ -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"

View File

@@ -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