diff --git a/pepclibs/helperlibs/ProjectFiles.py b/pepclibs/helperlibs/ProjectFiles.py index d5e2560b..fa643e14 100644 --- a/pepclibs/helperlibs/ProjectFiles.py +++ b/pepclibs/helperlibs/ProjectFiles.py @@ -19,8 +19,13 @@ # TODO: remove the 'importlib_resources' import and use 'importlib.resources' instead when # switching to Python 3.10+. This hack is needed only to support Python 3.9. -#import importlib.resources -import importlib_resources +try: + import importlib.resources + importlib_resources_files = importlib.resources.files +except: + import importlib_resources + importlib_resources_files = importlib_resources.files + from pepclibs.helperlibs import ProcessManager, Logging from pepclibs.helperlibs.Exceptions import Error, ErrorNotFound @@ -78,7 +83,7 @@ def get_python_data_package_path(prjname: str) -> Path | None: # 'improtlib.resources.files()' into a 'Path' object. Just using 'str()' does not work. # However, with 'joinpath()' it is possible to get a string, and then we can convert it # to a 'Path' object. - multiplexed_path = importlib_resources.files(pkgname) + multiplexed_path = importlib_resources_files(pkgname) pkgpath = Path(str(multiplexed_path.joinpath(f"../{pkgname}"))) if pkgpath: return pkgpath.resolve()