1From 944d5467e1655aac20a14325631df6daccaf5804 Mon Sep 17 00:00:00 2001
2From: Jan Tojnar <jtojnar@gmail.com>
3Date: Sun, 3 Mar 2019 01:13:46 +0100
4Subject: [PATCH] Fix building on Nix
5
6./configure.py tries to find dbus-python header in dbus-1 includedir
7obtained from pkg-config or from --dbus flag. Unfortunately, when supplied,
8it also uses the flag for locating dbus-1 headers. This fails on Nix,
9since every package is installed into its own immutable tree so we cannot
10use a single directory for both dbus-python and dbus-1. We can fix this by
11using pkg-config for finding dbus-python headers too.
12
13Additionally, the build system also tries to install the dbus support module
14to dbus-python tree. Often, it is possible to handle this in pkgconfig as well [1]
15but unfortunately, dbus-python does not export the moduledir in its pc file
16so I have decided to solve this with an extra configure flag.
17
18[1]: https://www.bassi.io/articles/2018/03/15/pkg-config-and-paths/
19---
20 configure.py | 13 +++++++++++--
21 1 file changed, 11 insertions(+), 2 deletions(-)
22
23diff --git a/configure.py b/configure.py
24index c6663e4..65e7da7 100644
25--- a/configure.py
26+++ b/configure.py
27@@ -905,6 +905,9 @@ class TargetConfiguration:
28 if opts.pydbusincdir is not None:
29 self.pydbus_inc_dir = opts.pydbusincdir
30
31+ if opts.pydbusmoduledir is not None:
32+ self.pydbus_module_dir = opts.pydbusmoduledir
33+
34 if opts.pyuicinterpreter is not None:
35 self.pyuic_interpreter = opts.pyuicinterpreter
36
37@@ -1191,6 +1194,11 @@ def create_optparser(target_config):
38 metavar="DIR",
39 help="the directory containing the dbus/dbus-python.h header is "
40 "DIR [default: supplied by pkg-config]")
41+ g.add_option("--dbus-moduledir", dest='pydbusmoduledir', type='string',
42+ default=None, action='callback', callback=store_abspath,
43+ metavar="DIR",
44+ help="the directory where dbus support module will be installed to"
45+ "DIR [default: obtained from dbus.mainloop python module]")
46 p.add_option_group(g)
47
48 # Installation.
49@@ -2277,7 +2285,7 @@ def check_dbus(target_config, verbose):
50
51 inform("Checking to see if the dbus support module should be built...")
52
53- cmd = 'pkg-config --cflags-only-I --libs dbus-1'
54+ cmd = 'pkg-config --cflags-only-I --libs dbus-1 dbus-python'
55
56 if verbose:
57 sys.stdout.write(cmd + "\n")
58@@ -2307,7 +2315,8 @@ def check_dbus(target_config, verbose):
59 inform("The Python dbus module doesn't seem to be installed.")
60 return
61
62- target_config.pydbus_module_dir = dbus.mainloop.__path__[0]
63+ if target_config.pydbus_module_dir == '':
64+ target_config.pydbus_module_dir = dbus.mainloop.__path__[0]
65
66 # Try and find dbus-python.h. We don't use pkg-config because it is broken
67 # for dbus-python (at least for versions up to and including v0.81.0).
68diff --git a/project.py b/project.py
69index fe9fbce..9ae1ca1 100644
70--- a/project.py
71+++ b/project.py
72@@ -261,7 +261,7 @@ del find_qt
73 dbus_lib_dirs = []
74 dbus_libs = []
75
76- args = ['pkg-config', '--cflags-only-I', '--libs dbus-1']
77+ args = ['pkg-config', '--cflags-only-I', '--libs dbus-1', 'dbus-python']
78
79 for line in self.read_command_pipe(args, fatal=False):
80 for flag in line.strip().split():