meson: stop discovering native version of Python
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Jul 9, 2025 at 08:23 UTC
10f048fcd18822d38348b2406e3e4bc898fb4a3a
1 file changed
+7
-5
meson.build
+7
-5
@@ -866,9 +866,11 @@ if host_machine.system() == 'cygwin' or host_machine.system() == 'windows'
866
endif
867
build_options_config.set_quoted('X', executable_suffix)
868
869
-python = import('python').find_installation('python3', required: get_option('python'))
870
-target_python = find_program('python3', native: false, required: python.found())
871
-if python.found()
869
+# Python is not used for our build system, but exclusively for git-p4.
870
+# Consequently we only need to determine whether Python is available for the
871
+# build target.
872
+target_python = find_program('python3', native: false, required: get_option('python'))
873
+if target_python.found()
874
build_options_config.set('NO_PYTHON', '')
875
else
876
libgit_c_args += '-DNO_PYTHON'
@@ -1979,7 +1981,7 @@ if perl_features_enabled
1981
subdir('perl')
1982
endif
1983
1982
-if python.found()
1984
+if target_python.found()
1985
scripts_python = [
1986
'git-p4.py'
1987
]
@@ -2190,7 +2192,7 @@ summary({
2192
'iconv': iconv.found(),
2193
'pcre2': pcre2.found(),
2194
'perl': perl_features_enabled,
2193
- 'python': python.found(),
2195
+ 'python': target_python.found(),
2196
}, section: 'Auto-detected features')
2197
2198
summary({