Skip to content

Commit 9e7d96d

Browse files
committed
Get rid of the --python python/py shortcuts
1 parent 0d6fada commit 9e7d96d

File tree

2 files changed

+1
-32
lines changed

2 files changed

+1
-32
lines changed

src/pip/_internal/cli/main_parser.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,6 @@ def create_main_parser() -> ConfigOptionParser:
5050

5151

5252
def identify_python_interpreter(python: str) -> Optional[str]:
53-
if python == "python" or python == "py":
54-
# Run the active Python.
55-
# We have to be very careful here, because:
56-
#
57-
# 1. On Unix, "python" is probably correct but there is a "py" launcher.
58-
# 2. On Windows, "py" is the best option if it's present.
59-
# 3. On Windows without "py", "python" might work, but it might also
60-
# be the shim that launches the Windows store to allow you to install
61-
# Python.
62-
#
63-
# We go with getting py on Windows, and if it's not present or we're
64-
# on Unix, get python. We don't worry about the launcher on Unix or
65-
# the installer stub on Windows.
66-
py = None
67-
if WINDOWS:
68-
py = shutil.which("py")
69-
if py is None:
70-
py = shutil.which("python")
71-
if py:
72-
return py
73-
7453
# If the named file exists, use it.
7554
# If it's a directory, assume it's a virtual environment and
7655
# look for the environment's Python executable.

tests/unit/test_cmdoptions.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,13 @@ def test_convert_python_version(
3535
assert actual == expected, f"actual: {actual!r}"
3636

3737

38-
def test_identify_python_interpreter_py(monkeypatch: pytest.MonkeyPatch) -> None:
39-
def which(cmd: str) -> str:
40-
assert cmd == "py" or cmd == "python"
41-
return "dummy_value"
42-
43-
monkeypatch.setattr("shutil.which", which)
44-
assert identify_python_interpreter("py") == "dummy_value"
45-
assert identify_python_interpreter("python") == "dummy_value"
46-
47-
4838
def test_identify_python_interpreter_venv(tmpdir: Path) -> None:
4939
env_path = tmpdir / "venv"
5040
env = EnvBuilder(with_pip=False)
5141
env.create(env_path)
5242

5343
# Passing a virtual environment returns the Python executable
54-
interp = identify_python_interpreter(os.fsdecode(env_path))
44+
interp = identify_python_interpreter(os.fspath(env_path))
5545
assert interp is not None
5646
assert Path(interp).exists()
5747

0 commit comments

Comments
 (0)