Skip to contentSkip to conversation

Add execute bit back to scripts/tracetool.py

PATCH Applied Anthony PERARD via 5 participants 6 messages Sep 23, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add execute bit back to scripts/tracetool.py

Commit a81df1b68b65 ("libqemuutil, qapi, trace: convert to meson") removed it without explanation and it is useful to be able to run a script without having to figure out which interpreter to use.

---
 scripts/tracetool.py | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 scripts/tracetool.py
scripts/tracetool.py +0 -0
old mode 100644
new mode 100755
Signature · 1 line
Anthony PERARD
Reviewed-by on v1 1/1
#1 lore raw

scripts/tracetool.py

Quoted 14 lines · Anthony PERARD via

Commit a81df1b68b65 ("libqemuutil, qapi, trace: convert to meson") removed it without explanation and it is useful to be able to run a script without having to figure out which interpreter to use.

---
 scripts/tracetool.py | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 scripts/tracetool.py
scripts/tracetool.py +0 -0
old mode 100644
new mode 100755
#2 lore raw
In reply to Anthony PERARD via

scripts/tracetool.py

Quoted 14 lines · Anthony PERARD

Commit a81df1b68b65 ("libqemuutil, qapi, trace: convert to meson") removed it without explanation and it is useful to be able to run a script without having to figure out which interpreter to use.

---
 scripts/tracetool.py | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 scripts/tracetool.py
scripts/tracetool.py +0 -0
old mode 100644
new mode 100755

The explanation is in docs/devel/build-system.rst

Support scripts
---------------

Meson has a special convention for invoking Python scripts: if their first line is #! /usr/bin/env python3 and the file is *not* executable, find_program() arranges to invoke the script under the same Python interpreter that was used to invoke Meson. This is the most common and preferred way to invoke support scripts from Meson build files, because it automatically uses the value of configure's --python= option.

In case the script is not written in Python, use a #! /usr/bin/env ... line and make the script executable.

Scripts written in Python, where it is desirable to make the script executable (for example for test scripts that developers may want to invoke from the command line, such as tests/qapi-schema/test-qapi.py), should be invoked through the python variable in meson.build. For example::

test('QAPI schema regression tests', python,

       args: files('test-qapi.py'),
       env: test_env, suite: ['qapi-schema', 'qapi-frontend'])

This is needed to obey the --python= option passed to the configure script, which may point to something other than the first python3 binary on the path.

#3 lore raw
Quoted 37 lines · Paolo Bonzini

scripts/tracetool.py

Quoted 14 lines · Anthony PERARD

Commit a81df1b68b65 ("libqemuutil, qapi, trace: convert to meson") removed it without explanation and it is useful to be able to run a script without having to figure out which interpreter to use.

---
 scripts/tracetool.py | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 scripts/tracetool.py
scripts/tracetool.py +0 -0
old mode 100644
new mode 100755

The explanation is in docs/devel/build-system.rst

Support scripts
---------------

Meson has a special convention for invoking Python scripts: if their first line is #! /usr/bin/env python3 and the file is *not* executable, find_program() arranges to invoke the script under the same Python interpreter that was used to invoke Meson. This is the most common and preferred way to invoke support scripts from Meson build files, because it automatically uses the value of configure's --python= option.

In case the script is not written in Python, use a #! /usr/bin/env ... line and make the script executable.

Scripts written in Python, where it is desirable to make the script executable (for example for test scripts that developers may want to invoke from the command line, such as tests/qapi-schema/test-qapi.py), should be invoked through the python variable in meson.build. For example::

Quoted 7 lines

test('QAPI schema regression tests', python,

       args: files('test-qapi.py'),
       env: test_env, suite: ['qapi-schema', 'qapi-frontend'])

This is needed to obey the --python= option passed to the configure script, which may point to something other than the first python3 binary on the path.

The top level meson.build sets

tracetool = [

    python, files('scripts/tracetool.py'),
     '--backend=' + config_host['TRACE_BACKENDS']

]

So looks like we're correctly honouring the configured --python binary, and thus setting the executable bit will not cause any problems with meson.

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#4 lore raw
In reply to Anthony PERARD via

scripts/tracetool.py

Quoted 14 lines · Anthony PERARD

Commit a81df1b68b65 ("libqemuutil, qapi, trace: convert to meson") removed it without explanation and it is useful to be able to run a script without having to figure out which interpreter to use.

---
 scripts/tracetool.py | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 scripts/tracetool.py
scripts/tracetool.py +0 -0
old mode 100644
new mode 100755
#5 lore raw
In reply to Anthony PERARD via
Quoted 9 lines · Anthony PERARD

Commit a81df1b68b65 ("libqemuutil, qapi, trace: convert to meson") removed it without explanation and it is useful to be able to run a script without having to figure out which interpreter to use.

---
 scripts/tracetool.py | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 scripts/tracetool.py

Thanks, applied to my tracing tree:
https://github.com/stefanha/qemu/commits/tracing

Stefan