From db45d22173d427eee3d673dc63b60b12c206b31d Mon Sep 17 00:00:00 2001 From: Sparky Bluefang Date: Sun, 23 Jun 2024 17:10:47 -0400 Subject: [PATCH] Allow installing gi override to multiple python installations --- meson_options.txt | 9 +++++++-- pygobject/meson.build | 33 +++++++++++++++++++++------------ 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/meson_options.txt b/meson_options.txt index 3ea5310..ccee240 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -9,10 +9,15 @@ option('deprecated_warnings', description: 'Show build warnings for deprecations' ) option('py-overrides-dir', - type : 'string', - value : '', + type : 'array', + value : [], description: 'Path to pygobject overrides directory' ) +option('python_target', + type: 'array', + value: ['python3'], + description: 'Python installation to target to lookup if py-overrides-dir not supplied' +) option('status-notifier', type: 'boolean', value: true, diff --git a/pygobject/meson.build b/pygobject/meson.build index da219f7..d5ffc09 100644 --- a/pygobject/meson.build +++ b/pygobject/meson.build @@ -3,22 +3,31 @@ pygobject = dependency('pygobject-3.0', required: true, ) -override_dir = get_option('py-overrides-dir') +override_dirs = get_option('py-overrides-dir') -if override_dir == '' - exec = find_program(['python3', 'python']) +if override_dirs.length() == 0 or override_dirs[0] == '' + override_dirs = [] - r = run_command(exec, '-c', 'import gi;print(gi._overridesdir)', check: false) + pymod = import('python') + python_targets = get_option('python_target') - if r.returncode() != 0 - error('Error getting the GObject Introspection override directory: ' + r.stderr()) - endif + foreach python_target : python_targets + python_install = pymod.find_installation(python_target) - override_dir = r.stdout().strip() + r = run_command(python_install, '-c', 'import gi;print(gi._overridesdir)', check: false) + + if r.returncode() != 0 + error('Error getting the GObject Introspection override directory: ' + r.stderr()) + endif + + override_dirs += r.stdout().strip() + endforeach endif -message('PyGObject overrides dir: ' + override_dir) +message('PyGObject overrides dirs: @0@'.format(override_dirs)) -install_data(['XApp.py'], - install_dir: override_dir, -) +foreach override_dir : override_dirs + install_data(['XApp.py'], + install_dir: override_dir, + ) +endforeach