[PATCH 0/3] meson: Drop python3_prog

Found these on a forgotten local branch. I only vaguely recall the reasoning, but hey - some lines are removed. Michal Prívozník (3): scripts: Avoid spawning yet another process in meson-python.sh scripts: Make standalone python scripts executable meson: Drop python3_prog docs/meson.build | 7 ++--- meson.build | 4 +-- scripts/check-drivername.py | 0 scripts/check-remote-protocol.py | 0 scripts/header-ifdef.py | 0 scripts/meson-install-dirs.py | 0 scripts/meson-install-symlink.py | 0 scripts/meson-python.sh | 2 +- scripts/mock-noinline.py | 0 scripts/prohibit-duplicate-header.py | 0 src/access/meson.build | 6 ++-- src/meson.build | 43 +++++++++++++--------------- src/network/meson.build | 2 +- src/qemu/meson.build | 2 +- tests/meson.build | 2 +- 15 files changed, 32 insertions(+), 36 deletions(-) mode change 100644 => 100755 scripts/check-drivername.py mode change 100644 => 100755 scripts/check-remote-protocol.py mode change 100644 => 100755 scripts/header-ifdef.py mode change 100644 => 100755 scripts/meson-install-dirs.py mode change 100644 => 100755 scripts/meson-install-symlink.py mode change 100644 => 100755 scripts/mock-noinline.py mode change 100644 => 100755 scripts/prohibit-duplicate-header.py -- 2.41.0

The aim of message-python.sh wrapper is to set some environment variables and then execute whatever it was called with (usually a python binary). Well, we can use 'exec' to replace the shell process with python instead of forking yet another process. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- scripts/meson-python.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/meson-python.sh b/scripts/meson-python.sh index 9ba670fc1a..52b37be926 100755 --- a/scripts/meson-python.sh +++ b/scripts/meson-python.sh @@ -1,3 +1,3 @@ #!/bin/sh -LC_ALL= LANG=C LC_CTYPE=en_US.UTF-8 "$@" +LC_ALL= LANG=C LC_CTYPE=en_US.UTF-8 exec "$@" -- 2.41.0

On a Tuesday in 2023, Michal Privoznik wrote:
The aim of message-python.sh wrapper is to set some environment variables and then execute whatever it was called with (usually a python binary).
Well, we can use 'exec' to replace the shell process with python instead of forking yet another process.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- scripts/meson-python.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

We keep a collection of python scripts under scripts/ directory. Some of them have executable bits set and some don't even though they have proper shebang. Add executable bits scripts from the latter set. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- scripts/check-drivername.py | 0 scripts/check-remote-protocol.py | 0 scripts/header-ifdef.py | 0 scripts/meson-install-dirs.py | 0 scripts/meson-install-symlink.py | 0 scripts/mock-noinline.py | 0 scripts/prohibit-duplicate-header.py | 0 7 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/check-drivername.py mode change 100644 => 100755 scripts/check-remote-protocol.py mode change 100644 => 100755 scripts/header-ifdef.py mode change 100644 => 100755 scripts/meson-install-dirs.py mode change 100644 => 100755 scripts/meson-install-symlink.py mode change 100644 => 100755 scripts/mock-noinline.py mode change 100644 => 100755 scripts/prohibit-duplicate-header.py diff --git a/scripts/check-drivername.py b/scripts/check-drivername.py old mode 100644 new mode 100755 diff --git a/scripts/check-remote-protocol.py b/scripts/check-remote-protocol.py old mode 100644 new mode 100755 diff --git a/scripts/header-ifdef.py b/scripts/header-ifdef.py old mode 100644 new mode 100755 diff --git a/scripts/meson-install-dirs.py b/scripts/meson-install-dirs.py old mode 100644 new mode 100755 diff --git a/scripts/meson-install-symlink.py b/scripts/meson-install-symlink.py old mode 100644 new mode 100755 diff --git a/scripts/mock-noinline.py b/scripts/mock-noinline.py old mode 100644 new mode 100755 diff --git a/scripts/prohibit-duplicate-header.py b/scripts/prohibit-duplicate-header.py old mode 100644 new mode 100755 -- 2.41.0

On a Tuesday in 2023, Michal Privoznik wrote:
We keep a collection of python scripts under scripts/ directory. Some of them have executable bits set and some don't even though they have proper shebang. Add executable bits scripts from the latter set.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- scripts/check-drivername.py | 0 scripts/check-remote-protocol.py | 0 scripts/header-ifdef.py | 0 scripts/meson-install-dirs.py | 0 scripts/meson-install-symlink.py | 0 scripts/mock-noinline.py | 0 scripts/prohibit-duplicate-header.py | 0 7 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/check-drivername.py mode change 100644 => 100755 scripts/check-remote-protocol.py mode change 100644 => 100755 scripts/header-ifdef.py mode change 100644 => 100755 scripts/meson-install-dirs.py mode change 100644 => 100755 scripts/meson-install-symlink.py mode change 100644 => 100755 scripts/mock-noinline.py mode change 100644 => 100755 scripts/prohibit-duplicate-header.py
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- docs/meson.build | 7 +++---- meson.build | 4 ++-- src/access/meson.build | 6 +++--- src/meson.build | 43 +++++++++++++++++++---------------------- src/network/meson.build | 2 +- src/qemu/meson.build | 2 +- tests/meson.build | 2 +- 7 files changed, 31 insertions(+), 35 deletions(-) diff --git a/docs/meson.build b/docs/meson.build index b20ef1c926..2231d2da04 100644 --- a/docs/meson.build +++ b/docs/meson.build @@ -126,7 +126,7 @@ aclperms_gen = custom_target( ) docs_timestamp = run_command( - python3_prog, meson_timestamp_prog.full_path(), env: runutf8, check: true, + meson_timestamp_prog, env: runutf8, check: true, ).stdout().strip() site_xsl = files('site.xsl') @@ -345,7 +345,7 @@ endforeach run_target( 'install-web', command: [ - meson_python_prog, python3_prog.full_path(), meson_install_web_prog.full_path(), + meson_python_prog, meson_install_web_prog.full_path(), install_web_files, ], depends: install_web_deps, @@ -353,9 +353,8 @@ run_target( test( 'check-html-references', - python3_prog, + check_html_references_prog, args: [ - check_html_references_prog.full_path(), '--webroot', meson.project_build_root() / 'docs' ], diff --git a/meson.build b/meson.build index 965ada483b..2c7e9908db 100644 --- a/meson.build +++ b/meson.build @@ -2097,7 +2097,7 @@ if git configuration: spec_conf, ) - authors = run_command(python3_prog, meson_gen_authors_prog.full_path(), + authors = run_command(meson_gen_authors_prog, env: runutf8, check: true) authors_file = 'AUTHORS.rst.in' @@ -2119,7 +2119,7 @@ if git foreach file : dist_files meson.add_dist_script( - meson_python_prog.full_path(), python3_prog.full_path(), meson_dist_prog.full_path(), + meson_python_prog.full_path(), meson_dist_prog.full_path(), meson.project_build_root(), file ) endforeach diff --git a/src/access/meson.build b/src/access/meson.build index e65f17c0a2..0ddfbd9d9e 100644 --- a/src/access/meson.build +++ b/src/access/meson.build @@ -70,7 +70,7 @@ if conf.has('WITH_POLKIT') 'org.libvirt.api.policy', input: access_perm_h, output: 'org.libvirt.api.policy', - command: [ meson_python_prog, python3_prog, genpolkit_prog, '@INPUT@' ], + command: [ meson_python_prog, genpolkit_prog, '@INPUT@' ], capture: true, install: true, install_dir: datadir / 'polkit-1' / 'actions', @@ -107,8 +107,8 @@ generated_sym_files += access_gen_sym test( 'check-aclperms', - python3_prog, - args: [ check_aclperms_prog.full_path(), access_perm_h, files('viraccessperm.c') ], + check_aclperms_prog, + args: [ access_perm_h, files('viraccessperm.c') ], env: runutf8, suite: 'script' ) diff --git a/src/meson.build b/src/meson.build index 28e4d0cc4e..606f238a95 100644 --- a/src/meson.build +++ b/src/meson.build @@ -75,7 +75,7 @@ if conf.has('WITH_DTRACE_PROBES') input: infile, output: out_stp, command: [ - meson_python_prog, python3_prog, dtrace2systemtap_prog, + meson_python_prog, dtrace2systemtap_prog, bindir, sbindir, libdir, '@INPUT@' ], capture: true, @@ -692,7 +692,7 @@ foreach data : virt_test_aug_files input: [ data['conf'], data['aug'] ], output: data['name'], command: [ - meson_python_prog, python3_prog, augeas_gentest_prog, + meson_python_prog, augeas_gentest_prog, '@INPUT@', ], capture: true, @@ -771,7 +771,7 @@ foreach data : virt_daemon_confs input: [ conf_out, test_aug_tmp ], output: test_aug_out, command: [ - meson_python_prog, python3_prog, augeas_gentest_prog, + meson_python_prog, augeas_gentest_prog, '@INPUT@', ], capture: true, @@ -890,7 +890,7 @@ if conf.has('WITH_DTRACE_PROBES') input: rpc_probe_files, output: 'libvirt_functions.stp', command: [ - meson_python_prog, python3_prog, gensystemtap_prog, + meson_python_prog, gensystemtap_prog, '@INPUT@', ], capture: true, @@ -910,7 +910,7 @@ virt_install_dirs += [ ] meson.add_install_script( - meson_python_prog.full_path(), python3_prog.full_path(), meson_install_dirs_prog.full_path(), + meson_python_prog.full_path(), meson_install_dirs_prog.full_path(), virt_install_dirs, ) @@ -920,8 +920,8 @@ meson.add_install_script( if host_machine.system() == 'linux' test( 'check-symfile', - python3_prog, - args: [ check_symfile_prog.full_path(), libvirt_syms, libvirt_lib ], + check_symfile_prog, + args: [ libvirt_syms, libvirt_lib ], env: runutf8, suite: 'script' ) @@ -929,8 +929,8 @@ if host_machine.system() == 'linux' if conf.has('WITH_REMOTE') test( 'check-admin-symfile', - python3_prog, - args: [ check_symfile_prog.full_path(), libvirt_admin_syms, libvirt_admin_lib ], + check_symfile_prog, + args: [ libvirt_admin_syms, libvirt_admin_lib ], env: runutf8, suite: 'script' ) @@ -939,9 +939,8 @@ endif test( 'check-symsorting', - python3_prog, + check_symsorting_prog, args: [ - check_symsorting_prog.full_path(), meson.current_source_dir(), files(sym_files, used_sym_files), ], @@ -951,9 +950,8 @@ test( test( 'check-admin-symsorting', - python3_prog, + check_symsorting_prog, args: [ - check_symsorting_prog.full_path(), meson.current_source_dir(), libvirt_admin_private_syms, ], @@ -963,9 +961,9 @@ test( test( 'check-drivername', - python3_prog, + check_drivername_prog, args: [ - check_drivername_prog.full_path(), files(driver_headers), + files(driver_headers), files('libvirt_public.syms'), libvirt_qemu_syms, libvirt_lxc_syms, ], env: runutf8, @@ -974,9 +972,9 @@ test( test( 'check-admin-drivername', - python3_prog, + check_drivername_prog, args: [ - check_drivername_prog.full_path(), libvirt_admin_public_syms, + libvirt_admin_public_syms, ], env: runutf8, suite: 'script' @@ -984,16 +982,16 @@ test( test( 'check-driverimpls', - python3_prog, - args: [ check_driverimpls_prog.full_path(), driver_source_files ], + check_driverimpls_prog, + args: [ driver_source_files ], env: runutf8, suite: 'script' ) test( 'check-aclrules', - python3_prog, - args: [ check_aclrules_prog.full_path(), files('remote/remote_protocol.x'), stateful_driver_source_files ], + check_aclrules_prog, + args: [ files('remote/remote_protocol.x'), stateful_driver_source_files ], env: runutf8, suite: 'script' ) @@ -1018,9 +1016,8 @@ if pdwtags_prog.found() and cc.get_id() != 'clang' lib = proto['lib'] test( 'check-@0@'.format(proto['name']), - python3_prog, + check_remote_protocol_prog, args: [ - check_remote_protocol_prog.full_path(), proto['name'], lib.name(), lib.full_path(), diff --git a/src/network/meson.build b/src/network/meson.build index 0888d1beac..cea0d1dcd8 100644 --- a/src/network/meson.build +++ b/src/network/meson.build @@ -90,7 +90,7 @@ if conf.has('WITH_NETWORK') ) meson.add_install_script( - meson_python_prog.full_path(), python3_prog.full_path(), meson_install_symlink_prog.full_path(), + meson_python_prog.full_path(), meson_install_symlink_prog.full_path(), confdir / 'qemu' / 'networks' / 'autostart', '../default.xml', 'default.xml', ) diff --git a/src/qemu/meson.build b/src/qemu/meson.build index c8806bbc36..271a0b4139 100644 --- a/src/qemu/meson.build +++ b/src/qemu/meson.build @@ -73,7 +73,7 @@ if conf.has('WITH_DTRACE_PROBES') input: infile, output: out_stp, command: [ - meson_python_prog, python3_prog, dtrace2systemtap_prog, + meson_python_prog, dtrace2systemtap_prog, bindir, sbindir, libdir, '@INPUT@', ], capture: true, diff --git a/tests/meson.build b/tests/meson.build index e6589ec555..0787b91513 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -711,7 +711,7 @@ testenv += 'VIR_TEST_FILE_ACCESS=1' add_test_setup( 'access', env: testenv, - exe_wrapper: [ python3_prog, check_file_access_prog.full_path() ], + exe_wrapper: [ check_file_access_prog ], ) add_test_setup( -- 2.41.0

On a Tuesday in 2023, Michal Privoznik wrote:
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Missing commit message.
--- docs/meson.build | 7 +++---- meson.build | 4 ++-- src/access/meson.build | 6 +++--- src/meson.build | 43 +++++++++++++++++++---------------------- src/network/meson.build | 2 +- src/qemu/meson.build | 2 +- tests/meson.build | 2 +- 7 files changed, 31 insertions(+), 35 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

On Tue, Aug 15, 2023 at 02:45:37PM +0200, Michal Privoznik wrote:
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- docs/meson.build | 7 +++---- meson.build | 4 ++-- src/access/meson.build | 6 +++--- src/meson.build | 43 +++++++++++++++++++---------------------- src/network/meson.build | 2 +- src/qemu/meson.build | 2 +- tests/meson.build | 2 +- 7 files changed, 31 insertions(+), 35 deletions(-)
Not sure we can do this. In meson.build we have the following: required_programs = [ 'perl', 'python3', 'xmllint', 'xsltproc', ] foreach name : required_programs prog = find_program(name, dirs: libvirt_sbin_path) varname = name.underscorify() conf.set_quoted(varname.to_upper(), prog.full_path()) set_variable('@0@_prog'.format(varname), prog) endforeach which will set the python3_prog variable and we use that as our python executable. I did a quick testing using the following meson.build file: ----------------------------------------------------------------------- project('mesonpy', 'c') required_programs = [ 'python3', ] foreach name : required_programs prog = find_program(name) varname = name.underscorify() set_variable('@0@_prog'.format(varname), prog) endforeach res1 = run_command(python3_prog, 'script.py') res2 = run_command('script.py') warning(res1.stdout()) warning(res2.stdout()) ----------------------------------------------------------------------- with the script.py having the following: ----------------------------------------------------------------------- #!/usr/bin/env python3 import sys print(sys.version) ----------------------------------------------------------------------- and when I changed PATH to have python3 pointing to python3.12 but my system python is python3.11 I've got the following resutl: meson.build:16: WARNING: 3.12.0b4 (main, Jul 12 2023, 00:00:00) [GCC 13.1.1 20230614 (Red Hat 13.1.1-4)] meson.build:17: WARNING: 3.11.4 (main, Jun 7 2023, 00:00:00) [GCC 13.1.1 20230511 (Red Hat 13.1.1-2)] Don't remember the origin of the wrapper but my guess is that this was the main reason why we have it. Pavel
diff --git a/docs/meson.build b/docs/meson.build index b20ef1c926..2231d2da04 100644 --- a/docs/meson.build +++ b/docs/meson.build @@ -126,7 +126,7 @@ aclperms_gen = custom_target( )
docs_timestamp = run_command( - python3_prog, meson_timestamp_prog.full_path(), env: runutf8, check: true, + meson_timestamp_prog, env: runutf8, check: true, ).stdout().strip()
site_xsl = files('site.xsl') @@ -345,7 +345,7 @@ endforeach run_target( 'install-web', command: [ - meson_python_prog, python3_prog.full_path(), meson_install_web_prog.full_path(), + meson_python_prog, meson_install_web_prog.full_path(), install_web_files, ], depends: install_web_deps, @@ -353,9 +353,8 @@ run_target(
test( 'check-html-references', - python3_prog, + check_html_references_prog, args: [ - check_html_references_prog.full_path(), '--webroot', meson.project_build_root() / 'docs' ], diff --git a/meson.build b/meson.build index 965ada483b..2c7e9908db 100644 --- a/meson.build +++ b/meson.build @@ -2097,7 +2097,7 @@ if git configuration: spec_conf, )
- authors = run_command(python3_prog, meson_gen_authors_prog.full_path(), + authors = run_command(meson_gen_authors_prog, env: runutf8, check: true) authors_file = 'AUTHORS.rst.in'
@@ -2119,7 +2119,7 @@ if git
foreach file : dist_files meson.add_dist_script( - meson_python_prog.full_path(), python3_prog.full_path(), meson_dist_prog.full_path(), + meson_python_prog.full_path(), meson_dist_prog.full_path(), meson.project_build_root(), file ) endforeach diff --git a/src/access/meson.build b/src/access/meson.build index e65f17c0a2..0ddfbd9d9e 100644 --- a/src/access/meson.build +++ b/src/access/meson.build @@ -70,7 +70,7 @@ if conf.has('WITH_POLKIT') 'org.libvirt.api.policy', input: access_perm_h, output: 'org.libvirt.api.policy', - command: [ meson_python_prog, python3_prog, genpolkit_prog, '@INPUT@' ], + command: [ meson_python_prog, genpolkit_prog, '@INPUT@' ], capture: true, install: true, install_dir: datadir / 'polkit-1' / 'actions', @@ -107,8 +107,8 @@ generated_sym_files += access_gen_sym
test( 'check-aclperms', - python3_prog, - args: [ check_aclperms_prog.full_path(), access_perm_h, files('viraccessperm.c') ], + check_aclperms_prog, + args: [ access_perm_h, files('viraccessperm.c') ], env: runutf8, suite: 'script' ) diff --git a/src/meson.build b/src/meson.build index 28e4d0cc4e..606f238a95 100644 --- a/src/meson.build +++ b/src/meson.build @@ -75,7 +75,7 @@ if conf.has('WITH_DTRACE_PROBES') input: infile, output: out_stp, command: [ - meson_python_prog, python3_prog, dtrace2systemtap_prog, + meson_python_prog, dtrace2systemtap_prog, bindir, sbindir, libdir, '@INPUT@' ], capture: true, @@ -692,7 +692,7 @@ foreach data : virt_test_aug_files input: [ data['conf'], data['aug'] ], output: data['name'], command: [ - meson_python_prog, python3_prog, augeas_gentest_prog, + meson_python_prog, augeas_gentest_prog, '@INPUT@', ], capture: true, @@ -771,7 +771,7 @@ foreach data : virt_daemon_confs input: [ conf_out, test_aug_tmp ], output: test_aug_out, command: [ - meson_python_prog, python3_prog, augeas_gentest_prog, + meson_python_prog, augeas_gentest_prog, '@INPUT@', ], capture: true, @@ -890,7 +890,7 @@ if conf.has('WITH_DTRACE_PROBES') input: rpc_probe_files, output: 'libvirt_functions.stp', command: [ - meson_python_prog, python3_prog, gensystemtap_prog, + meson_python_prog, gensystemtap_prog, '@INPUT@', ], capture: true, @@ -910,7 +910,7 @@ virt_install_dirs += [ ]
meson.add_install_script( - meson_python_prog.full_path(), python3_prog.full_path(), meson_install_dirs_prog.full_path(), + meson_python_prog.full_path(), meson_install_dirs_prog.full_path(), virt_install_dirs, )
@@ -920,8 +920,8 @@ meson.add_install_script( if host_machine.system() == 'linux' test( 'check-symfile', - python3_prog, - args: [ check_symfile_prog.full_path(), libvirt_syms, libvirt_lib ], + check_symfile_prog, + args: [ libvirt_syms, libvirt_lib ], env: runutf8, suite: 'script' ) @@ -929,8 +929,8 @@ if host_machine.system() == 'linux' if conf.has('WITH_REMOTE') test( 'check-admin-symfile', - python3_prog, - args: [ check_symfile_prog.full_path(), libvirt_admin_syms, libvirt_admin_lib ], + check_symfile_prog, + args: [ libvirt_admin_syms, libvirt_admin_lib ], env: runutf8, suite: 'script' ) @@ -939,9 +939,8 @@ endif
test( 'check-symsorting', - python3_prog, + check_symsorting_prog, args: [ - check_symsorting_prog.full_path(), meson.current_source_dir(), files(sym_files, used_sym_files), ], @@ -951,9 +950,8 @@ test(
test( 'check-admin-symsorting', - python3_prog, + check_symsorting_prog, args: [ - check_symsorting_prog.full_path(), meson.current_source_dir(), libvirt_admin_private_syms, ], @@ -963,9 +961,9 @@ test(
test( 'check-drivername', - python3_prog, + check_drivername_prog, args: [ - check_drivername_prog.full_path(), files(driver_headers), + files(driver_headers), files('libvirt_public.syms'), libvirt_qemu_syms, libvirt_lxc_syms, ], env: runutf8, @@ -974,9 +972,9 @@ test(
test( 'check-admin-drivername', - python3_prog, + check_drivername_prog, args: [ - check_drivername_prog.full_path(), libvirt_admin_public_syms, + libvirt_admin_public_syms, ], env: runutf8, suite: 'script' @@ -984,16 +982,16 @@ test(
test( 'check-driverimpls', - python3_prog, - args: [ check_driverimpls_prog.full_path(), driver_source_files ], + check_driverimpls_prog, + args: [ driver_source_files ], env: runutf8, suite: 'script' )
test( 'check-aclrules', - python3_prog, - args: [ check_aclrules_prog.full_path(), files('remote/remote_protocol.x'), stateful_driver_source_files ], + check_aclrules_prog, + args: [ files('remote/remote_protocol.x'), stateful_driver_source_files ], env: runutf8, suite: 'script' ) @@ -1018,9 +1016,8 @@ if pdwtags_prog.found() and cc.get_id() != 'clang' lib = proto['lib'] test( 'check-@0@'.format(proto['name']), - python3_prog, + check_remote_protocol_prog, args: [ - check_remote_protocol_prog.full_path(), proto['name'], lib.name(), lib.full_path(), diff --git a/src/network/meson.build b/src/network/meson.build index 0888d1beac..cea0d1dcd8 100644 --- a/src/network/meson.build +++ b/src/network/meson.build @@ -90,7 +90,7 @@ if conf.has('WITH_NETWORK') )
meson.add_install_script( - meson_python_prog.full_path(), python3_prog.full_path(), meson_install_symlink_prog.full_path(), + meson_python_prog.full_path(), meson_install_symlink_prog.full_path(), confdir / 'qemu' / 'networks' / 'autostart', '../default.xml', 'default.xml', ) diff --git a/src/qemu/meson.build b/src/qemu/meson.build index c8806bbc36..271a0b4139 100644 --- a/src/qemu/meson.build +++ b/src/qemu/meson.build @@ -73,7 +73,7 @@ if conf.has('WITH_DTRACE_PROBES') input: infile, output: out_stp, command: [ - meson_python_prog, python3_prog, dtrace2systemtap_prog, + meson_python_prog, dtrace2systemtap_prog, bindir, sbindir, libdir, '@INPUT@', ], capture: true, diff --git a/tests/meson.build b/tests/meson.build index e6589ec555..0787b91513 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -711,7 +711,7 @@ testenv += 'VIR_TEST_FILE_ACCESS=1' add_test_setup( 'access', env: testenv, - exe_wrapper: [ python3_prog, check_file_access_prog.full_path() ], + exe_wrapper: [ check_file_access_prog ], )
add_test_setup( -- 2.41.0

On 8/16/23 12:25, Pavel Hrdina wrote:
On Tue, Aug 15, 2023 at 02:45:37PM +0200, Michal Privoznik wrote:
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- docs/meson.build | 7 +++---- meson.build | 4 ++-- src/access/meson.build | 6 +++--- src/meson.build | 43 +++++++++++++++++++---------------------- src/network/meson.build | 2 +- src/qemu/meson.build | 2 +- tests/meson.build | 2 +- 7 files changed, 31 insertions(+), 35 deletions(-)
Not sure we can do this. In meson.build we have the following:
required_programs = [ 'perl', 'python3', 'xmllint', 'xsltproc', ]
foreach name : required_programs prog = find_program(name, dirs: libvirt_sbin_path) varname = name.underscorify() conf.set_quoted(varname.to_upper(), prog.full_path()) set_variable('@0@_prog'.format(varname), prog) endforeach
which will set the python3_prog variable and we use that as our python executable.
I did a quick testing using the following meson.build file:
----------------------------------------------------------------------- project('mesonpy', 'c')
required_programs = [ 'python3', ]
foreach name : required_programs prog = find_program(name) varname = name.underscorify() set_variable('@0@_prog'.format(varname), prog) endforeach
res1 = run_command(python3_prog, 'script.py') res2 = run_command('script.py')
warning(res1.stdout()) warning(res2.stdout()) -----------------------------------------------------------------------
with the script.py having the following:
----------------------------------------------------------------------- #!/usr/bin/env python3
import sys
print(sys.version) -----------------------------------------------------------------------
and when I changed PATH to have python3 pointing to python3.12 but my system python is python3.11 I've got the following resutl:
meson.build:16: WARNING: 3.12.0b4 (main, Jul 12 2023, 00:00:00) [GCC 13.1.1 20230614 (Red Hat 13.1.1-4)]
meson.build:17: WARNING: 3.11.4 (main, Jun 7 2023, 00:00:00) [GCC 13.1.1 20230511 (Red Hat 13.1.1-2)]
Don't remember the origin of the wrapper but my guess is that this was the main reason why we have it.
Right. But this is expected, isn't it? The same way, if you'd change any other binary invoked from meson (say compiler) and we don't hardcode paths for them either. IOW - why should this behavior be problematic? BTW: we already invoke python scripts WITHOUT pytho3_prog and it didn't bother us yet: apibuild_prog, hyperv_wmi_generator_prog, esx_vi_generator_prog to name a few. Michal

On Wed, Aug 16, 2023 at 01:18:37PM +0200, Michal Prívozník wrote:
On 8/16/23 12:25, Pavel Hrdina wrote:
On Tue, Aug 15, 2023 at 02:45:37PM +0200, Michal Privoznik wrote:
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- docs/meson.build | 7 +++---- meson.build | 4 ++-- src/access/meson.build | 6 +++--- src/meson.build | 43 +++++++++++++++++++---------------------- src/network/meson.build | 2 +- src/qemu/meson.build | 2 +- tests/meson.build | 2 +- 7 files changed, 31 insertions(+), 35 deletions(-)
Not sure we can do this. In meson.build we have the following:
required_programs = [ 'perl', 'python3', 'xmllint', 'xsltproc', ]
foreach name : required_programs prog = find_program(name, dirs: libvirt_sbin_path) varname = name.underscorify() conf.set_quoted(varname.to_upper(), prog.full_path()) set_variable('@0@_prog'.format(varname), prog) endforeach
which will set the python3_prog variable and we use that as our python executable.
I did a quick testing using the following meson.build file:
----------------------------------------------------------------------- project('mesonpy', 'c')
required_programs = [ 'python3', ]
foreach name : required_programs prog = find_program(name) varname = name.underscorify() set_variable('@0@_prog'.format(varname), prog) endforeach
res1 = run_command(python3_prog, 'script.py') res2 = run_command('script.py')
warning(res1.stdout()) warning(res2.stdout()) -----------------------------------------------------------------------
with the script.py having the following:
----------------------------------------------------------------------- #!/usr/bin/env python3
import sys
print(sys.version) -----------------------------------------------------------------------
and when I changed PATH to have python3 pointing to python3.12 but my system python is python3.11 I've got the following resutl:
meson.build:16: WARNING: 3.12.0b4 (main, Jul 12 2023, 00:00:00) [GCC 13.1.1 20230614 (Red Hat 13.1.1-4)]
meson.build:17: WARNING: 3.11.4 (main, Jun 7 2023, 00:00:00) [GCC 13.1.1 20230511 (Red Hat 13.1.1-2)]
Don't remember the origin of the wrapper but my guess is that this was the main reason why we have it.
Right. But this is expected, isn't it? The same way, if you'd change any other binary invoked from meson (say compiler) and we don't hardcode paths for them either.
IOW - why should this behavior be problematic?
After offlist discussion and explanation the patch will not be merged. The main issue with this patch is that compiling libvirt would use system python and not what user have in the current environment which is not the same what happens with compiler or other binaries we are using during compilation. Pavel
BTW: we already invoke python scripts WITHOUT pytho3_prog and it didn't bother us yet: apibuild_prog, hyperv_wmi_generator_prog, esx_vi_generator_prog to name a few.
Yeah, some of them where broken by commit <e06beacec2f8e57bbc5cd8f6eb9d44a1f291966d> and that should be fixed. Pavel
participants (4)
-
Ján Tomko
-
Michal Privoznik
-
Michal Prívozník
-
Pavel Hrdina