Skip to content

fix(pr-review): use both UV_PYTHON and UV_PYTHON_PREFERENCE#204

Closed
xingyaoww wants to merge 1 commit into
mainfrom
fix/pr-review-python-version-override
Closed

fix(pr-review): use both UV_PYTHON and UV_PYTHON_PREFERENCE#204
xingyaoww wants to merge 1 commit into
mainfrom
fix/pr-review-python-version-override

Conversation

@xingyaoww
Copy link
Copy Markdown
Member

Problem

PR #203 replaced UV_PYTHON_PREFERENCE=only-system with UV_PYTHON=3.12. This fixed repos with newer Python (e.g. .python-version: 3.13) but re-broke repos with older Python (e.g. .python-version: 3.11) — UV_PYTHON alone doesn't prevent uv from downloading the version specified in .python-version.

Evidence: MizzenAI/Personality (which has .python-version: 3.11) started failing again after #203:

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, ...

Fix

Use both env vars:

  • UV_PYTHON=3.12 — tells uv which version to request (fixes .python-version > 3.12)
  • UV_PYTHON_PREFERENCE=only-system — blocks managed downloads (fixes .python-version < 3.12)

Together they handle .python-version in either direction.

This PR was created by an AI assistant (OpenHands) on behalf of a user.

UV_PYTHON=3.12 alone is not sufficient — uv still downloads the
version from .python-version when managed downloads are allowed.
Restore UV_PYTHON_PREFERENCE=only-system alongside UV_PYTHON=3.12:

- UV_PYTHON=3.12: tells uv which version to request
- only-system: prevents uv from downloading a different version

Together they handle .python-version in both directions:
- Older (e.g. 3.11): only-system blocks the download, UV_PYTHON
  selects 3.12
- Newer (e.g. 3.13): only-system blocks the download, UV_PYTHON
  selects 3.12

Co-authored-by: openhands <openhands@all-hands.dev>
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 fix that uses both env vars complementarily to handle .python-version in either direction. Solves a real production problem with minimal, well-documented change.

[RISK ASSESSMENT]

[Overall PR] ⚠️ Risk Assessment: 🟢 LOW

Configuration-only change with limited blast radius. Restores working behavior for repos with older Python versions while maintaining the fix for newer versions. No security concerns, infrastructure changes, or architectural shifts.

Worth merging

KEY INSIGHT: The combination of UV_PYTHON=3.12 (version preference) + UV_PYTHON_PREFERENCE=only-system (block downloads) elegantly eliminates both edge cases without conditional logic.

Copy link
Copy Markdown
Member Author

Closing — tested locally and UV_PYTHON=3.12 alone (current main, PR #203) handles all three cases correctly:

  • .python-version: 3.11 → ✅ uses 3.12
  • .python-version: 3.13 → ✅ uses 3.12
  • no .python-version → ✅ uses 3.12

The screenshot was from before #203 was merged. No additional fix needed.

This comment was posted by an AI assistant (OpenHands) on behalf of a user.

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