diff --git a/pyproject.toml b/pyproject.toml index 840870aa..8d96944e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,6 +38,7 @@ dependencies=[ "biocommons.seqrepo >= 0.6.5", "bioutils >= 0.4.0,<1.0", "configparser >= 3.3.0", + "importlib_resources", "ipython", "parsley", "psycopg2", diff --git a/src/hgvs/config.py b/src/hgvs/config.py index c0c7b301..ff05ac16 100644 --- a/src/hgvs/config.py +++ b/src/hgvs/config.py @@ -31,7 +31,10 @@ import re from configparser import ConfigParser, ExtendedInterpolation from copy import copy -from importlib import resources +try: + from importlib.resources import files as resources_files +except ImportError: + from importlib_resources import files as resources_files logger = logging.getLogger(__name__) @@ -115,6 +118,6 @@ def _val_xform(v): _default_config = Config() -_default_config.read_stream(resources.files(__package__) / "_data" / "defaults.ini") +_default_config.read_stream(resources_files(__package__) / "_data" / "defaults.ini") global_config = copy(_default_config) diff --git a/tests/test_hgvs_grammar_full.py b/tests/test_hgvs_grammar_full.py index 3758925d..5c55c4c6 100644 --- a/tests/test_hgvs_grammar_full.py +++ b/tests/test_hgvs_grammar_full.py @@ -4,7 +4,10 @@ import re import unittest from sys import version_info -from importlib import resources +try: + from importlib.resources import files as resources_files +except ImportError: + from importlib_resources import files as resources_files # # Tests of the grammar @@ -51,7 +54,7 @@ def test_parser_test_completeness(self): """ensure that all rules in grammar have tests""" grammar_rule_re = re.compile(r"^(\w+)") - grammar_fn = resources.files("hgvs") / "_data" / "hgvs.pymeta" + grammar_fn = resources_files("hgvs") / "_data" / "hgvs.pymeta" with open(grammar_fn, "r") as f: grammar_rules = set(r.group(1) for r in filter(None, map(grammar_rule_re.match, f)))