diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2018-06-01 13:00:17 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2018-06-01 22:46:37 +0530 |
commit | 9d6bd8a622250bb09246ca7cdf281e96634a198f (patch) | |
tree | cb122eb5604fb7de3572533131afe75b843cf99d /mesonbuild/mesonlib.py | |
parent | 4e0a4177632831f761b46d340e7a0934327ff321 (diff) | |
download | meson-nirbheek/rework-meson-script-handling.tar.gz |
Set the meson command to use when we know what it isnirbheek/rework-meson-script-handling
Instead of using fragile guessing to figure out how to invoke meson,
set the value when meson is run. Also rework how we pass of
meson_script_launcher to regenchecker.py -- it wasn't even being used
With this change, we only need to guess the meson path when running
the tests, and in that case:
1. If MESON_EXE is set in the env, we know how to run meson
for project tests.
2. MESON_EXE is not set, which means we run the configure in-process
for project tests and need to guess what meson to run, so either
- meson.py is found next to run_tests.py, or
- meson, meson.py, or meson.exe is in PATH
Otherwise, you can invoke meson in the following ways:
1. meson is installed, and mesonbuild is available in PYTHONPATH:
- meson, meson.py, meson.exe from PATH
- python3 -m mesonbuild.mesonmain
- python3 /path/to/meson.py
- meson is a shell wrapper to meson.real
2. meson is not installed, and is run from git:
- Absolute path to meson.py
- Relative path to meson.py
- Symlink to meson.py
All these are tested in test_meson_commands.py, except meson.exe since
that involves building the meson msi and installing it.
Diffstat (limited to 'mesonbuild/mesonlib.py')
-rw-r--r-- | mesonbuild/mesonlib.py | 48 |
1 files changed, 1 insertions, 47 deletions
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index fe426c574..15c791840 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -38,58 +38,12 @@ except Exception: from glob import glob -def detect_meson_py_location(): - c = sys.argv[0] - c_dir, c_fname = os.path.split(c) - - # get the absolute path to the <mesontool> folder - m_dir = None - if os.path.isabs(c): - # $ /foo/<mesontool>.py <args> - m_dir = c_dir - elif c_dir == '': - # $ <mesontool> <args> (gets run from /usr/bin/<mesontool>) - in_path_exe = shutil.which(c_fname) - if in_path_exe: - 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) - - # find meson in m_dir - if m_dir is not None: - for fname in ['meson', 'meson.py']: - m_path = os.path.join(m_dir, fname) - if os.path.exists(m_path): - return m_path - - # No meson found, which means that either: - # 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) - fname = os.path.normpath(os.path.join(os.path.dirname(__file__), '..', 'meson.py')) - 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. - meson_command = [sys.executable] python_command = [sys.executable, 'runpython'] else: python_command = [sys.executable] - meson_command = python_command + [detect_meson_py_location()] +meson_command = None def is_ascii_string(astring): try: |