...
 
Commits (6)
    https://gitcode.net/awesome-mirrors/pypa/pip/-/commit/8d381eeec23cd1a0901266b189740d1a20f08534 Warn if the --python option is not specified before the subcommand name 2023-06-02T11:06:11+01:00 Paul Moore p.f.moore@gmail.com https://gitcode.net/awesome-mirrors/pypa/pip/-/commit/6aa4d48b23e11f6a837b61f4c3fda1a247758357 Fix the test failure 2023-06-05T11:53:43+01:00 Paul Moore p.f.moore@gmail.com https://gitcode.net/awesome-mirrors/pypa/pip/-/commit/073666e2994896a66eff3a474dac3cf03b2dfdd9 Make this an error rather than a warning 2023-06-05T11:57:04+01:00 Paul Moore p.f.moore@gmail.com https://gitcode.net/awesome-mirrors/pypa/pip/-/commit/16f145d30657093dab2fe66cd3695d248c46db45 Add a test for the error 2023-06-05T12:03:22+01:00 Paul Moore p.f.moore@gmail.com https://gitcode.net/awesome-mirrors/pypa/pip/-/commit/de8f0b5ed17fc59fab1f20e9cca92c24ca89136d Lint 2023-06-05T12:11:41+01:00 Paul Moore p.f.moore@gmail.com https://gitcode.net/awesome-mirrors/pypa/pip/-/commit/2d168e6e13cf50bfe10a5cf63aa758799de942da Merge pull request #12068 from pfmoore/python_option_subcommand 2023-06-08T14:20:19+01:00 Paul Moore p.f.moore@gmail.com Error if the --python option is specified after the subcommand name
Fail with an error if the ``--python`` option is specified after the subcommand name.
......@@ -131,6 +131,17 @@ class Command(CommandContextMixIn):
", ".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.critical(
"The --python option must be placed before the pip subcommand name"
)
sys.exit(ERROR)
# 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.
......
......@@ -1157,7 +1157,7 @@ def test_install_nonlocal_compatible_wheel(
"--find-links",
data.find_links,
"--only-binary=:all:",
"--python",
"--python-version",
"3",
"--platform",
"fakeplat",
......@@ -1177,7 +1177,7 @@ def test_install_nonlocal_compatible_wheel(
"--find-links",
data.find_links,
"--only-binary=:all:",
"--python",
"--python-version",
"3",
"--platform",
"fakeplat",
......
......@@ -39,3 +39,15 @@ def test_python_interpreter(
script.pip("--python", env_path, "uninstall", "simplewheel", "--yes")
result = script.pip("--python", env_path, "list", "--format=json")
assert json.loads(result.stdout) == before
def test_error_python_option_wrong_location(
script: PipTestEnvironment,
tmpdir: Path,
shared_data: TestData,
) -> None:
env_path = os.fspath(tmpdir / "venv")
env = EnvBuilder(with_pip=False)
env.create(env_path)
script.pip("list", "--python", env_path, "--format=json", expect_error=True)