From 05b563ed003c4dfa91d8227ec620c550680485ab Mon Sep 17 00:00:00 2001 From: MickLesk Date: Mon, 22 Jun 2026 21:39:24 +0200 Subject: [PATCH] fix(endurain): pin uv to the version required by the project Add UV_VERSION support to setup_uv and install the required uv release before backend setup so poetry/uv venv no longer fails on version drift. --- ct/endurain.sh | 2 ++ install/endurain-install.sh | 2 ++ misc/tools.func | 32 +++++++++++++++++--------------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/ct/endurain.sh b/ct/endurain.sh index 664efe62a..ae372adf1 100644 --- a/ct/endurain.sh +++ b/ct/endurain.sh @@ -61,6 +61,8 @@ function update_script() { msg_info "Updating Backend" cd /opt/endurain/backend + UV_VERSION=$(grep -Po 'required-version\s*=\s*"\K[^"]+' pyproject.toml 2>/dev/null || echo "0.11.18") + UV_VERSION="$UV_VERSION" setup_uv $STD poetry export -f requirements.txt --output requirements.txt --without-hashes $STD uv venv --clear $STD uv pip install -r requirements.txt diff --git a/install/endurain-install.sh b/install/endurain-install.sh index 6aef73f66..805797204 100644 --- a/install/endurain-install.sh +++ b/install/endurain-install.sh @@ -81,6 +81,8 @@ msg_ok "Built Frontend" msg_info "Setting up Backend" cd /opt/endurain/backend +UV_VERSION=$(grep -Po 'required-version\s*=\s*"\K[^"]+' pyproject.toml 2>/dev/null || echo "0.11.18") +UV_VERSION="$UV_VERSION" setup_uv $STD uv tool install poetry $STD uv tool update-shell export PATH="/root/.local/bin:$PATH" diff --git a/misc/tools.func b/misc/tools.func index a1aa4be30..4a41f3ce3 100644 --- a/misc/tools.func +++ b/misc/tools.func @@ -8710,12 +8710,14 @@ setup_uv() { ensure_dependencies jq - # Fetch latest version - local LATEST_VERSION - LATEST_VERSION=$(get_latest_github_release "astral-sh/uv") || { - msg_error "Could not fetch latest uv version from GitHub API" - return 7 - } + # Fetch target version (pinned via UV_VERSION or latest release) + local TARGET_VERSION="${UV_VERSION:-}" + if [[ -z "$TARGET_VERSION" ]]; then + TARGET_VERSION=$(get_latest_github_release "astral-sh/uv") || { + msg_error "Could not fetch latest uv version from GitHub API" + return 7 + } + fi # Get currently installed version local INSTALLED_VERSION="" @@ -8723,9 +8725,9 @@ setup_uv() { INSTALLED_VERSION=$("$UV_BIN" --version 2>/dev/null | awk '{print $2}') fi - # Scenario 1: Already at latest version - if [[ -n "$INSTALLED_VERSION" && "$INSTALLED_VERSION" == "$LATEST_VERSION" ]]; then - cache_installed_version "uv" "$LATEST_VERSION" + # Scenario 1: Already at target version + if [[ -n "$INSTALLED_VERSION" && "$INSTALLED_VERSION" == "$TARGET_VERSION" ]]; then + cache_installed_version "uv" "$TARGET_VERSION" # Check if uvx is needed and missing if [[ "${USE_UVX:-NO}" == "YES" ]] && [[ ! -x "$UVX_BIN" ]]; then @@ -8738,13 +8740,13 @@ setup_uv() { fi # Scenario 2: New install or upgrade - if [[ -n "$INSTALLED_VERSION" && "$INSTALLED_VERSION" != "$LATEST_VERSION" ]]; then - msg_info "Upgrade uv from $INSTALLED_VERSION to $LATEST_VERSION" + if [[ -n "$INSTALLED_VERSION" && "$INSTALLED_VERSION" != "$TARGET_VERSION" ]]; then + msg_info "Upgrade uv from $INSTALLED_VERSION to $TARGET_VERSION" else - msg_info "Setup uv $LATEST_VERSION" + msg_info "Setup uv $TARGET_VERSION" fi - local UV_URL="https://github.com/astral-sh/uv/releases/download/${LATEST_VERSION}/${UV_TAR}" + local UV_URL="https://github.com/astral-sh/uv/releases/download/${TARGET_VERSION}/${UV_TAR}" if ! curl_with_retry "$UV_URL" "$TMP_DIR/uv.tar.gz"; then msg_error "Failed to download uv from $UV_URL" @@ -8799,8 +8801,8 @@ setup_uv() { msg_ok "Python $PYTHON_VERSION installed" fi - cache_installed_version "uv" "$LATEST_VERSION" - msg_ok "Setup uv $LATEST_VERSION" + cache_installed_version "uv" "$TARGET_VERSION" + msg_ok "Setup uv $TARGET_VERSION" } # Helper function to install uvx wrapper