Support running out-of-tree tests against a meson in PATH

Closes https://github.com/mesonbuild/meson/issues/3015
pull/3103/head
Nirbheek Chauhan 7 years ago committed by Jussi Pakkanen
parent 0ec18a0531
commit 657d9f2b29
  1. 16
      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.

Loading…
Cancel
Save