diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2019-03-18 19:30:43 +0100 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2019-03-20 20:37:36 +0200 |
commit | 0078d808a2a2b01c634483ca4a986f52ffe1ce3c (patch) | |
tree | 8760dc22541dec61511b10fe8398725c0276b957 | |
parent | f46b485fc2bee49c5fed763106136218bf0f82dc (diff) | |
download | meson-0078d808a2a2b01c634483ca4a986f52ffe1ce3c.tar.gz |
find_program: use Meson's Python3 for non-executable Python scripts
Whenever a non-executable Python script is found by find_program, currently
Haiku and Windows replace a python3 from the shebang line with the one that
was used by Meson. Extend this behavior to POSIX systems so that it is
easy to test a program with multiple Python versions.
Currently this is particularly important for generators, because
they don't allow files in the arguments and thus you cannot do
something like
g = generator(pymod.find_installation(), ...,
arguments: [files('myscript.py'), ...])
With this patch, instead, you can just do
g = generator(find_program('myscript.py'), ...)
-rw-r--r-- | mesonbuild/dependencies/base.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 995a980bb..de25895c5 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -1993,6 +1993,12 @@ class ExternalProgram: # We know what python3 is, we're running on it if len(commands) > 0 and commands[0] == 'python3': commands = mesonlib.python_command + commands[1:] + else: + # Replace python3 with the actual python3 that we are using + if commands[0] == '/usr/bin/env' and commands[1] == 'python3': + commands = mesonlib.python_command + commands[2:] + elif commands[0].split('/')[-1] == 'python3': + commands = mesonlib.python_command + commands[1:] return commands + [script] except Exception as e: mlog.debug(e) |