File tree 2 files changed +1
-32
lines changed 2 files changed +1
-32
lines changed Original file line number Diff line number Diff line change @@ -50,27 +50,6 @@ def create_main_parser() -> ConfigOptionParser:
50
50
51
51
52
52
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
53
# If the named file exists, use it.
75
54
# If it's a directory, assume it's a virtual environment and
76
55
# look for the environment's Python executable.
Original file line number Diff line number Diff line change @@ -35,23 +35,13 @@ def test_convert_python_version(
35
35
assert actual == expected , f"actual: { actual !r} "
36
36
37
37
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
-
48
38
def test_identify_python_interpreter_venv (tmpdir : Path ) -> None :
49
39
env_path = tmpdir / "venv"
50
40
env = EnvBuilder (with_pip = False )
51
41
env .create (env_path )
52
42
53
43
# 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 ))
55
45
assert interp is not None
56
46
assert Path (interp ).exists ()
57
47
You can’t perform that action at this time.
0 commit comments