aboutsummaryrefslogtreecommitdiff
path: root/meson.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2018-06-01 13:00:17 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2018-06-01 19:20:04 +0000
commit0a035dea6d0b1416fc76e323bbd7b0ab5a60a4af (patch)
tree0399ae08fe7cd92d23563db29a401f5454b68693 /meson.py
parent14750b50ea9c9f53237bed59a79365e1ebbdacda (diff)
downloadmeson-0a035dea6d0b1416fc76e323bbd7b0ab5a60a4af.zip
meson-0a035dea6d0b1416fc76e323bbd7b0ab5a60a4af.tar.gz
meson-0a035dea6d0b1416fc76e323bbd7b0ab5a60a4af.tar.bz2
Set the meson command to use when we know what it is
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 'meson.py')
-rwxr-xr-xmeson.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/meson.py b/meson.py
index abbac6f..dc84b51 100755
--- a/meson.py
+++ b/meson.py
@@ -14,13 +14,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from mesonbuild import mesonmain
-import sys, os
+import sys
+from pathlib import Path
+
+# If we're run uninstalled, add the script directory to sys.path to ensure that
+# we always import the correct mesonbuild modules even if PYTHONPATH is mangled
+meson_exe = Path(sys.argv[0]).resolve()
+if (meson_exe.parent / 'mesonbuild').is_dir():
+ sys.path.insert(0, meson_exe.parent)
-def main():
- # Always resolve the command path so Ninja can find it for regen, tests, etc.
- launcher = os.path.realpath(sys.argv[0])
- return mesonmain.run(sys.argv[1:], launcher)
+from mesonbuild import mesonmain
if __name__ == '__main__':
- sys.exit(main())
+ sys.exit(mesonmain.main())