Skip to content

Commit 8d381ee

Browse files
committed
Warn if the --python option is not specified before the subcommand name
1 parent 5e8e88e commit 8d381ee

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

news/12067.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Warn if the ``--python`` option is specified after the subcommand name.

src/pip/_internal/cli/base_command.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,18 @@ def _main(self, args: List[str]) -> int:
131131
", ".join(sorted(always_enabled_features)),
132132
)
133133

134+
135+
# Make sure that the --python argument isn't specified after the
136+
# subcommand. We can tell, because if --python was specified,
137+
# we should only reach this point if we're running in the created
138+
# subprocess, which has the _PIP_RUNNING_IN_SUBPROCESS environment
139+
# variable set.
140+
if options.python and "_PIP_RUNNING_IN_SUBPROCESS" not in os.environ:
141+
logger.warning(
142+
"The --python option is ignored if placed after "
143+
"the pip subcommand name"
144+
)
145+
134146
# TODO: Try to get these passing down from the command?
135147
# without resorting to os.environ to hold these.
136148
# This also affects isolated builds and it should.

0 commit comments

Comments
 (0)