|  | 
| 2 | 2 | """ | 
| 3 | 3 | 
 | 
| 4 | 4 | import os | 
| 5 |  | -import shutil | 
| 6 | 5 | import subprocess | 
| 7 | 6 | import sys | 
| 8 | 7 | from typing import List, Optional, Tuple | 
|  | 
| 12 | 11 | from pip._internal.cli.parser import ConfigOptionParser, UpdatingDefaultsHelpFormatter | 
| 13 | 12 | from pip._internal.commands import commands_dict, get_similar_commands | 
| 14 | 13 | from pip._internal.exceptions import CommandError | 
| 15 |  | -from pip._internal.utils.compat import WINDOWS | 
| 16 | 14 | from pip._internal.utils.misc import get_pip_version, get_prog | 
| 17 | 15 | 
 | 
| 18 | 16 | __all__ = ["create_main_parser", "parse_command"] | 
| @@ -50,27 +48,6 @@ def create_main_parser() -> ConfigOptionParser: | 
| 50 | 48 | 
 | 
| 51 | 49 | 
 | 
| 52 | 50 | 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 |  | - | 
| 74 | 51 |     # If the named file exists, use it. | 
| 75 | 52 |     # If it's a directory, assume it's a virtual environment and | 
| 76 | 53 |     # look for the environment's Python executable. | 
|  | 
0 commit comments