1{ stdenv, lib, buildPythonPackage, fetchPypi, isPyPy, isPy3k, libgit2, cached-property, pytestCheckHook, cffi, cacert }:
2
3buildPythonPackage rec {
4 pname = "pygit2";
5 version = "1.7.0";
6
7 src = fetchPypi {
8 inherit pname version;
9 sha256 = "602bffa8b4dbc185a6c7f36515563b600e0ee9002583c97ae3150eedaf340edb";
10 };
11
12 preConfigure = lib.optionalString stdenv.isDarwin ''
13 export DYLD_LIBRARY_PATH="${libgit2}/lib"
14 '';
15
16 buildInputs = [
17 libgit2
18 ];
19
20 propagatedBuildInputs = [
21 cached-property
22 ] ++ lib.optional (!isPyPy) cffi;
23
24 propagatedNativeBuildInputs = lib.optional (!isPyPy) cffi;
25
26 checkInputs = [ pytestCheckHook ];
27
28 preCheck = ''
29 # disable tests that require networking
30 rm test/test_repository.py
31 rm test/test_credentials.py
32 rm test/test_submodule.py
33 '';
34
35 # Tests require certificates
36 # https://github.com/NixOS/nixpkgs/pull/72544#issuecomment-582674047
37 SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt";
38
39 # setup.py check is broken
40 # https://github.com/libgit2/pygit2/issues/868
41 dontUseSetuptoolsCheck = true;
42
43 # TODO: Test collection is failing
44 # https://github.com/NixOS/nixpkgs/pull/72544#issuecomment-582681068
45 doCheck = false;
46
47 disabled = !isPy3k;
48
49 meta = with lib; {
50 description = "A set of Python bindings to the libgit2 shared library";
51 homepage = "https://pypi.python.org/pypi/pygit2";
52 license = licenses.gpl2;
53 };
54}