Skip to content

Commit

Permalink
Allow installing gi override to multiple python installations (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
SparkyBluefang authored Sep 2, 2024
1 parent 17955c9 commit 4ffed1b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
9 changes: 7 additions & 2 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
33 changes: 21 additions & 12 deletions pygobject/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4ffed1b

Please sign in to comment.