from __future__ import absolute_import from __future__ import division from __future__ import print_function __RCSID__ = "45ddde113 (2021-10-01 11:19:55 +0200) Chris Burr " import importlib import six from DIRAC import S_OK from DIRAC.Core.Utilities.Extensions import extensionsByPriority def getCurrentVersion(): """Get a string corresponding to the current version of the DIRAC package and all the installed extension packages """ for ext in extensionsByPriority(): try: return S_OK(importlib.import_module(ext).version) except (ImportError, AttributeError): pass def getVersion(): """Get a dictionary corresponding to the current version of the DIRAC package and all the installed extension packages """ vDict = {"Extensions": {}} for ext in extensionsByPriority(): if six.PY2: try: version = importlib.import_module(ext).version except (ImportError, AttributeError): continue if ext.endswith("DIRAC") and ext != "DIRAC": ext = ext[: -len("DIRAC")] else: from importlib.metadata import version as get_version # pylint: disable=import-error,no-name-in-module version = get_version(ext) vDict["Extensions"][ext] = version return S_OK(vDict)