1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 cacert,
6 cached-property,
7 cffi,
8 fetchPypi,
9 isPyPy,
10 libgit2,
11 pycparser,
12 pytestCheckHook,
13 pythonOlder,
14 setuptools,
15}:
16
17buildPythonPackage rec {
18 pname = "pygit2";
19 version = "1.17.0";
20 pyproject = true;
21
22 disabled = pythonOlder "3.9";
23
24 src = fetchPypi {
25 inherit pname version;
26 hash = "sha256-+ivAULLC0+c7VNbVQceSF4Vho0TwfkCfUy1buXrHuJQ=";
27 };
28
29 preConfigure = lib.optionalString stdenv.hostPlatform.isDarwin ''
30 export DYLD_LIBRARY_PATH="${libgit2}/lib"
31 '';
32
33 build-system = [ setuptools ];
34
35 buildInputs = [ libgit2 ];
36
37 dependencies = [
38 cached-property
39 pycparser
40 ] ++ lib.optionals (!isPyPy) [ cffi ];
41
42 propagatedNativeBuildInputs = lib.optionals (!isPyPy) [ cffi ];
43
44 nativeCheckInputs = [ pytestCheckHook ];
45
46 disabledTestPaths = [
47 # Disable tests that require networking
48 "test/test_repository.py"
49 "test/test_credentials.py"
50 "test/test_submodule.py"
51 ];
52
53 # Tests require certificates
54 # https://github.com/NixOS/nixpkgs/pull/72544#issuecomment-582674047
55 SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt";
56
57 pythonImportsCheck = [ "pygit2" ];
58
59 meta = with lib; {
60 description = "Set of Python bindings to the libgit2 shared library";
61 homepage = "https://github.com/libgit2/pygit2";
62 changelog = "https://github.com/libgit2/pygit2/blob/v${version}/CHANGELOG.md";
63 license = licenses.gpl2Only;
64 maintainers = [ ];
65 };
66}