From 93cc81281cd12c55139f483d65629be9c31e798d Mon Sep 17 00:00:00 2001 From: Jehan Date: Fri, 9 Aug 2024 01:01:58 +0200 Subject: [PATCH] Issue #11317: make Python plug-ins mandatory. Unlike the other bindings (Lua, JS, Vala) where we only have a demo plug-in, we actually have a bunch of interesting and useful Python plug-ins. Furthermore, we are running several Python scripts through GIMP during our build (to generate a few images), so pygobject becomes a build dependency anyway, even if it may not be a run dependency with -Dpython=disabled. This all becomes a bit confusing and in fact handling this case (of not installing Python plug-ins) seems like an annoyance while we lose good core plug-ins. So let's just make Python plug-ins mandatory. It's not like Python is very controversial these days, and AFAWK, it is available on every platform out there. --- extensions/goat-exercises/meson.build | 12 +++--- libgimp/meson.build | 2 +- meson.build | 54 +++++++++------------------ meson_options.txt | 1 - plug-ins/python/meson.build | 26 ++++++------- plug-ins/python/tests/meson.build | 6 +-- 6 files changed, 35 insertions(+), 66 deletions(-) diff --git a/extensions/goat-exercises/meson.build b/extensions/goat-exercises/meson.build index 7a916d5dac..2349677ace 100644 --- a/extensions/goat-exercises/meson.build +++ b/extensions/goat-exercises/meson.build @@ -65,13 +65,11 @@ endif # Python 3 (pygobject) version. -if have_python - install_data( - 'goat-exercise-py3.py', - install_dir: gimpplugindir / 'extensions' / extension_name, - ) - plug_ins = plug_ins + ':goat-exercise-py3.py' -endif +install_data( + 'goat-exercise-py3.py', + install_dir: gimpplugindir / 'extensions' / extension_name, +) +plug_ins = plug_ins + ':goat-exercise-py3.py' # Javascript (GJS) version. diff --git a/libgimp/meson.build b/libgimp/meson.build index d72c111145..27d0c28f71 100644 --- a/libgimp/meson.build +++ b/libgimp/meson.build @@ -570,7 +570,7 @@ else endif endif -if have_python and not platform_windows and not platform_osx +if not platform_windows and not platform_osx # Verify .def files for Windows. # Ironically we only check this on non-Windows platform, since the # script expects .so libraries, and I'm not sure that the `nm` tool is diff --git a/meson.build b/meson.build index dc09ac2dd9..8ea17e7d4c 100644 --- a/meson.build +++ b/meson.build @@ -1075,46 +1075,27 @@ perl = find_program('perl5', 'perl', 'perl5.005', 'perl5.004', 'perl') python3_minver = '>=3.6' -python = pythonmod.find_installation('python3') +python = pythonmod.find_installation('python3', required: true) message('Found Python @0@'.format(python.language_version())) -have_python = get_option('python').enabled() - -if get_option('python').allowed() - python_found = ( - python.found() and - python.language_version().version_compare(python3_minver) - ) - if python_found - 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)) - python_found = python_found and pygobject_found - endif - - if python_found - have_python = true - elif have_python - python_warning = ''' - Python @0@ or PyGObject was not found. - Python plug-ins will be installed anyway but you should make sure that - a compatible Python interpreter is available at installation, otherwise - installed plug-ins won't be usable. - '''.format(python3_minver) - warning(python_warning) - warnings += python_warning - endif - - MIMEtypes += 'image/openraster' +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.') +endif + +MIMEtypes += 'image/openraster' + ## Javascript gjs = find_program('gjs', required: get_option('javascript')) @@ -2081,7 +2062,6 @@ final_message = [ .format(can_import_avif, can_export_avif), ''' PDF (export): @0@'''.format(cairopdf.found()), ''' Print: @0@'''.format(have_print), -''' Python 3 plug-ins: @0@'''.format(have_python), ''' Javascript plug-ins: @0@'''.format(have_javascript), ''' Lua plug-ins: @0@'''.format(have_lua), ''' Vala plug-ins: @0@'''.format(have_vala), diff --git a/meson_options.txt b/meson_options.txt index eb6b6c9abd..ad5520ce0e 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -66,4 +66,3 @@ option('vector-icons', type: 'boolean', value: true, description: 'Use ve option('vala', type: 'feature', value: 'auto', description: 'Build VAPI and Vala plugins') option('javascript', type: 'feature', value: 'auto', description: 'Install Javascript plug-ins') option('lua', type: 'feature', value: 'auto', description: 'Install Lua plug-ins') -option('python', type: 'feature', value: 'auto', description: 'Install Python 3 plug-ins') diff --git a/plug-ins/python/meson.build b/plug-ins/python/meson.build index d40eefb2e5..d45451c073 100644 --- a/plug-ins/python/meson.build +++ b/plug-ins/python/meson.build @@ -24,10 +24,8 @@ foreach plugin : plugins name = plugin.get('name') srcs = plugin.get('srcs', [name + '.py']) - if have_python - install_data(srcs, install_dir: gimpplugindir / 'plug-ins' / name, - install_mode: 'rwxr-xr-x') - endif + install_data(srcs, install_dir: gimpplugindir / 'plug-ins' / name, + install_mode: 'rwxr-xr-x') foreach src : srcs # Ugly trick to copy Python plug-ins into subfolders so that we can run GIMP @@ -39,16 +37,14 @@ foreach plugin : plugins endforeach endforeach -if have_python - # Fallback fix to the problem of non-configured interpreters - if platform_windows and not meson.is_cross_build() and python.found() - python_config = configuration_data() - python_config.set('PYTHON_PATH', '') +# Fallback fix to the problem of non-configured interpreters +if platform_windows and not meson.is_cross_build() and python.found() + python_config = configuration_data() + python_config.set('PYTHON_PATH', '') - configure_file(input : 'pygimp.interp.in', - output: 'pygimp.interp', - configuration: python_config, - install: true, - install_dir: gimpplugindir / 'interpreters') - endif + configure_file(input : 'pygimp.interp.in', + output: 'pygimp.interp', + configuration: python_config, + install: true, + install_dir: gimpplugindir / 'interpreters') endif diff --git a/plug-ins/python/tests/meson.build b/plug-ins/python/tests/meson.build index 1d1112dfab..ad9af795a6 100644 --- a/plug-ins/python/tests/meson.build +++ b/plug-ins/python/tests/meson.build @@ -1,5 +1 @@ -if not have_python - subdir_done() -endif - -subdir('test-file-plug-ins') \ No newline at end of file +subdir('test-file-plug-ins')