Skip to content

Commit

Permalink
Warn if the --python option is not specified before the subcommand name
Browse files Browse the repository at this point in the history
  • Loading branch information
pfmoore committed Jun 2, 2023
1 parent 5e8e88e commit 8d381ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions news/12067.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Warn if the ``--python`` option is specified after the subcommand name.
12 changes: 12 additions & 0 deletions src/pip/_internal/cli/base_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,18 @@ def _main(self, args: List[str]) -> int:
", ".join(sorted(always_enabled_features)),
)


# Make sure that the --python argument isn't specified after the
# subcommand. We can tell, because if --python was specified,
# we should only reach this point if we're running in the created
# subprocess, which has the _PIP_RUNNING_IN_SUBPROCESS environment
# variable set.
if options.python and "_PIP_RUNNING_IN_SUBPROCESS" not in os.environ:
logger.warning(
"The --python option is ignored if placed after "
"the pip subcommand name"
)

# TODO: Try to get these passing down from the command?
# without resorting to os.environ to hold these.
# This also affects isolated builds and it should.
Expand Down

0 comments on commit 8d381ee

Please sign in to comment.