git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org,  Ramsay Jones <ramsay@ramsayjones.plus.com>,
	irecca.kun@gmail.com,  Eli Schwartz <eschwartz@gentoo.org>,
	 Jeff King <peff@peff.net>,  Justin Tobler <jltobler@gmail.com>
Subject: Re: [PATCH v3 1/8] meson: stop discovering native version of Python
Date: Wed, 09 Jul 2025 08:09:24 -0700	[thread overview]
Message-ID: <xmqqikk1pfiz.fsf@gitster.g> (raw)
In-Reply-To: <20250709-b4-pks-meson-cleanups-v3-1-29ab15b9ab85@pks.im> (Patrick Steinhardt's message of "Wed, 09 Jul 2025 08:23:35 +0200")

Patrick Steinhardt <ps@pks.im> writes:

> When Python features are enabled we search both for a native and
> non-native version of Python. This is wrong though: we don't use Python
> in our build process, so there is no need to search for it in the first
> place.
>
> There is one location where we use the native version of Python, namely
> when deciding whether or not we want to wire up git-p4(1). This check is
> invalid though, as we shouldn't check for the build host to have Python,
> but for the target host.
>
> Fix this invalid check to use the non-native version of Python and stop
> searching for a native version of Python altogether.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
>  meson.build | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)

The above explains the reasoning very nicely.

> -python = import('python').find_installation('python3', required: get_option('python'))
> -target_python = find_program('python3', native: false, required: python.found())
> -if python.found()
> +# Python is not used for our build system, but exclusively for git-p4.
> +# Consequently we only need to determine whether Python is available for the
> +# build target.
> +target_python = find_program('python3', native: false, required: get_option('python'))
> +if target_python.found()
>    build_options_config.set('NO_PYTHON', '')
>  else
>    libgit_c_args += '-DNO_PYTHON'

We ask explicitly for Python 3 here.

Does find_program() have some magic to deal with installations where
Python3 is simply called /usr/bin/python (and worse yet, not as a
symbolic link to /usr/bin/python3)?

I found

    "Since 0.50.0 if the "python3" program is requested and it is
    not found in the system, Meson will return its current
    interpreter",

which I suspect refers to the path to python3 used during the build
and is not what we want, at

https://mesonbuild.com/Reference-manual_functions.html#find_program

which got me a bit worried.

Perhaps everybody with Python3 has it at /usr/bin/python3 these
days, and my worries are unfounded? ;-)

Thanks.


> @@ -1979,7 +1981,7 @@ if perl_features_enabled
>    subdir('perl')
>  endif
>  
> -if python.found()
> +if target_python.found()
>    scripts_python = [
>      'git-p4.py'
>    ]
> @@ -2202,7 +2204,7 @@ summary({
>    'iconv': iconv.found(),
>    'pcre2': pcre2.found(),
>    'perl': perl_features_enabled,
> -  'python': python.found(),
> +  'python': target_python.found(),
>  }, section: 'Auto-detected features')
>  
>  summary({

  reply	other threads:[~2025-07-09 15:09 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-03  9:28 [PATCH 0/8] A handful of Meson cleanups and improvements Patrick Steinhardt
2025-07-03  9:28 ` [PATCH 1/8] meson: stop discovering native version of Python Patrick Steinhardt
2025-07-08 19:38   ` Justin Tobler
2025-07-09  6:16     ` Patrick Steinhardt
2025-07-03  9:28 ` [PATCH 2/8] meson: stop printing 'https' option twice in our summaries Patrick Steinhardt
2025-07-03  9:28 ` [PATCH 3/8] meson: improve summary of auto-detected features Patrick Steinhardt
2025-07-08 19:56   ` Justin Tobler
2025-07-03  9:28 ` [PATCH 4/8] meson: clean up unnecessary variables Patrick Steinhardt
2025-07-03  9:28 ` [PATCH 5/8] meson: fix lookup of shell on MINGW64 Patrick Steinhardt
2025-07-03  9:28 ` [PATCH 6/8] meson: fix GIT_EXEC_PATH with overridden -Dlibexecdir= Patrick Steinhardt
2025-07-03 16:39   ` Ramsay Jones
2025-07-08  8:44     ` Patrick Steinhardt
2025-07-03  9:28 ` [PATCH 7/8] meson: update subproject wrappers Patrick Steinhardt
2025-07-03  9:28 ` [PATCH 8/8] ci: use Meson's new `--slice` option Patrick Steinhardt
2025-07-08  0:16   ` Junio C Hamano
2025-07-08  1:12     ` Jeff King
2025-07-08  1:39       ` Jeff King
2025-07-08  4:39         ` Junio C Hamano
2025-07-08  7:16         ` Patrick Steinhardt
2025-07-08  7:57 ` [PATCH v2 0/8] A handful of Meson cleanups and improvements Patrick Steinhardt
2025-07-08  7:57   ` [PATCH v2 1/8] meson: stop discovering native version of Python Patrick Steinhardt
2025-07-08  7:57   ` [PATCH v2 2/8] meson: stop printing 'https' option twice in our summaries Patrick Steinhardt
2025-07-08  7:57   ` [PATCH v2 3/8] meson: improve summary of auto-detected features Patrick Steinhardt
2025-07-08  7:57   ` [PATCH v2 4/8] meson: clean up unnecessary variables Patrick Steinhardt
2025-07-08  7:57   ` [PATCH v2 5/8] meson: fix lookup of shell on MINGW64 Patrick Steinhardt
2025-07-08 20:44     ` Justin Tobler
2025-07-08  7:57   ` [PATCH v2 6/8] meson: fix GIT_EXEC_PATH with overridden -Dlibexecdir= Patrick Steinhardt
2025-07-08  7:57   ` [PATCH v2 7/8] meson: update subproject wrappers Patrick Steinhardt
2025-07-08  7:57   ` [PATCH v2 8/8] ci: use Meson's new `--slice` option Patrick Steinhardt
2025-07-09  6:23 ` [PATCH v3 0/8] A handful of Meson cleanups and improvements Patrick Steinhardt
2025-07-09  6:23   ` [PATCH v3 1/8] meson: stop discovering native version of Python Patrick Steinhardt
2025-07-09 15:09     ` Junio C Hamano [this message]
2025-07-09 21:36       ` Justin Tobler
2025-07-09 22:22       ` Eli Schwartz
2025-07-09 22:40         ` Junio C Hamano
2025-07-09  6:23   ` [PATCH v3 2/8] meson: stop printing 'https' option twice in our summaries Patrick Steinhardt
2025-07-09 15:17     ` Junio C Hamano
2025-07-09  6:23   ` [PATCH v3 3/8] meson: improve summary of auto-detected features Patrick Steinhardt
2025-07-10 15:25     ` Toon Claes
2025-07-10 16:24       ` Junio C Hamano
2025-07-09  6:23   ` [PATCH v3 4/8] meson: clean up unnecessary variables Patrick Steinhardt
2025-07-09  6:23   ` [PATCH v3 5/8] meson: fix lookup of shell on MINGW64 Patrick Steinhardt
2025-07-09  6:23   ` [PATCH v3 6/8] meson: fix GIT_EXEC_PATH with overridden -Dlibexecdir= Patrick Steinhardt
2025-07-09  6:23   ` [PATCH v3 7/8] meson: update subproject wrappers Patrick Steinhardt
2025-07-09  6:23   ` [PATCH v3 8/8] ci: use Meson's new `--slice` option Patrick Steinhardt
2025-07-09 21:37   ` [PATCH v3 0/8] A handful of Meson cleanups and improvements Justin Tobler

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=xmqqikk1pfiz.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=eschwartz@gentoo.org \
    --cc=git@vger.kernel.org \
    --cc=irecca.kun@gmail.com \
    --cc=jltobler@gmail.com \
    --cc=peff@peff.net \
    --cc=ps@pks.im \
    --cc=ramsay@ramsayjones.plus.com \
    /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).