2.99 meson: enhance, reduce build time reliance on python3, for MacOS
The symptom is "command 'python3' not found" from meson. The symptom is on older platforms e.g. ten year old MacOS 10.13 High Sierra, where python3 is not native to the platform.
The root cause is that a few GIMP meson.build files call
run_command( 'python3' ...)
This fails because of the meson principle: no access to the environment, commands don't run in a shell. So if 'python3' is not native, meson can't find it. (A non-native python3 installation such as a MacPorts install would install python3 in a non-standard place /opt/local/bin, and doesn't seem to be found by meson.)
A meson.build file is a Python language file. You don't need to "shell out" i.e. call "run_command" to execute Python language in a meson.build file.
Not call run_command('python3') at all
The first fix is to gimp/meson.build about line 1620, replacing calls to python3:
# git-version.h is already present and not generated if dist tarball
fs = import('fs')
is_git_repository = fs.is_file('.git')
has_version_h = fs.is_file('git-version.h')
Since meson 0.53, the Filesystem module 'fs' of meson provides things such as "file exists". So we don't need to shell out to test whether a file exists.
Call run_command('python') instead of python3
The second fix is to icons/Color/meson.build (and Legacy/meson.build and Symbolic/meson.build)
Where ever 'python3' is called, just call 'python'. The Python code that the GIMP meson.build files execute is Python 2 compatible. So if 'python' actually invokes the Python 2, interpreter, the build still works. Note that I haven't tested whether this works on newer system, where I suppose "python" might not be found either.
Discussion
This is about the build system depending on Python at build time, not the GIMP app depending on Python at runtime.
The Gimp build depends on meson, and meson depends on Python3, but Gimp build should not directly depend on Python3. Any Python code in the meson.build files should be Python 2 compatible (and that is easy to do.)
Only important if you want to support older systems.