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