aboutsummaryrefslogtreecommitdiff
path: root/recipes-extended/libvirt/libvirt/libvirt_api_xml_path.patch
blob: 0aa3bde221decde2dab393a2f1ce85e009b02e37 (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
Adding support for LIBVIRT_CFLAGS and LIBVIRT_LIBS

Signed-off-by: Amy Fong <amy.fong@windriver.com>


Adding a support for LIBVIRT_API_PATH evironment variable, which can
control where the script should look for the 'libvirt-api.xml' file.
This allows building libvirt-python against different libvirt than the
one installed in the system.  This may be used for example in autotest
or by packagers without the need to install libvirt into the system.

Signed-off-by: Martin Kletzander <mkletzan redhat com>
---
 setup.py |   25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

Index: libvirt-python-1.2.1/setup.py
===================================================================
--- libvirt-python-1.2.1.orig/setup.py
+++ libvirt-python-1.2.1/setup.py
@@ -30,18 +30,19 @@
 if pkgcfg is None:
     raise Exception("pkg-config binary is required to compile libvirt-python")
 
-spawn([pkgcfg,
-       "--print-errors",
-       "--atleast-version=%s" % MIN_LIBVIRT,
-       "libvirt"])
+# spawn([pkgcfg,
+#        "--print-errors",
+#        "--atleast-version=%s" % MIN_LIBVIRT,
+#        "libvirt"])
 
 have_libvirt_lxc=True
-try:
-    spawn([pkgcfg,
-           "--atleast-version=%s" % MIN_LIBVIRT_LXC,
-         "libvirt"])
-except DistutilsExecError:
-    have_libvirt_lxc=False
+# try:
+#     spawn([pkgcfg,
+#            "--atleast-version=%s" % MIN_LIBVIRT_LXC,
+#          "libvirt"])
+# except DistutilsExecError:
+#     have_libvirt_lxc=False
+have_libvirt_lxc=True
 
 def get_pkgconfig_data(args, mod, required=True):
     """Run pkg-config to and return content associated with it"""
@@ -63,7 +64,17 @@
     """Check with pkg-config that libvirt is present and extract
     the API XML file paths we need from it"""
 
-    libvirt_api = get_pkgconfig_data(["--variable", "libvirt_api"], "libvirt")
+    libvirt_api = os.getenv("LIBVIRT_API_PATH")
+
+    if libvirt_api:
+        if not libvirt_api.endswith("-api.xml"):
+            raise ValueError("Invalid path '%s' for API XML" % libvirt_api)
+        if not os.path.exists(libvirt_api):
+            raise ValueError("API XML '%s' does not exist, "
+                             "have you built libvirt?" % libvirt_api)
+    else:
+        libvirt_api = get_pkgconfig_data(["--variable", "libvirt_api"],
+                                         "libvirt")
 
     offset = libvirt_api.index("-api.xml")
     libvirt_qemu_api = libvirt_api[0:offset] + "-qemu-api.xml"
@@ -73,8 +84,17 @@
 
     return (libvirt_api, libvirt_qemu_api, libvirt_lxc_api)
 
-ldflags = get_pkgconfig_data(["--libs-only-L"], "libvirt", False)
-cflags = get_pkgconfig_data(["--cflags"], "libvirt", False)
+libvirt_cflags = os.getenv("LIBVIRT_CFLAGS")
+if libvirt_cflags:
+    cflags = libvirt_cflags
+else:
+    cflags = get_pkgconfig_data(["--cflags"], "libvirt", False)
+
+libvirt_libs = os.getenv("LIBVIRT_LIBS")
+if libvirt_libs:
+    ldflags = libvirt_libs
+else:
+    ldflags = get_pkgconfig_data(["--libs-only-L"], "libvirt", False)
 
 c_modules = []
 py_modules = []