Skip to content

fix: prevent PR repo's .python-version from overriding setup-python#200

Merged
xingyaoww merged 2 commits into
OpenHands:mainfrom
Shimada666:fix/pr-review-python-version
Apr 23, 2026
Merged

fix: prevent PR repo's .python-version from overriding setup-python#200
xingyaoww merged 2 commits into
OpenHands:mainfrom
Shimada666:fix/pr-review-python-version

Conversation

@Shimada666
Copy link
Copy Markdown
Contributor

Problem

When the PR review action runs uv run inside pr-repo/, uv discovers and respects the reviewed repository's .python-version file. If that file specifies Python < 3.12 (e.g. 3.11), uv downloads that version instead of using the 3.12 installed by setup-python, causing openhands-sdk installation to fail:

Downloading cpython-3.11.15-linux-x86_64-gnu (download) (29.9MiB)
× No solution found when resolving `--with` dependencies:
╰─▶ Because the current Python version (3.11.15) does not satisfy Python>=3.12
    and all versions of openhands-sdk depend on Python>=3.12,
    we can conclude that all versions of openhands-sdk cannot be used.

Even though --no-project is passed to ignore pyproject.toml, uv still reads .python-version for Python version discovery.

Fix

Set UV_PYTHON_PREFERENCE: only-system on the "Run PR review" step so uv always uses the system Python installed by setup-python and ignores any .python-version file in the reviewed repository.

Test plan

  • Verified the fix on our repo (MizzenAI/Personality) which has .python-version: 3.11 and was consistently failing with this error.

When `uv run` executes inside `pr-repo/`, it discovers and respects
the PR repository's `.python-version` file. If that file specifies a
Python version older than 3.12 (e.g. 3.11), uv downloads that version
instead of using the 3.12 installed by setup-python, causing
openhands-sdk installation to fail since it requires Python >= 3.12.

Set `UV_PYTHON_PREFERENCE: only-system` so uv always uses the
system Python (installed by setup-python) and ignores any
`.python-version` file in the reviewed repository.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@all-hands-bot all-hands-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Good taste - Elegant, minimal fix that solves a real problem.

[RISK ASSESSMENT]
⚠️ Risk Assessment: 🟢 LOW

One-line environment variable change with clear, predictable behavior. Forces uv to use the system Python installed by setup-python, eliminating the failure mode when reviewed repos have .python-version files specifying Python < 3.12. No breaking changes, no security concerns.

VERDICT:Worth merging

KEY INSIGHT: Fixing implicit dependencies (uv reading .python-version from the reviewed repo) with explicit configuration (UV_PYTHON_PREFERENCE: only-system) is exactly the right approach - it makes behavior predictable and eliminates special cases.

@xingyaoww xingyaoww merged commit b230253 into OpenHands:main Apr 23, 2026
3 checks passed
xingyaoww pushed a commit that referenced this pull request Apr 23, 2026
PR #200 added UV_PYTHON_PREFERENCE=only-system to prevent the target
repo's .python-version from overriding setup-python. This works when
.python-version is *older* than 3.12 (e.g. 3.11), but breaks when it
is *newer* (e.g. 3.13 in software-agent-sdk) because uv cannot find
3.13 on the system and is not allowed to download it.

Replace with UV_PYTHON=3.12 which explicitly tells uv which interpreter
to use, ignoring .python-version in either direction.

Fixes: https://github.com/OpenHands/software-agent-sdk/actions/runs/24844346484

Co-authored-by: openhands <openhands@all-hands.dev>
xingyaoww added a commit that referenced this pull request Apr 23, 2026
PR #200 added UV_PYTHON_PREFERENCE=only-system to prevent the target
repo's .python-version from overriding setup-python. This works when
.python-version is *older* than 3.12 (e.g. 3.11), but breaks when it
is *newer* (e.g. 3.13 in software-agent-sdk) because uv cannot find
3.13 on the system and is not allowed to download it.

Replace with UV_PYTHON=3.12 which explicitly tells uv which interpreter
to use, ignoring .python-version in either direction.

Fixes: https://github.com/OpenHands/software-agent-sdk/actions/runs/24844346484

Co-authored-by: openhands <openhands@all-hands.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants