aboutsummaryrefslogtreecommitdiff
path: root/meson.py
diff options
context:
space:
mode:
authorEmanuele Aina <emanuele.aina@collabora.com>2016-09-27 15:31:38 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2016-09-30 15:30:27 -0400
commit338dbc964cf2927d476d1fb89a5751e8cfce39bd (patch)
tree47862b01bdaffda9a708d2f9f3f1926c070c0918 /meson.py
parent0a4957627a1e7bc88a74e9398fdf3b6e17cd7b05 (diff)
downloadmeson-338dbc964cf2927d476d1fb89a5751e8cfce39bd.zip
meson-338dbc964cf2927d476d1fb89a5751e8cfce39bd.tar.gz
meson-338dbc964cf2927d476d1fb89a5751e8cfce39bd.tar.bz2
User argv[0] to internally relaunch meson.py
When installing Meson distutils may choose to put shim scripts in the PATH that only set up the egg requirements before launching the real `meson.py` contained in the egg. This means that __file__ points to the real `meson.py` file, but launching it directly is doomed to fail as it's missing the metadata contained in the shim to set up the path egg, resulting in errors when trying to import the `mesonbuild` module. A similar issue affects Meson when installed as a zipapp, with the current code going great lengths to figure out how to relaunch itself. Using argv[0] avoids these issues as it gives us the way the current executable has been launched, so we are pretty much guaranteed that using it will create another instance of the same executable.
Diffstat (limited to 'meson.py')
-rwxr-xr-xmeson.py12
1 files changed, 1 insertions, 11 deletions
diff --git a/meson.py b/meson.py
index fbca883..7f2c49d 100755
--- a/meson.py
+++ b/meson.py
@@ -17,14 +17,4 @@
from mesonbuild import mesonmain
import sys, os
-def main():
- thisfile = __file__
- if not os.path.isabs(thisfile):
- thisfile = os.path.normpath(os.path.join(os.getcwd(), thisfile))
- if __package__ == '':
- thisfile = os.path.dirname(thisfile)
-
- sys.exit(mesonmain.run(thisfile, sys.argv[1:]))
-
-if __name__ == '__main__':
- main()
+sys.exit(mesonmain.run(sys.argv[0], sys.argv[1:]))