fix: prevent PR repo's .python-version from overriding setup-python#200
Merged
xingyaoww merged 2 commits intoApr 23, 2026
Merged
Conversation
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>
all-hands-bot
approved these changes
Apr 23, 2026
Contributor
all-hands-bot
left a comment
There was a problem hiding this comment.
🟢 Good taste - Elegant, minimal fix that solves a real problem.
[RISK ASSESSMENT]
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
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When the PR review action runs
uv runinsidepr-repo/, uv discovers and respects the reviewed repository's.python-versionfile. If that file specifies Python < 3.12 (e.g.3.11), uv downloads that version instead of using the 3.12 installed bysetup-python, causingopenhands-sdkinstallation to fail:Even though
--no-projectis passed to ignorepyproject.toml, uv still reads.python-versionfor Python version discovery.Fix
Set
UV_PYTHON_PREFERENCE: only-systemon the "Run PR review" step so uv always uses the system Python installed bysetup-pythonand ignores any.python-versionfile in the reviewed repository.Test plan
.python-version: 3.11and was consistently failing with this error.