aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Duponchelle <mathieu@centricular.com>2018-03-06 22:49:03 +0100
committerJussi Pakkanen <jpakkane@gmail.com>2018-03-07 19:56:24 +0200
commit9f7bdedc94944d11a5166eb47f199c592cb74c0d (patch)
treeb0842a19e5c32087dda942031dcf1f2848b41119
parente98ae58d0e40a15ae670d456e0c27057b4b2185b (diff)
downloadmeson-9f7bdedc94944d11a5166eb47f199c592cb74c0d.zip
meson-9f7bdedc94944d11a5166eb47f199c592cb74c0d.tar.gz
meson-9f7bdedc94944d11a5166eb47f199c592cb74c0d.tar.bz2
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.
-rw-r--r--mesonbuild/mesonlib.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index 9e0508b..4e72600 100644
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -36,12 +36,11 @@ def detect_meson_py_location():
# $ <mesontool> <args> (gets run from /usr/bin/<mesontool>)
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 <opts>",
- # 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)