python.find_installation: only try to find python with the py launcher if it isn't in PATH

Meson tries to find the interpreter path through the "py" launcher on Windows in all
cases which breaks if meson is run under MSYS2 and an official CPython is installed as well.
MSYS2 Python doesn't install a py launcher which results in meson finding the system one instead
even though python2/python3 is in PATH.

Always check if the interpreter name is in PATH before falling back to checking the py launcher.
pull/3955/head
Christoph Reiter 6 years ago committed by Jussi Pakkanen
parent 941d2c273a
commit 6b9fdfe67b
  1. 5
      mesonbuild/modules/python.py

@ -470,11 +470,14 @@ class PythonModule(ExtensionModule):
mlog.log("Using meson's python {}".format(mesonlib.python_command))
python = ExternalProgram('python3', mesonlib.python_command, silent=True)
else:
if mesonlib.is_windows():
python = ExternalProgram(name_or_path, silent = True)
if not python.found() and mesonlib.is_windows():
pythonpath = self._get_win_pythonpath(name_or_path)
if pythonpath is not None:
name_or_path = pythonpath
python = ExternalProgram(name_or_path, silent = True)
# Last ditch effort, python2 or python3 can be named python
# on various platforms, let's not give up just yet, if an executable
# named python is available and has a compatible version, let's use

Loading…
Cancel
Save