Fix pip --python flag ordering in PYAPP-mode plugin dependency sync - #2392
Open
aryansk wants to merge 1 commit into
Open
Fix pip --python flag ordering in PYAPP-mode plugin dependency sync#2392aryansk wants to merge 1 commit into
aryansk wants to merge 1 commit into
Conversation
…pypa#2389) The shared argument ordering appended `install --disable-pip-version-check --python <executable>` after the pip command, which works for uv (global flags come after the subcommand) but not for pip, where --python must precede the subcommand name. PYAPP-mode `hatch pip install --python ...` silently ignored the flag and installed into the wrong environment. Split the orderings per backend, with regression tests covering both branches.
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.
Summary
When a plugin declares dependencies and hatch needs to sync them, the built
pip/uvcommand appendedinstall --disable-pip-version-check --python <executable>after the subcommand name — the correct order for uv, but not for pip.pip requires global options like
--pythonto come before the subcommand:This is only reachable in PYAPP mode (
PYAPP+PYAPP_COMMAND_NAMEset), where the pip backend is used — uv's ordering was already correct. The flag was being parsed as a pip install option, which pip rejects unknown--pythonfor, so the dependency sync failed (or worse, installed into the wrong environment when a compatible Python was found).Changes
--python <exe>beforeinstallinstallbefore--python)Test Plan
pytest tests/cli/test_application.py— 2 passedmasterand are environment-related.ruff checkandruff format --checkclean on changed files.Fixes #2389