[PATCH 3/3] meson: Drop python3_prog

Pavel Hrdina phrdina at redhat.com
Wed Aug 16 10:25:56 UTC 2023


On Tue, Aug 15, 2023 at 02:45:37PM +0200, Michal Privoznik wrote:
> Signed-off-by: Michal Privoznik <mprivozn at 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 at _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 at _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- at 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
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20230816/37abe9df/attachment.sig>


More information about the libvir-list mailing list