From d27fd555e8226a024c64343931a24fafd7492546 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sat, 9 Apr 2022 22:06:01 -0400 Subject: python module: restore logging for broken python This check was erroneously removed in commit c5c02b72e132a03ae0284bdd5e15d1675301a37d --- mesonbuild/modules/python.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'mesonbuild/modules/python.py') diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py index 3bbccd168..691942e83 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'] -- cgit v1.2.3