diff --git a/setup.py b/setup.py index 6f73295..25f4b61 100644 --- a/setup.py +++ b/setup.py @@ -21,6 +21,7 @@ 'jsonschema<=4.9.1', # c.f. https://github.com/yadage/yadage-schemas/issues/38 'click', 'six>=1.4.0', # six.moves added in six v1.4.0 + 'importlib-resources>=5.10;python_version<"3.9"' # for accessing package filepaths ], extras_require = { 'develop': [ diff --git a/yadageschemas/__init__.py b/yadageschemas/__init__.py index 7d1b013..eb4ec64 100644 --- a/yadageschemas/__init__.py +++ b/yadageschemas/__init__.py @@ -1,12 +1,20 @@ import json -import pkg_resources -schemadir = pkg_resources.resource_filename('yadageschemas','') +try: + from importlib.resources import files +except ImportError: + # Support Python 3.8 as importlib.resources added in Python 3.9 + # https://docs.python.org/3/library/importlib.resources.html#importlib.resources.files + from importlib_resources import files + +# FIXME: Import order must be before yadageschemas.utils to avoid circular import +schemadir = files("yadageschemas") -from .utils import WithJsonRefEncoder from . import dialects +from .utils import WithJsonRefEncoder from .validator import validate_spec + def load(spec, specopts, validate = True, validopts = None, dialect = 'raw_with_defaults'): data = dialects.handlers[dialect](spec, specopts) if validate: