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.4.0";
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-mRZm5Jj2Db8+Sbi3Z49VWbimUDT99hquYs3s232Jx3A=";
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 patchShebangs test/*.sh
52 '';
53
54 nativeBuildInputs = [
55 dbus # build systems checks for `dbus-run-session` in PATH
56 meson
57 meson-python
58 pkg-config
59 ];
60
61 buildInputs = [
62 dbus
63 dbus-glib
64 ];
65
66 pypaBuildFlags = [
67 # Don't discard meson build directory, still needed for tests!
68 "-Cbuild-dir=_meson-build"
69 ];
70
71 mesonFlags = [ (lib.mesonBool "tests" finalPackage.doInstallCheck) ];
72
73 # workaround bug in meson-python
74 # https://github.com/mesonbuild/meson-python/issues/240
75 postInstall = ''
76 mkdir -p $dev/lib
77 mv $out/${python.sitePackages}/.dbus_python.mesonpy.libs/pkgconfig/ $dev/lib
78 '';
79
80 # make sure the Cflags in the pkgconfig file are correct and make the structure backwards compatible
81 postFixup = ''
82 ln -s $dev/include/*/dbus_python/dbus-1.0/ $dev/include/dbus-1.0
83 '';
84
85 nativeCheckInputs = [ dbus.out ];
86
87 checkPhase = ''
88 runHook preCheck
89
90 meson test -C _meson-build --no-rebuild --print-errorlogs --timeout-multiplier 0
91
92 runHook postCheck
93 '';
94
95 meta = with lib; {
96 description = "Python DBus bindings";
97 homepage = "https://gitlab.freedesktop.org/dbus/dbus-python";
98 license = licenses.mit;
99 platforms = dbus.meta.platforms;
100 maintainers = [ ];
101 };
102 }
103)