app, meson: Make python check more robust to work with MacPorts etc

Partially reverts 9be1af2b

See the context: https://gitlab.gnome.org/Infrastructure/gimp-macos-build/-/merge_requests/408#note_2642419
This commit is contained in:
Bruno Lopes 2026-03-20 13:12:52 -03:00
parent 7612363d8c
commit 92a860d5c9
3 changed files with 47 additions and 41 deletions

View file

@ -48,7 +48,6 @@ if [ -f "$OPT_PREFIX/bin/port" ]; then
if echo "$CI_JOB_NAME" | grep -q 'deps' && { [ "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" ] || [ "$first_cache" ] }; then
mkdir -p macports-cached-$(uname -m) && cp -fa $OPT_PREFIX/var/macports/* macports-cached-$(uname -m) || true
fi
git apply -v build/macos/patches/0001-meson-Patch-python-version.patch || true
else
brew upgrade --quiet
brew install --quiet $(tr '\\' '\n' < build/macos/all-deps-uni.txt | grep -v '#' | sed -n 's/.*|homebrew://p' | awk '{print $1}' | xargs)

View file

@ -1,24 +0,0 @@
From 9ee6b4e10c0b429358640aac4e081e2aca329ddb Mon Sep 17 00:00:00 2001
From: Bruno Lopes <brunvonlope@outlook.com>
Date: Sat, 10 Jan 2026 15:49:22 -0300
Subject: [PATCH] meson: Patch python version
---
meson.build | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/meson.build b/meson.build
index cd51137d6f..b59fb6cceb 100644
--- a/meson.build
+++ b/meson.build
@@ -130,7 +130,7 @@ versionconfig.set('GIMP_API_VERSION', gimp_api_version)
pkgconfig = import('pkgconfig')
i18n = import('i18n')
gnome = import('gnome')
-python = import('python').find_installation()
+python = import('python').find_installation('python3.13')
simd = import('unstable-simd')
fs = import('fs')
--
2.50.1 (Apple Git-155)

View file

@ -130,7 +130,7 @@ versionconfig.set('GIMP_API_VERSION', gimp_api_version)
pkgconfig = import('pkgconfig')
i18n = import('i18n')
gnome = import('gnome')
python = import('python').find_installation()
pythonmod = import('python')
simd = import('unstable-simd')
fs = import('fs')
@ -1192,23 +1192,54 @@ perl = find_program('perl5', 'perl', 'perl5.005', 'perl5.004', 'perl')
python3_minver = '>=3.6'
pygobject_minver = '>=3.0'
#Non-versioned python
py_candidates = ['python3']
#Versioned python (e.g. on MacPorts)
foreach i : range(python3_minver.substring(2).split('.')[-1].to_int(), 40)
py_candidates += ['python3.' + i.to_string()]
endforeach
python = disabler()
pygobject_found = ''
pygobject_gexiv2_found = false
foreach py : py_candidates
#Check if PyGobject installation have pycairo (#13105)
python_tmp = pythonmod.find_installation(py, modules: ['gi', 'cairo'], required: false)
if python_tmp.found() and python_tmp.language_version().version_compare(python3_minver)
python = python_tmp
#Check if PyGObject installation have minimum version
pygobject_found = run_command(python_tmp, '-c',
'\n'.join([
'''import gi''',
'''print(".".join(map(str, gi.version_info)))''']),
check: false)
#Check if PyGObject installation have gexiv2 (#15179)
#(This is specially important on MacPorts where gexiv2 have many python variants)
pygobject_gexiv2_found = run_command(python_tmp, '-c',
'\n'.join([
'''import sys, gi''',
'''try:''',
''' import gi.repository.GExiv2''',
'''except (ImportError):''',
''' sys.exit(1)''']),
check: false).returncode() == 0
if pygobject_found.returncode() == 0 and pygobject_found.stdout().strip().version_compare(pygobject_minver) and pygobject_gexiv2_found
break
endif
endif
endforeach
if not python.found() or not python.language_version().version_compare(python3_minver)
error('No suitable Python installation found. Minimum supported version: @0@'.format(python3_minver))
endif
message('Found Python @0@'.format(python.language_version()))
if not python.language_version().version_compare(python3_minver)
error('Minimum supported Python version: @0@'.format(python3_minver))
endif
pygobject_found = run_command(python, '-c',
'\n'.join([
'''import sys, gi''',
'''version = '@0@' '''.format('3.0'),
'''sys.exit(gi.check_version(version))''']),
check: false).returncode() == 0
message('Found PyGObject: @0@'.format(pygobject_found))
if not pygobject_found
error('PyGObject is required.')
if pygobject_found.returncode() != 0 or not pygobject_found.stdout().strip().version_compare(pygobject_minver) or not pygobject_gexiv2_found
error('No suitable PyGObject (with Pycairo and Gexiv2 modules) found. Minimum supported version: @0@'.format(pygobject_minver))
endif
message('Found PyGObject: @0@'.format(pygobject_found.stdout().strip()))
## Javascript
@ -1271,7 +1302,7 @@ if have_lua
endif
if is_supported_lua
have_lua_lgi = run_command(lua, '-e',
have_lua_lgi = run_command(luat, '-e',
'''
local lgi = require 'lgi'
''',