1{ lib
2, attrs
3, buildPythonPackage
4, fetchPypi
5, hatch-fancy-pypi-readme
6, hatch-vcs
7, hatchling
8, importlib-metadata
9, importlib-resources
10, pyrsistent
11, pythonOlder
12, twisted
13, typing-extensions
14
15# optionals
16, fqdn
17, idna
18, isoduration
19, jsonpointer
20, rfc3339-validator
21, rfc3986-validator
22, rfc3987
23, uri-template
24, webcolors
25}:
26
27buildPythonPackage rec {
28 pname = "jsonschema";
29 version = "4.17.3";
30 format = "pyproject";
31
32 disabled = pythonOlder "3.7";
33
34 src = fetchPypi {
35 inherit pname version;
36 hash = "sha256-D4ZEN6uLYHa6ZwdFPvj5imoNUSqA6T+KvbZ29zfstg0=";
37 };
38
39 postPatch = ''
40 patchShebangs json/bin/jsonschema_suite
41 '';
42
43 nativeBuildInputs = [
44 hatch-fancy-pypi-readme
45 hatch-vcs
46 hatchling
47 ];
48
49 propagatedBuildInputs = [
50 attrs
51 pyrsistent
52 ] ++ lib.optionals (pythonOlder "3.8") [
53 importlib-metadata
54 typing-extensions
55 ] ++ lib.optionals (pythonOlder "3.9") [
56 importlib-resources
57 ];
58
59 passthru.optional-dependencies = {
60 format = [
61 fqdn
62 idna
63 isoduration
64 jsonpointer
65 rfc3339-validator
66 rfc3987
67 uri-template
68 webcolors
69 ];
70 format-nongpl = [
71 fqdn
72 idna
73 isoduration
74 jsonpointer
75 rfc3339-validator
76 rfc3986-validator
77 uri-template
78 webcolors
79 ];
80 };
81
82 nativeCheckInputs = [
83 twisted
84 ];
85
86 checkPhase = ''
87 export JSON_SCHEMA_TEST_SUITE=json
88 trial jsonschema
89 '';
90
91 pythonImportsCheck = [
92 "jsonschema"
93 ];
94
95 meta = with lib; {
96 description = "An implementation of JSON Schema validation for Python";
97 homepage = "https://github.com/python-jsonschema/jsonschema";
98 license = licenses.mit;
99 maintainers = with maintainers; [ domenkozar ];
100 };
101}