diff --git a/jsonschema/_utils.py b/jsonschema/_utils.py index 620dab4c8..6c2f70ff5 100644 --- a/jsonschema/_utils.py +++ b/jsonschema/_utils.py @@ -1,7 +1,8 @@ import itertools import json import re -import os + +import pkg_resources from jsonschema.compat import str_types, MutableMapping, urlsplit @@ -50,14 +51,12 @@ def __repr__(self): def load_schema(name): """ - Load a schema from ./schemas/``name``.json and return it. - + Load a schema from jsonschema.schemas.``name``.json and + return it. """ - - schema_dir = os.path.join( - os.path.dirname(os.path.abspath(__file__)), "schemas", - ) - with open(os.path.join(schema_dir, name + ".json")) as schema_file: + fname = pkg_resources.resource_filename('jsonschema', + "schemas/" + name + ".json") + with open(fname) as schema_file: return json.load(schema_file) diff --git a/jsonschema/schemas/__init__.py b/jsonschema/schemas/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/setup.py b/setup.py index 5f38d6e79..3927dbe2d 100644 --- a/setup.py +++ b/setup.py @@ -27,8 +27,8 @@ setup( name="jsonschema", version=__version__, - packages=["jsonschema", "jsonschema.tests"], - package_data={"jsonschema": ["schemas/*.json"]}, + packages=["jsonschema", "jsonschema.tests", "jsonschema.schemas"], + package_data={"jsonschema.schemas": ["*.json"]}, author="Julian Berman", author_email="Julian@GrayVines.com", classifiers=classifiers,