aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/modules
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2022-04-09 22:06:01 -0400
committerJussi Pakkanen <jpakkane@gmail.com>2022-04-10 15:17:22 +0300
commitd27fd555e8226a024c64343931a24fafd7492546 (patch)
treebb783b955db0b10b8f6d459f39f705ed2620ce63 /mesonbuild/modules
parent7ceec99c55c8534f6c0ec287e0ca7092a8c29ef5 (diff)
downloadmeson-d27fd555e8226a024c64343931a24fafd7492546.zip
meson-d27fd555e8226a024c64343931a24fafd7492546.tar.gz
meson-d27fd555e8226a024c64343931a24fafd7492546.tar.bz2
python module: restore logging for broken python
This check was erroneously removed in commit c5c02b72e132a03ae0284bdd5e15d1675301a37d
Diffstat (limited to 'mesonbuild/modules')
-rw-r--r--mesonbuild/modules/python.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py
index 3bbccd1..691942e 100644
--- a/mesonbuild/modules/python.py
+++ b/mesonbuild/modules/python.py
@@ -643,7 +643,7 @@ class PythonModule(ExtensionModule):
else:
return None
- def _find_installation_impl(self, state: 'ModuleState', display_name: str, name_or_path: str) -> ExternalProgram:
+ def _find_installation_impl(self, state: 'ModuleState', display_name: str, name_or_path: str, required: bool) -> ExternalProgram:
if not name_or_path:
python = PythonExternalProgram('python3', mesonlib.python_command)
else:
@@ -663,10 +663,17 @@ class PythonModule(ExtensionModule):
if not python.found() and name_or_path in ['python2', 'python3']:
python = PythonExternalProgram('python')
- if python.found() and not python.sanity(state):
- python = NonExistingExternalProgram()
+ if python.found():
+ if python.sanity(state):
+ return python
+ else:
+ sanitymsg = f'{python} is not a valid python or it is missing distutils'
+ if required:
+ raise mesonlib.MesonException(sanitymsg)
+ else:
+ mlog.warning(sanitymsg, location=state.current_node)
- return python
+ return NonExistingExternalProgram()
@disablerIfNotFound
@typed_pos_args('python.find_installation', optargs=[str])
@@ -700,7 +707,7 @@ class PythonModule(ExtensionModule):
python = self.installations.get(name_or_path)
if not python:
- python = self._find_installation_impl(state, display_name, name_or_path)
+ python = self._find_installation_impl(state, display_name, name_or_path, required)
self.installations[name_or_path] = python
want_modules = kwargs['modules']