Check pip availability before running ensurepip#392
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request improves the robustness of the Python toolcache setup templates by only running ensurepip when pip is not already importable for the target interpreter, avoiding redundant bootstrapping steps across Windows, Linux, and macOS.
Changes:
- Windows: check
import pipbefore invokingpython -m ensurepip. - Linux/macOS: gate
./python -m ensurepipbehind animport pipcheck (with stderr suppressed). - Keep the existing
pip install --upgrade --force-reinstall pip ...upgrade flow unchanged.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| installers/win-setup-template.ps1 | Adds a pip import check before running ensurepip, then upgrades/reinstalls pip as before. |
| installers/nix-setup-template.sh | Runs ensurepip only when pip isn’t importable, then performs the same pip upgrade/reinstall. |
| installers/macos-pkg-setup-template.sh | Mirrors the nix template change: conditionally run ensurepip based on import pip, then upgrade/reinstall. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Review comment for
|
This pull request improves the robustness of the Python installation scripts across macOS, Linux, and Windows by ensuring that
pipis only bootstrapped withensurepipif it is not already present. This prevents unnecessary reinstallation and potential errors during setup.Related issues:
actions/setup-python#1217
actions/setup-python#1295