From ada37a7f3ed961b7428baf83f34aa1ab88a70b7b Mon Sep 17 00:00:00 2001 From: Vassilis Vassiliadis Date: Thu, 11 Jul 2024 15:37:00 +0100 Subject: [PATCH] refactor: when importlib is unavailable fallback to importlib_metadata Signed-off-by: Vassilis Vassiladis --- requirement_files/requirements_base_3.7.txt | 4 +++- scripts/elaunch.py | 5 ++++- scripts/ewrap.py | 6 +++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/requirement_files/requirements_base_3.7.txt b/requirement_files/requirements_base_3.7.txt index 3b33576..b766d2e 100644 --- a/requirement_files/requirements_base_3.7.txt +++ b/requirement_files/requirements_base_3.7.txt @@ -1,4 +1,6 @@ # Numpy dropped support for python 3.7 in v1.22 numpy < 1.22 # Matplotlib dropped support for python 3.7 in v3.6.0 -matplotlib < 3.6.0 \ No newline at end of file +matplotlib < 3.6.0 +# 6.8.0 requires python 3.8 or later +importlib_metadata < 6.8.0 \ No newline at end of file diff --git a/scripts/elaunch.py b/scripts/elaunch.py index fce1fd0..acb45ff 100755 --- a/scripts/elaunch.py +++ b/scripts/elaunch.py @@ -1105,7 +1105,10 @@ def arg_to_bool(name, val): def build_parser() -> NoSystemExitOptparseOptionParser: - import importlib_metadata + try: + import importlib.metadata as importlib_metadata + except ImportError: + import importlib_metadata # HACK: Daresbury system dependant projectDir = os.path.split(os.path.expanduser("~"))[0] diff --git a/scripts/ewrap.py b/scripts/ewrap.py index 25f5389..573fd39 100755 --- a/scripts/ewrap.py +++ b/scripts/ewrap.py @@ -24,7 +24,11 @@ import experiment.runtime.output import experiment.model.frontends.flowir import experiment.model.storage -import importlib_metadata + +try: + import importlib.metadata as importlib_metadata +except ImportError: + import importlib_metadata import yaml usage = "usage: %prog [options] [package]"