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.
This commit is contained in:
Jehan 2024-08-09 01:01:58 +02:00
parent f2d47ee53a
commit 93cc81281c
6 changed files with 35 additions and 66 deletions

View File

@ -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.

View File

@ -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

View File

@ -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),

View File

@ -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')

View File

@ -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

View File

@ -1,5 +1 @@
if not have_python
subdir_done()
endif
subdir('test-file-plug-ins')
subdir('test-file-plug-ins')