diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2018-02-19 17:43:50 +0530 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2018-02-20 00:17:18 +0200 |
commit | 657d9f2b29334556366eb3c0801612e9e7385f57 (patch) | |
tree | 06b57cbf04f1ab14e6c619daefca2609c8504ef1 | |
parent | 0ec18a0531ba9fc64f3149be3f967a7b5beb2169 (diff) | |
download | meson-657d9f2b29334556366eb3c0801612e9e7385f57.zip meson-657d9f2b29334556366eb3c0801612e9e7385f57.tar.gz meson-657d9f2b29334556366eb3c0801612e9e7385f57.tar.bz2 |
Support running out-of-tree tests against a meson in PATH
Closes https://github.com/mesonbuild/meson/issues/3015
-rw-r--r-- | mesonbuild/mesonlib.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index 65b689f..695c4a9 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -56,12 +56,18 @@ def detect_meson_py_location(): # a) meson is not installed # b) meson is installed to a non-standard location # c) the script that invoked mesonlib is not the one of meson tools (e.g. run_unittests.py) - # The only thing remaining is to try to find the bundled executable and - # pray distro packagers have not moved it. fname = os.path.normpath(os.path.join(os.path.dirname(__file__), '..', 'meson.py')) - if not os.path.exists(fname): - raise RuntimeError('Could not determine how to run Meson. Please file a bug with details.') - return fname + if os.path.exists(fname): + return fname + # If meson is still not found, we might be imported by out-of-source tests + # https://github.com/mesonbuild/meson/issues/3015 + exe = shutil.which('meson') + if exe is None: + exe = shutil.which('meson.py') + if exe is not None: + return exe + # Give up. + raise RuntimeError('Could not determine how to run Meson. Please file a bug with details.') if os.path.basename(sys.executable) == 'meson.exe': # In Windows and using the MSI installed executable. |