diff options
Diffstat (limited to 'meson.py')
-rwxr-xr-x | meson.py | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -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()) |