qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Foley <pefoley@google.com>, qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>,
	"Hanna Reitz" <hreitz@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Alexandre Iooss" <erdnaxe@crans.org>,
	"Mahmoud Mandour" <ma.mandourr@gmail.com>,
	"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
	qemu-block@nongnu.org, nabihestefan@google.com
Subject: Re: [PATCH] Use meson's detected python installation
Date: Fri, 5 Sep 2025 09:25:51 +0200	[thread overview]
Message-ID: <6e43209d-645f-46e4-a23a-2a1ec149dfe8@redhat.com> (raw)
In-Reply-To: <20250904-python-v1-1-c43b3209a0cd@google.com>

On 9/4/25 17:11, Peter Foley wrote:
> Relying on `python3` to be avilable in $PATH doesn't work in some build
> environments. Update the build files to use the found python binary
> explicitly.

Meson already does this, if the file is not executable.  See 
docs/devel/build-system.rst:

   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.

Using "[python, 'foo']" is only needed for scripts "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)".

I think the only file you touched that is executable is 
scripts/qemu-plugin-symbols.py; so your issue can be fixed without code 
changes, and with a patch that only does "chmod -x 
scripts/qemu-plugin-symbols.py".  Please correct me if I'm wrong though!

Thanks,

Paolo

> Signed-off-by: Peter Foley <pefoley@google.com>
> ---
>   block/meson.build   |  6 ++----
>   meson.build         | 10 +++++-----
>   plugins/meson.build |  2 +-
>   3 files changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/block/meson.build b/block/meson.build
> index 34b1b2a30630214959630d5543181bc82a54d2b3..67e9bee1210307ff15ca87ba0f5e7f785df15042 100644
> --- a/block/meson.build
> +++ b/block/meson.build
> @@ -139,14 +139,12 @@ if get_option('dmg').allowed()
>     endforeach
>   endif
>   
> -module_block_py = find_program('../scripts/modules/module_block.py')
>   module_block_h = custom_target('module_block.h',
>                                  output: 'module_block.h',
>                                  input: modsrc,
> -                               command: [module_block_py, '@OUTPUT0@', modsrc])
> +                               command: [python, files('../scripts/modules/module_block.py'), '@OUTPUT0@', modsrc])
>   block_ss.add(module_block_h)
>   
> -wrapper_py = find_program('../scripts/block-coroutine-wrapper.py')
>   block_gen_c = custom_target('block-gen.c',
>                               output: 'block-gen.c',
>                               input: files(
> @@ -158,7 +156,7 @@ block_gen_c = custom_target('block-gen.c',
>                                         '../include/system/block-backend-io.h',
>                                         'coroutines.h'
>                                         ),
> -                            command: [wrapper_py, '@OUTPUT@', '@INPUT@'])
> +                            command: [python, files('../scripts/block-coroutine-wrapper.py'), '@OUTPUT@', '@INPUT@'])
>   block_ss.add(block_gen_c)
>   
>   block_ss.add(files('stream.c'))
> diff --git a/meson.build b/meson.build
> index fa6186db33435c26d06dce2971a9f536250607e0..6e8baf3deb13c172eecd371ea302b1c2539048d0 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -12,8 +12,6 @@ add_test_setup('slow', exclude_suites: ['thorough'],
>   add_test_setup('thorough',
>                  env: ['G_TEST_SLOW=1', 'SPEED=thorough', 'RUST_BACKTRACE=1'])
>   
> -meson.add_postconf_script(find_program('scripts/symlink-install-tree.py'))
> -
>   ####################
>   # Global variables #
>   ####################
> @@ -76,6 +74,8 @@ have_user = have_linux_user or have_bsd_user
>   sh = find_program('sh')
>   python = import('python').find_installation()
>   
> +meson.add_postconf_script([python, 'scripts/symlink-install-tree.py'])
> +
>   cc = meson.get_compiler('c')
>   all_languages = ['c']
>   if host_os == 'windows' and add_languages('cpp', required: false, native: false)
> @@ -3474,7 +3474,7 @@ foreach target : target_dirs
>         output: config_devices_mak,
>         depfile: config_devices_mak + '.d',
>         capture: true,
> -      command: [minikconf,
> +      command: [python, minikconf,
>                   get_option('default_devices') ? '--defconfig' : '--allnoconfig',
>                   config_devices_mak, '@DEPFILE@', '@INPUT@',
>                   host_kconfig, target_kconfig])
> @@ -3545,8 +3545,8 @@ config_host_h = configure_file(output: 'config-host.h', configuration: config_ho
>   genh += config_host_h
>   
>   hxtool = find_program('scripts/hxtool')
> -shaderinclude = find_program('scripts/shaderinclude.py')
> -qapi_gen = find_program('scripts/qapi-gen.py')
> +shaderinclude = [python, 'scripts/shaderinclude.py']
> +qapi_gen = [python, 'scripts/qapi-gen.py']
>   qapi_gen_depends = [ meson.current_source_dir() / 'scripts/qapi/__init__.py',
>                        meson.current_source_dir() / 'scripts/qapi/commands.py',
>                        meson.current_source_dir() / 'scripts/qapi/common.py',
> diff --git a/plugins/meson.build b/plugins/meson.build
> index 62c991d87fcdd8bcde8edddcc73909c6133f5460..6bf72a69060414ba1b7c1857515eeceb5a2c7b7c 100644
> --- a/plugins/meson.build
> +++ b/plugins/meson.build
> @@ -6,7 +6,7 @@ qemu_plugin_symbols = configure_file(
>     input: files('../include/qemu/qemu-plugin.h'),
>     output: 'qemu-plugin.symbols',
>     capture: true,
> -  command: [files('../scripts/qemu-plugin-symbols.py'), '@INPUT@'])
> +  command: [python, files('../scripts/qemu-plugin-symbols.py'), '@INPUT@'])
>   
>   # Modules need more symbols than just those in plugins/qemu-plugins.symbols
>   if not enable_modules
> 
> ---
> base-commit: baa79455fa92984ff0f4b9ae94bed66823177a27
> change-id: 20250904-python-78ccebd0fded
> 
> Best regards,



  reply	other threads:[~2025-09-05  7:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-04 15:11 [PATCH] Use meson's detected python installation Peter Foley
2025-09-05  7:25 ` Paolo Bonzini [this message]
2025-09-05 15:01   ` Peter Foley
2025-09-06 14:33     ` Paolo Bonzini
2025-09-08  8:48   ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6e43209d-645f-46e4-a23a-2a1ec149dfe8@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=berrange@redhat.com \
    --cc=erdnaxe@crans.org \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=ma.mandourr@gmail.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=nabihestefan@google.com \
    --cc=pefoley@google.com \
    --cc=philmd@linaro.org \
    --cc=pierrick.bouvier@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).