about summary refs log tree commit diff
path: root/pkgs/development/python-modules/sigrok/default.nix
blob: 40253c5ad19c70d9588a7df78405abb05f515707 (plain) (blame)
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
{
  lib,
  stdenv,
  libsigrok,
  toPythonModule,
  python,
  autoreconfHook,
  pythonImportsCheckHook,
  pythonCatchConflictsHook,
  swig,
  setuptools,
  numpy,
  pygobject3,
}:

# build libsigrok plus its Python bindings. Unfortunately it does not appear
# to be possible to build them separately, at least not easily.
toPythonModule (
  (libsigrok.override { inherit python; }).overrideAttrs (orig: {
    pname = "${python.libPrefix}-sigrok";

    patches = orig.patches or [ ] ++ [
      # Makes libsigrok install the bindings into site-packages properly (like
      # we expect) instead of making a version-specific *.egg subdirectory.
      ./python-install.patch
    ];

    nativeBuildInputs =
      orig.nativeBuildInputs or [ ]
      ++ [
        autoreconfHook
        setuptools
        swig
        numpy
      ]
      ++ lib.optionals (stdenv.hostPlatform == stdenv.buildPlatform) [
        pythonImportsCheckHook
        pythonCatchConflictsHook
      ];

    buildInputs = orig.buildInputs or [ ] ++ [
      pygobject3 # makes headers available the configure script checks for
    ];

    propagatedBuildInputs = orig.propagatedBuildInputs or [ ] ++ [
      pygobject3
      numpy
    ];

    postInstall = ''
      ${orig.postInstall or ""}

      # for pythonImportsCheck
      export PYTHONPATH="$out/${python.sitePackages}:$PYTHONPATH"
    '';

    pythonImportsCheck = [
      "sigrok"
      "sigrok.core"
    ];

    meta = orig.meta // {
      description = "Python bindings for libsigrok";
      maintainers = orig.meta.maintainers ++ [ lib.maintainers.sternenseemann ];
    };
  })
)