Skip to content

Run ensurepip before pip fallback (uv-created venvs lack pip)#443

Merged
Jason2866 merged 1 commit into
pioarduino:developfrom
swoboda1337:fix-ensurepip-fallback
Mar 26, 2026
Merged

Run ensurepip before pip fallback (uv-created venvs lack pip)#443
Jason2866 merged 1 commit into
pioarduino:developfrom
swoboda1337:fix-ensurepip-fallback

Conversation

@swoboda1337
Copy link
Copy Markdown

@swoboda1337 swoboda1337 commented Mar 26, 2026

When the penv is created by uv, pip is not included. If the external uv fails to install uv into the penv (e.g. timeout), the pip fallback fails with No module named pip.

Fix by running ensurepip to bootstrap pip before the pip fallback. ensurepip is a Python stdlib module that installs pip from a bundled wheel — no network needed.

DEBUG: uv not found in penv, attempting install
DEBUG: python_exe=/root/.platformio/penv/bin/python
DEBUG: external_uv_executable=/usr/local/bin/uv
Warning: uv installation via external uv timed out after 300s
Error: uv installation via pip failed with exit code 1
DEBUG: stderr: /root/.platformio/penv/bin/python: No module named pip

Related: esphome/esphome#15074

Summary by CodeRabbit

  • Chores
    • Improved virtual environment setup process with enhanced package initialization to ensure more reliable dependency installation in edge cases.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4bbe7959-2384-4a40-9624-d2fba1e7a28a

📥 Commits

Reviewing files that changed from the base of the PR and between 658ebd7 and f8cff21.

📒 Files selected for processing (1)
  • builder/penv_setup.py

📝 Walkthrough

Walkthrough

When the uv package manager is unavailable in a created virtual environment, the fallback installation mechanism now runs python -m ensurepip --default-pip before attempting pip install uv. Ensurepip failures are silently ignored, preserving existing error handling.

Changes

Cohort / File(s) Summary
Virtual Environment Setup
builder/penv_setup.py
Added ensurepip invocation (with 60s timeout and captured output) as a robustness measure prior to pip-based uv installation in the fallback path when uv is unavailable in the created venv.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

🐰 A little pip was stuck inside the warren so deep,
We whispered ensurepip to wake it from sleep,
Then uv bloomed like carrots in the spring—
With timeouts and silence, we fixed everything! 🥕✨

🚥 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 clearly and specifically describes the main change: running ensurepip before attempting pip fallback in uv-created virtual environments that lack pip.
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

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.

@Jason2866
Copy link
Copy Markdown

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 26, 2026

✅ Actions performed

Full review triggered.

@Jason2866
Copy link
Copy Markdown

@swoboda1337 Well the change makes sense. Thx!
But i doubt, when already that deep in issues, this will be the rescue

@Jason2866 Jason2866 merged commit 6557046 into pioarduino:develop Mar 26, 2026
1 check passed
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