summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/dbus-python/default.nix
blob: 12f0246f840126048595722d2e5d493090761a68 (about) (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
{
  lib,
  fetchPypi,
  buildPythonPackage,
  fetchpatch,
  isPyPy,
  python,

  # build-system
  meson,
  meson-python,
  pkg-config,

  # native dependencies
  dbus,
  dbus-glib,
}:

lib.fix (
  finalPackage:
  buildPythonPackage rec {
    pname = "dbus-python";
    version = "1.4.0";
    pyproject = true;

    disabled = isPyPy;

    outputs = [
      "out"
      "dev"
    ];

    src = fetchPypi {
      inherit pname version;
      hash = "sha256-mRZm5Jj2Db8+Sbi3Z49VWbimUDT99hquYs3s232Jx3A=";
    };

    patches = [
      # reduce required dependencies
      # https://gitlab.freedesktop.org/dbus/dbus-python/-/merge_requests/23
      (fetchpatch {
        url = "https://gitlab.freedesktop.org/dbus/dbus-python/-/commit/d5e19698a8d6e1485f05b67a5b2daa2392819aaf.patch";
        hash = "sha256-Rmj/ByRLiLnIF3JsMBElJugxsG8IARcBdixLhoWgIYU=";
      })
    ];

    postPatch = ''
      # we provide patchelf natively, not through the python package
      sed -i '/patchelf/d' pyproject.toml

      patchShebangs test/*.sh
    '';

    nativeBuildInputs = [
      dbus # build systems checks for `dbus-run-session` in PATH
      meson
      meson-python
      pkg-config
    ];

    buildInputs = [
      dbus
      dbus-glib
    ];

    pypaBuildFlags = [
      # Don't discard meson build directory, still needed for tests!
      "-Cbuild-dir=_meson-build"
    ];

    mesonFlags = [ (lib.mesonBool "tests" finalPackage.doInstallCheck) ];

    # workaround bug in meson-python
    # https://github.com/mesonbuild/meson-python/issues/240
    postInstall = ''
      mkdir -p $dev/lib
      mv $out/${python.sitePackages}/.dbus_python.mesonpy.libs/pkgconfig/ $dev/lib
    '';

    # make sure the Cflags in the pkgconfig file are correct and make the structure backwards compatible
    postFixup = ''
      ln -s $dev/include/*/dbus_python/dbus-1.0/ $dev/include/dbus-1.0
    '';

    nativeCheckInputs = [ dbus.out ];

    checkPhase = ''
      runHook preCheck

      meson test -C _meson-build --no-rebuild --print-errorlogs --timeout-multiplier 0

      runHook postCheck
    '';

    meta = with lib; {
      description = "Python DBus bindings";
      homepage = "https://gitlab.freedesktop.org/dbus/dbus-python";
      license = licenses.mit;
      platforms = dbus.meta.platforms;
      maintainers = [ ];
    };
  }
)