1{
2 lib,
3 fetchPypi,
4 buildPythonPackage,
5 fetchpatch,
6 isPyPy,
7 python,
8
9 # build-system
10 meson,
11 meson-python,
12 pkg-config,
13
14 # native dependencies
15 dbus,
16 dbus-glib,
17}:
18
19lib.fix (
20 finalPackage:
21 buildPythonPackage rec {
22 pname = "dbus-python";
23 version = "1.3.2";
24 pyproject = true;
25
26 disabled = isPyPy;
27
28 outputs = [
29 "out"
30 "dev"
31 ];
32
33 src = fetchPypi {
34 inherit pname version;
35 hash = "sha256-rWeBkwhhi1BpU3viN/jmjKHH/Mle5KEh/mhFsUGCSPg=";
36 };
37
38 patches = [
39 # reduce required dependencies
40 # https://gitlab.freedesktop.org/dbus/dbus-python/-/merge_requests/23
41 (fetchpatch {
42 url = "https://gitlab.freedesktop.org/dbus/dbus-python/-/commit/d5e19698a8d6e1485f05b67a5b2daa2392819aaf.patch";
43 hash = "sha256-Rmj/ByRLiLnIF3JsMBElJugxsG8IARcBdixLhoWgIYU=";
44 })
45 ];
46
47 postPatch = ''
48 # we provide patchelf natively, not through the python package
49 sed -i '/patchelf/d' pyproject.toml
50
51 # dont run autotols configure phase
52 rm configure.ac configure
53
54 patchShebangs test/*.sh
55 '';
56
57 nativeBuildInputs = [
58 dbus # build systems checks for `dbus-run-session` in PATH
59 meson
60 meson-python
61 pkg-config
62 ];
63
64 buildInputs = [
65 dbus
66 dbus-glib
67 ];
68
69 pypaBuildFlags = [
70 # Don't discard meson build directory, still needed for tests!
71 "-Cbuild-dir=_meson-build"
72 ];
73
74 mesonFlags = [ (lib.mesonBool "tests" finalPackage.doInstallCheck) ];
75
76 # workaround bug in meson-python
77 # https://github.com/mesonbuild/meson-python/issues/240
78 postInstall = ''
79 mkdir -p $dev/lib
80 mv $out/${python.sitePackages}/.dbus_python.mesonpy.libs/pkgconfig/ $dev/lib
81 '';
82
83 # make sure the Cflags in the pkgconfig file are correct and make the structure backwards compatible
84 postFixup = ''
85 ln -s $dev/include/*/dbus_python/dbus-1.0/ $dev/include/dbus-1.0
86 '';
87
88 nativeCheckInputs = [ dbus.out ];
89
90 checkPhase = ''
91 runHook preCheck
92
93 meson test -C _meson-build --no-rebuild --print-errorlogs
94
95 runHook postCheck
96 '';
97
98 meta = with lib; {
99 description = "Python DBus bindings";
100 homepage = "https://gitlab.freedesktop.org/dbus/dbus-python";
101 license = licenses.mit;
102 platforms = dbus.meta.platforms;
103 maintainers = [ ];
104 };
105 }
106)