aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/modules/python.py
diff options
context:
space:
mode:
authorguruDanny67 <daniele.forghieri@gmail.com>2018-12-30 16:00:04 +0100
committerJussi Pakkanen <jpakkane@gmail.com>2019-01-02 22:18:11 +0200
commitee555e37c9940e04d12f5e11a396d857dc0b7b66 (patch)
tree4ab697694c519713efe6f82362ef7c12e0f75430 /mesonbuild/modules/python.py
parentf1b32aa4bbf7091719b83e64febc1a9f2f4ed67d (diff)
downloadmeson-ee555e37c9940e04d12f5e11a396d857dc0b7b66.zip
meson-ee555e37c9940e04d12f5e11a396d857dc0b7b66.tar.gz
meson-ee555e37c9940e04d12f5e11a396d857dc0b7b66.tar.bz2
Avoid exception looking for python on windows if the launcher (py.exe) is not installed
Diffstat (limited to 'mesonbuild/modules/python.py')
-rw-r--r--mesonbuild/modules/python.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py
index c51b412..9643ebc 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)