From 9f7bdedc94944d11a5166eb47f199c592cb74c0d Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Tue, 6 Mar 2018 22:49:03 +0100 Subject: [PATCH] mesonlib: fix meson detection (again) Starting from 8fc424418720da4ef61bde9348f4cc1a149d1cb2, tests failed on my system (python 3.6 arch) because shutil.which('meson.py') returns 'meson.py', not './meson.py'. Refactor that codepath by using os.path.isabs instead of "m_dir == '.'", also remove the adjacent comment because it doesn't make much sense. --- mesonbuild/mesonlib.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index 9e0508bf2..4e7260066 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -36,12 +36,11 @@ def detect_meson_py_location(): # $ (gets run from /usr/bin/) in_path_exe = shutil.which(c_fname) if in_path_exe: - m_dir, c_fname = os.path.split(in_path_exe) - # Special case: when run like "./meson.py ", - # we need to expand it out, because, for example, - # "ninja test" will be run from a different directory. - if m_dir == '.': + if not os.path.isabs(in_path_exe): m_dir = os.getcwd() + c_fname = in_path_exe + else: + m_dir, c_fname = os.path.split(in_path_exe) else: m_dir = os.path.abspath(c_dir)