Skip to content

Commit 83e810c

Browse files
committed
Load meta-schemas via pkgutil rather than searching the filesystem.
Hopefully this makes things like cx_Freeze work, but they appear to all be special snowflakes and this doesn't appear easy to test. Credit to @pjdelport for helping clear away some of the smoke. Closes #161, #162
1 parent 6f071cc commit 83e810c

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

jsonschema/_utils.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import itertools
22
import json
3+
import pkgutil
34
import re
4-
import os
55

66
from jsonschema.compat import str_types, MutableMapping, urlsplit
77

@@ -54,11 +54,8 @@ def load_schema(name):
5454
5555
"""
5656

57-
schema_dir = os.path.join(
58-
os.path.dirname(os.path.abspath(__file__)), "schemas",
59-
)
60-
with open(os.path.join(schema_dir, name + ".json")) as schema_file:
61-
return json.load(schema_file)
57+
data = pkgutil.get_data(__package__, "schemas/{0}.json".format(name))
58+
return json.loads(data.decode("utf-8"))
6259

6360

6461
def indent(string, times=1):

0 commit comments

Comments
 (0)