From 1cab4f62b940974eba5b27960736e58900a182ee Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Sat, 9 Sep 2023 21:46:26 +0100 Subject: [PATCH] Allow multiple versions in gi requirements 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")] --- gramps/gen/utils/requirements.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/gramps/gen/utils/requirements.py b/gramps/gen/utils/requirements.py index d3261e75607..6178adb1298 100644 --- a/gramps/gen/utils/requirements.py +++ b/gramps/gen/utils/requirements.py @@ -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