summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/pycapnp/default.nix
blob: d0d460762cb9d0da3683ecb13f82ae022ae20698 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
{
  lib,
  buildPythonPackage,
  replaceVars,
  fetchFromGitHub,
  fetchpatch2,
  setuptools,
  wheel,
  capnproto,
  cython,
  pkgconfig,
  pytest-asyncio,
  pytestCheckHook,
}:

buildPythonPackage rec {
  pname = "pycapnp";
  version = "2.0.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "capnproto";
    repo = "pycapnp";
    tag = "v${version}";
    hash = "sha256-SVeBRJMMR1Z8+S+QoiUKGRFGUPS/MlmWLi1qRcGcPoE=";
  };

  patches = [
    # pycapnp hardcodes /usr/include and /usr/local/include as the paths to search
    # for capnproto's built-in schemas in; replace them with the path to our copy of
    # capnproto.
    #
    # Theoretically, this mechanism could also be used to load capnproto schemas
    # exposed by other packages (e.g. capnproto-java), which we could support using
    # a setup hook; but in practice nobody seems to use this mechanism for anything
    # other than the builtin schemas (based on quick GitHub code search), so I don't
    # think it's worthwhile.
    (replaceVars ./include-paths.patch { inherit capnproto; })
    (fetchpatch2 {
      name = "cython-3.patch";
      url = "https://github.com/capnproto/pycapnp/pull/334.diff?full_index=1";
      hash = "sha256-we7v4RaL7c1tePWl+oYfzMHAfnvnpdMkQgVu9YLwC6Y=";
    })
  ];

  build-system = [
    setuptools
    wheel
    cython
    pkgconfig
  ];

  buildInputs = [ capnproto ];

  nativeCheckInputs = [
    pytest-asyncio
    pytestCheckHook
  ];
  __darwinAllowLocalNetworking = true;
  # https://github.com/NixOS/nixpkgs/issues/255262
  preCheck = ''
    enabledTestPaths=$PWD/test
    pushd "$out"
  '';
  postCheck = ''
    popd
  '';

  meta = {
    description = "Cython wrapping of the C++ Cap'n Proto library";
    homepage = "https://capnproto.github.io/pycapnp/";
    changelog = "https://github.com/capnproto/pycapnp/blob/${src.rev}/CHANGELOG.md";
    license = lib.licenses.bsd2;
    maintainers = with lib.maintainers; [ Liamolucko ];
  };
}