Skip to content

Commit

Permalink
Allow multiple versions in gi requirements
Browse files Browse the repository at this point in the history
Enhances the `requires_gi` property in gpr files to allow
mutiple versions of a GObject introspection module.

e.g. requires_gi=[("GooCanvas", "2.0,3.0")]
  • Loading branch information
Nick-Hall committed Sep 9, 2023
1 parent f402000 commit 2ac47de
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions gramps/gen/utils/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,24 @@ def check_gi(self, module_spec):
"""
if module_spec in self.gi_list:
return True

if "," in module_spec[1]:
for version in module_spec[1].split(","):
if self._test_gi(module_spec[0], version.strip()):
self.gi_list.append(module_spec)
return True
else:
if self._test_gi(*module_spec):
self.gi_list.append(module_spec)
return True
return False

def _test_gi(self, module, version):
"""
Test to see if a particular version of a module is available.
"""
try:
gi.require_version(*module_spec)
self.gi_list.append(module_spec)
gi.require_version(module, version)
return True
except ValueError:
return False
Expand Down

0 comments on commit 2ac47de

Please sign in to comment.