1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 python,
6 requests,
7}:
8
9let
10
11 json-ld = fetchFromGitHub {
12 owner = "json-ld";
13 repo = "json-ld.org";
14 rev = "843a70e4523d7cd2a4d3f5325586e726eb1b123f";
15 sha256 = "05j0nq6vafclyypxjj30iw898ig0m32nvz0rjdlslx6lawkiwb2a";
16 };
17
18 normalization = fetchFromGitHub {
19 owner = "json-ld";
20 repo = "normalization";
21 rev = "aceeaf224b64d6880189d795bd99c3ffadb5d79e";
22 sha256 = "125q5rllfm8vg9mz8hn7bhvhv2vqpd86kx2kxlk84smh33l8kbyl";
23 };
24in
25
26buildPythonPackage rec {
27 pname = "pyld";
28 version = "1.0.5";
29 format = "setuptools";
30
31 src = fetchFromGitHub {
32 owner = "digitalbazaar";
33 repo = "pyld";
34 rev = version;
35 sha256 = "0z2vkllw8bvzxripwb6l757r7av5qwhzsiy4061gmlhq8z8gq961";
36 };
37
38 propagatedBuildInputs = [ requests ];
39
40 # Unfortunately PyLD does not pass all testcases in the JSON-LD corpus. We
41 # check for at least a minimum amount of successful tests so we know it's not
42 # getting worse, at least.
43 checkPhase = ''
44 ok_min=401
45
46 if ! ${python.interpreter} tests/runtests.py -d ${json-ld}/test-suite 2>&1 | tee test.out; then
47 ok_count=$(grep -F '... ok' test.out | wc -l)
48 if [[ $ok_count -lt $ok_min ]]; then
49 echo "Less than $ok_min tests passed ($ok_count). Failing the build."
50 exit 1
51 fi
52 fi
53
54 ${python.interpreter} tests/runtests.py -d ${normalization}/tests
55 '';
56
57 meta = with lib; {
58 description = "Python implementation of the JSON-LD API";
59 homepage = "https://github.com/digitalbazaar/pyld";
60 license = licenses.bsd3;
61 maintainers = with maintainers; [ apeschar ];
62 };
63}