nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 buildPythonPackage,
4 replaceVars,
5 fetchFromGitHub,
6 setuptools,
7 wheel,
8 capnproto,
9 cython,
10 pkgconfig,
11 pytest-asyncio,
12 pytestCheckHook,
13}:
14
15buildPythonPackage rec {
16 pname = "pycapnp";
17 version = "2.2.2";
18 pyproject = true;
19
20 src = fetchFromGitHub {
21 owner = "capnproto";
22 repo = "pycapnp";
23 tag = "v${version}";
24 hash = "sha256-oRgO/FuNxNMSUla+jIypD/dAvFi27TkEfCHbqovhq9I=";
25 };
26
27 patches = [
28 # pycapnp hardcodes /usr/include and /usr/local/include as the paths to search
29 # for capnproto's built-in schemas in; replace them with the path to our copy of
30 # capnproto.
31 #
32 # Theoretically, this mechanism could also be used to load capnproto schemas
33 # exposed by other packages (e.g. capnproto-java), which we could support using
34 # a setup hook; but in practice nobody seems to use this mechanism for anything
35 # other than the builtin schemas (based on quick GitHub code search), so I don't
36 # think it's worthwhile.
37 (replaceVars ./include-paths.patch { inherit capnproto; })
38 ];
39
40 build-system = [
41 setuptools
42 wheel
43 cython
44 pkgconfig
45 ];
46
47 buildInputs = [ capnproto ];
48
49 nativeCheckInputs = [
50 pytest-asyncio
51 pytestCheckHook
52 ];
53 __darwinAllowLocalNetworking = true;
54 # https://github.com/NixOS/nixpkgs/issues/255262
55 preCheck = ''
56 enabledTestPaths=$PWD/test
57 pushd "$out"
58 '';
59 postCheck = ''
60 popd
61 '';
62
63 meta = {
64 description = "Cython wrapping of the C++ Cap'n Proto library";
65 homepage = "https://capnproto.github.io/pycapnp/";
66 changelog = "https://github.com/capnproto/pycapnp/blob/${src.tag}/CHANGELOG.md";
67 license = lib.licenses.bsd2;
68 maintainers = with lib.maintainers; [ Liamolucko ];
69 };
70}