fix: check pip module availability instead of PATH binary in download#13947
Merged
honnibal merged 1 commit intoexplosion:masterfrom Mar 28, 2026
Merged
Conversation
_get_pip_install_cmd() uses shutil.which("pip") to check for pip, then
returns [sys.executable, "-m", "pip", "install"] which invokes pip as a
module. The binary check fails in venvs where ensurepip creates pip3 but
not pip (common on Debian/Ubuntu), even though python -m pip works.
Replace shutil.which("pip") with importlib.util.find_spec("pip"), which
tests the actual precondition: whether pip is importable in the current
interpreter. The uv branch is unchanged since uv is a standalone binary.
Fixes explosion#13946
Member
|
Thanks! I should've paid more attention on this. |
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.
Fixes #13946.
_get_pip_install_cmd()checksshutil.which("pip")then returns[sys.executable, "-m", "pip", "install"]. The binary check and the module invocation test different things. In venvs whereensurepipcreatespip3but not barepip(standard on Debian/Ubuntu), the binary check fails even thoughpython -m pipworks.Replaces
shutil.which("pip")withimportlib.util.find_spec("pip")— the actual precondition forsys.executable -m pip. Theuvbranch is unchanged sinceuvis a standalone binary whereshutil.whichis the right check.No new dependencies (stdlib). No change in behavior for environments where both
pipandpip3exist.