diff --git a/python_wrapper/setup.py b/python_wrapper/setup.py index 92f736683..0d73ad452 100644 --- a/python_wrapper/setup.py +++ b/python_wrapper/setup.py @@ -25,6 +25,7 @@ 'python-dotenv', 'yagmail', 'Werkzeug', + 'importlib_resources>=5.10', ], include_package_data=True, entry_points={ diff --git a/python_wrapper/twa/resRegistry/resRegistry.py b/python_wrapper/twa/resRegistry/resRegistry.py index 6ddde9308..e4e18b336 100644 --- a/python_wrapper/twa/resRegistry/resRegistry.py +++ b/python_wrapper/twa/resRegistry/resRegistry.py @@ -1,4 +1,4 @@ -import pkg_resources +import importlib_resources import json import os import shutil @@ -6,7 +6,7 @@ import builtins import textwrap -_RES_DIR = pkg_resources.resource_filename(__name__, os.path.join('..','resources')) +_RES_DIR = importlib_resources.files(__name__).joinpath('..','resources') _RES_REG_FILE = 'resources_registry.json' _DEF_RES_META_FILE = 'default_resources.json' _URL_ID = 'url://' @@ -24,7 +24,9 @@ def __init__(self): Constructs the registry object. If regsitry file does not exists, it creates one on the fly. """ try: - self.resReg = json.load(pkg_resources.resource_stream(__name__, os.path.join('..','resources',_RES_REG_FILE))) + resource_path = importlib_resources.files(__name__).joinpath('..', 'resources', _RES_REG_FILE) + with importlib_resources.open_text(__name__, resource_path) as resource_file: + self.resReg = json.load(resource_file) except FileNotFoundError: self.resReg = {'resources':{}} self._updateRegFile()