From 765a5e98358672f8c433145ee1642dabb75c7f7c Mon Sep 17 00:00:00 2001 From: "Michael Hirsch, Ph.D" Date: Thu, 19 Sep 2019 14:36:03 -0400 Subject: [PATCH 1/2] ducking 'None' for missing module This handles the Windows-specific case, the next commit handles the general issue --- mesonbuild/mesonlib.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index 1adc7523a..db7ac485e 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -1389,13 +1389,13 @@ class BuildDirLock: msvcrt.locking(self.lockfile.fileno(), msvcrt.LK_UNLCK, 1) self.lockfile.close() -def relpath(path, start): +def relpath(path: str, start: str) -> str: # On Windows a relative path can't be evaluated for paths on two different # drives (i.e. c:\foo and f:\bar). The only thing left to do is to use the # original absolute path. try: return os.path.relpath(path, start) - except ValueError: + except (TypeError, ValueError): return path From 4857940e897ad2628cbd182b0632867b43cb4b25 Mon Sep 17 00:00:00 2001 From: "Michael Hirsch, Ph.D" Date: Thu, 19 Sep 2019 14:46:26 -0400 Subject: [PATCH 2/2] raise exception when a non-required module not found and subsequently used --- mesonbuild/interpreter.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index d4f02c042..cd38d40bb 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2388,6 +2388,8 @@ external dependencies (including libraries) must go to "dependencies".''') msg = 'Program {!r} was overridden with the compiled executable {!r}'\ ' and therefore cannot be used during configuration' raise InterpreterException(msg.format(progname, cmd.description())) + if not cmd.found(): + raise InterpreterException('command {!r} not found or not executable'.format(cmd)) elif isinstance(cmd, CompilerHolder): cmd = cmd.compiler.get_exelist()[0] prog = ExternalProgram(cmd, silent=True)