From ee555e37c9940e04d12f5e11a396d857dc0b7b66 Mon Sep 17 00:00:00 2001 From: guruDanny67 Date: Sun, 30 Dec 2018 16:00:04 +0100 Subject: [PATCH] Avoid exception looking for python on windows if the launcher (py.exe) is not installed --- mesonbuild/modules/python.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py index c51b412fd..9643ebc44 100644 --- a/mesonbuild/modules/python.py +++ b/mesonbuild/modules/python.py @@ -14,6 +14,7 @@ import os import json +import shutil from pathlib import Path from .. import mesonlib @@ -468,6 +469,9 @@ class PythonModule(ExtensionModule): def _get_win_pythonpath(self, name_or_path): if name_or_path not in ['python2', 'python3']: return None + if not shutil.which('py'): + # program not installed, return without an exception + return None ver = {'python2': '-2', 'python3': '-3'}[name_or_path] cmd = ['py', ver, '-c', "import sysconfig; print(sysconfig.get_config_var('BINDIR'))"] _, stdout, _ = mesonlib.Popen_safe(cmd)