aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2023-01-15 20:15:03 -0500
committerJussi Pakkanen <jpakkane@gmail.com>2023-01-30 15:13:06 +0200
commit118396f344a77291e41733194e9ee767a451911c (patch)
tree036bcef9e005f24ae0e8bf0710da27c4888464c9 /mesonbuild
parent7b0a590c1bc1af2a70ca51d9e9865cae741f2cfa (diff)
downloadmeson-118396f344a77291e41733194e9ee767a451911c.zip
meson-118396f344a77291e41733194e9ee767a451911c.tar.gz
meson-118396f344a77291e41733194e9ee767a451911c.tar.bz2
runpython: make it work for -c as well
In commit 4e4f97edb3d475273108b203bc02b04bd6840b06 we added support for runpython to accept `-c 'code to execute'` in addition to just script files. However, doing so would mangle the sys.argv in the executed code -- which assumes, as python itself does, that argv is the stuff after the code to execute. We correctly handled this for script files, but the original addition of -c support pushed this handling into a script-file specific block.
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/mesonmain.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py
index 369b411..c720242 100644
--- a/mesonbuild/mesonmain.py
+++ b/mesonbuild/mesonmain.py
@@ -139,11 +139,11 @@ class CommandLineParser:
parser.add_argument('script_args', nargs=argparse.REMAINDER)
def run_runpython_command(self, options):
- import runpy
+ sys.argv[1:] = options.script_args
if options.eval_arg:
exec(options.script_file)
else:
- sys.argv[1:] = options.script_args
+ import runpy
sys.path.insert(0, os.path.dirname(options.script_file))
runpy.run_path(options.script_file, run_name='__main__')
return 0