Skip to content

Fall back to pip when external uv fails to install uv into penv#387

Merged
Jason2866 merged 2 commits into
pioarduino:developfrom
swoboda1337:uv_pip_fallback
Feb 11, 2026
Merged

Fall back to pip when external uv fails to install uv into penv#387
Jason2866 merged 2 commits into
pioarduino:developfrom
swoboda1337:uv_pip_fallback

Conversation

@swoboda1337
Copy link
Copy Markdown

@swoboda1337 swoboda1337 commented Feb 11, 2026

Summary

  • When external uv is available but fails to install uv into the penv (e.g. due to transient network errors), fall through to the pip installation path instead of aborting the build
  • Changes the if/else to two sequential attempts: try external uv first, on any failure silently fall back to pip

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced installation reliability by implementing an automatic fallback mechanism that ensures successful environment setup even when standard installation methods are unavailable.

When external uv is available but fails to install uv into the penv
(e.g. due to transient network errors), fall through to the pip
installation path instead of returning False and aborting the build.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 11, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR modifies the uv installation flow in the Python environment setup process. It now attempts external uv installation first, then gracefully falls back to pip-based installation if that fails, while simplifying error handling logic by consolidating specific exceptions into a broader fallback mechanism.

Changes

Cohort / File(s) Summary
uv Installation Flow Refactor
builder/penv_setup.py
Reworked installation logic to attempt external uv executable first, then fall back to pip installation on failure. Consolidated error handling by removing exhaustive per-exception handling and implementing broader try/except blocks. Adjusted error messaging to reflect pip-based installation outcomes.

Sequence Diagram

sequenceDiagram
    participant Installer as Installation Flow
    participant ExtUV as External uv Executable
    participant Pip as pip (Fallback)
    participant Penv as Python Environment

    Installer->>ExtUV: Attempt to install uv externally
    alt External uv Installation Succeeds
        ExtUV-->>Installer: Success
        Installer->>Penv: Mark uv_in_penv_available = True
    else External uv Installation Fails
        ExtUV-->>Installer: Error
        Installer->>Pip: Fall back to pip-based installation
        Pip->>Penv: Install uv via pip
        Pip-->>Installer: Installation complete
        Installer->>Penv: Mark uv_in_penv_available (based on outcome)
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 hops with glee and raises a paw,
uv tries first—that's the new law!
If external stumbles and takes a fall,
pip catches it gracefully, saves the day for all!
A rabbit's delight: fallback so divine, 🎯

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: implementing fallback logic from external uv to pip when installation fails.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@swoboda1337
Copy link
Copy Markdown
Author

It is worth trying pip if uv fails, easy to fallback to pip

@Jason2866
Copy link
Copy Markdown

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 11, 2026

✅ Actions performed

Full review triggered.

Added a warning message for failed external uv installation.
@Jason2866
Copy link
Copy Markdown

Thx. Overlooked it was designed to act like that.

@Jason2866 Jason2866 merged commit 31c2dee into pioarduino:develop Feb 11, 2026
1 check passed
@swoboda1337
Copy link
Copy Markdown
Author

Thanks!

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.

2 participants