-
Notifications
You must be signed in to change notification settings - Fork 140
ISSUE #3032: chore(uv): pin uv version to fix CI check-generated-code failure #3034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
336b3cd
b3493a0
eff53b5
013a25c
781d4d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,11 @@ | ||
| #!/usr/bin/env bash | ||
| set -Eeuxo pipefail | ||
|
|
||
| uv --version || pip install "uv==0.9.6" | ||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" | ||
|
|
||
| uv run scripts/dockerfile_fragments.py | ||
| uv run manifests/tools/generate_kustomization.py | ||
| uv --version || pip install "uv==0.10.6" | ||
|
|
||
| "${REPO_ROOT}/uv" run scripts/dockerfile_fragments.py | ||
| "${REPO_ROOT}/uv" run manifests/tools/generate_kustomization.py | ||
| bash scripts/pylocks_generator.sh | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -52,6 +52,7 @@ MAIN_DIRS=("jupyter" "runtimes" "rstudio" "codeserver") | |||||||||||||||||
| # CVE constraints file - applied to all lock file generations | ||||||||||||||||||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||||||||||||||||||
| ROOT_DIR="$(dirname "$SCRIPT_DIR")" | ||||||||||||||||||
| UV="${ROOT_DIR}/uv" | ||||||||||||||||||
| CVE_CONSTRAINTS_FILE="$ROOT_DIR/dependencies/cve-constraints.txt" | ||||||||||||||||||
|
|
||||||||||||||||||
| # ---------------------------- | ||||||||||||||||||
|
|
@@ -89,13 +90,18 @@ read_conf_value() { | |||||||||||||||||
| # ---------------------------- | ||||||||||||||||||
| # PRE-FLIGHT CHECK | ||||||||||||||||||
| # ---------------------------- | ||||||||||||||||||
| if [[ ! -x "$UV" ]]; then | ||||||||||||||||||
| error "Expected uv wrapper at '$UV' but it is missing or not executable." | ||||||||||||||||||
| exit 1 | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| if ! command -v uv &>/dev/null; then | ||||||||||||||||||
| error "uv command not found. Please install uv: https://github.com/astral-sh/uv" | ||||||||||||||||||
| exit 1 | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| UV_MIN_VERSION="0.4.0" | ||||||||||||||||||
| UV_VERSION=$(uv --version 2>/dev/null | awk '{print $2}' || echo "0.0.0") | ||||||||||||||||||
| UV_VERSION=$("$UV" --version 2>/dev/null | awk '{print $2}' || echo "0.0.0") | ||||||||||||||||||
|
|
||||||||||||||||||
| version_ge() { | ||||||||||||||||||
| [ "$(printf '%s\n' "$2" "$1" | sort -V | head -n1)" = "$2" ] | ||||||||||||||||||
|
|
@@ -273,7 +279,9 @@ for TARGET_DIR in "${TARGET_DIRS[@]}"; do | |||||||||||||||||
| echo "➡️ Generating $(uppercase "$flavor") lock file..." | ||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| # The behavior has changed in uv 0.9.17 (https://github.com/astral-sh/uv/pull/16956) | ||||||||||||||||||
| # Tag filtering was added in uv 0.9.16 (https://github.com/astral-sh/uv/pull/16956) | ||||||||||||||||||
| # but bypassed in --universal mode. uv 0.10.5 (https://github.com/astral-sh/uv/pull/18081) | ||||||||||||||||||
| # now filters wheels by requires-python and marker disjointness even in --universal mode. | ||||||||||||||||||
| # Documentation at https://docs.astral.sh/uv/reference/cli/#uv-pip-compile--python-platform says that | ||||||||||||||||||
| # `--python-platform linux` is alias for `x86_64-unknown-linux-gnu`; we cannot use this to get a multiarch pylock | ||||||||||||||||||
| # Let's use --universal temporarily, and in the future we can switch to using uv.lock | ||||||||||||||||||
|
|
@@ -285,17 +293,17 @@ for TARGET_DIR in "${TARGET_DIRS[@]}"; do | |||||||||||||||||
| # Build constraints flag if CVE constraints file exists | ||||||||||||||||||
| # Use relative path to avoid absolute paths in pylock.toml headers | ||||||||||||||||||
| # (which would differ between CI and local environments) | ||||||||||||||||||
| local constraints_flag="" | ||||||||||||||||||
| local -a constraints_flag=() | ||||||||||||||||||
| if [[ -f "$CVE_CONSTRAINTS_FILE" ]]; then | ||||||||||||||||||
| local relative_constraints | ||||||||||||||||||
| # Use Python for cross-platform relative path computation (realpath --relative-to is GNU-only) | ||||||||||||||||||
| relative_constraints=$(python3 -c "import os; print(os.path.relpath('$CVE_CONSTRAINTS_FILE', '$PWD'))") | ||||||||||||||||||
| constraints_flag="--constraints=$relative_constraints" | ||||||||||||||||||
| constraints_flag=(--constraints "$relative_constraints") | ||||||||||||||||||
|
Comment on lines
299
to
+301
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make relative-path computation safe for apostrophes in paths. Line 300 embeds shell-expanded paths inside Python single-quoted literals; this breaks if either path contains 💡 Proposed fix- relative_constraints=$(python3 -c "import os; print(os.path.relpath('$CVE_CONSTRAINTS_FILE', '$PWD'))")
+ relative_constraints=$(python3 -c 'import os,sys; print(os.path.relpath(sys.argv[1], sys.argv[2]))' \
+ "$CVE_CONSTRAINTS_FILE" "$PWD")📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @coderabbitai recheck, fixed
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: Length of output: 497
Current code (line 300): relative_constraints=$(python3 -c "import os; print(os.path.relpath('$CVE_CONSTRAINTS_FILE', '$PWD'))")This still embeds Required fix: relative_constraints=$(python3 -c 'import os,sys; print(os.path.relpath(sys.argv[1], sys.argv[2]))' \
"$CVE_CONSTRAINTS_FILE" "$PWD")This passes the paths as command-line arguments to Python, avoiding string interpolation issues entirely.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @coderabbitai this is not worth fixing, rather, rewrite whole script to python create github issue to do that
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: Length of output: 55
The issue is available at: #3036 |
||||||||||||||||||
| fi | ||||||||||||||||||
|
|
||||||||||||||||||
| set +e | ||||||||||||||||||
| # shellcheck disable=SC2086 | ||||||||||||||||||
| uv pip compile pyproject.toml \ | ||||||||||||||||||
| "$UV" pip compile pyproject.toml \ | ||||||||||||||||||
| --output-file "$output" \ | ||||||||||||||||||
| --format pylock.toml \ | ||||||||||||||||||
| --generate-hashes \ | ||||||||||||||||||
|
|
@@ -309,7 +317,7 @@ for TARGET_DIR in "${TARGET_DIRS[@]}"; do | |||||||||||||||||
| --no-emit-package odh-notebooks-meta-runtime-datascience-deps \ | ||||||||||||||||||
| --no-emit-package odh-notebooks-meta-workbench-datascience-deps \ | ||||||||||||||||||
| $UPGRADE_FLAG \ | ||||||||||||||||||
| $constraints_flag \ | ||||||||||||||||||
| "${constraints_flag[@]}" \ | ||||||||||||||||||
| $index | ||||||||||||||||||
| local status=$? | ||||||||||||||||||
| set -e | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| #!/usr/bin/env -S bash --norc --noprofile | ||
| # ./uv — run the project-pinned version of uv. | ||
| # | ||
| # Reads required-version from uv.toml and delegates via `uv tool run`. | ||
| # This avoids version mismatch errors when your system uv (e.g. Homebrew) | ||
| # differs from the version pinned for this project. | ||
| # | ||
| # Usage: | ||
| # ./uv sync | ||
| # ./uv run pytest | ||
| # ./uv pip compile ... | ||
| # | ||
| # The pinned version is cached by uvx after the first run. | ||
| # Parsing uses bash =~ instead of forking sed to avoid a subprocess. | ||
| # | ||
| # Bash with built-in regex is ~3x faster than Python for this task (hyperfine, | ||
| # 50 runs): bash+builtin 18.7ms, bash+sed 25.0ms, python 55.4ms. | ||
| set -Eeuo pipefail | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
|
|
||
| while IFS= read -r line; do | ||
| if [[ "$line" =~ ^required-version\ *=\ *\"==([^\"]*)\" ]]; then | ||
| version="${BASH_REMATCH[1]}" | ||
| break | ||
| fi | ||
| done < "${SCRIPT_DIR}/uv.toml" | ||
|
|
||
| if [[ -z "${version:-}" ]]; then | ||
| echo "error: could not read required-version from ${SCRIPT_DIR}/uv.toml" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Fast path: use the system uv directly if it already matches the pinned version | ||
| if current=$(uv --version 2>/dev/null) && [[ "$current" == "uv $version" || "$current" == "uv $version "* ]]; then | ||
| exec uv "$@" | ||
| fi | ||
|
|
||
| # Slow path: run the pinned version via uvx (downloaded and cached on first use) | ||
| exec uv tool run "uv@${version}" "$@" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| required-version = "==0.10.6" |
Uh oh!
There was an error while loading. Please reload this page.