Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use importlib-resources over deprecated pkg_resources #51

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': [
Expand Down
14 changes: 11 additions & 3 deletions yadageschemas/__init__.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Loading