[libvirt] Fix missing python binding constants

Daniel P. Berrange berrange at fedoraproject.org
Tue Feb 5 15:52:01 UTC 2013


commit 803b3b891ac5112b06ac9c2be8bbaf425373b101
Author: Daniel P. Berrange <berrange at redhat.com>
Date:   Tue Feb 5 15:45:45 2013 +0000

    Fix missing python binding constants

 ...-error-constants-in-libvirt-python-module.patch |   98 ++++++++++++++++++++
 libvirt.spec                                       |    7 +-
 2 files changed, 104 insertions(+), 1 deletions(-)
---
diff --git a/0001-Fix-missing-error-constants-in-libvirt-python-module.patch b/0001-Fix-missing-error-constants-in-libvirt-python-module.patch
new file mode 100644
index 0000000..b9afb51
--- /dev/null
+++ b/0001-Fix-missing-error-constants-in-libvirt-python-module.patch
@@ -0,0 +1,98 @@
+From 25ea8e47e74def560bf89cd94dd54b75ca5ff4d6 Mon Sep 17 00:00:00 2001
+From: "Daniel P. Berrange" <berrange at redhat.com>
+Date: Tue, 5 Feb 2013 12:55:09 +0000
+Subject: [PATCH] Fix missing error constants in libvirt python module
+
+The previous change to the generator, changed too much - only
+the functions are in 'virerror.c', the constants remained in
+'virerror.h' which could not be renamed for API compat reasons.
+
+Add a test case to sanity check the generated python bindings
+
+Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
+---
+ python/Makefile.am   |  5 +++++
+ python/generator.py  |  4 +++-
+ python/sanitytest.py | 31 +++++++++++++++++++++++++++++++
+ 3 files changed, 39 insertions(+), 1 deletion(-)
+ create mode 100644 python/sanitytest.py
+
+diff --git a/python/Makefile.am b/python/Makefile.am
+index dd69600..ef3c3eb 100644
+--- a/python/Makefile.am
++++ b/python/Makefile.am
+@@ -119,6 +119,11 @@ $(libvirtmod_la_OBJECTS): $(GENERATED)
+ $(libvirtmod_qemu_la_OBJECTS): $(QEMU_GENERATED)
+ $(libvirtmod_lxc_la_OBJECTS): $(LXC_GENERATED)
+ 
++EXTRA_DIST += sanitytest.py
++
++check-local:
++	$(AM_V_GEN)PYTHONPATH=$(abs_topbuilddir):$(abs_topbuilddir)/.libs $(PYTHON) $(srcdir)/sanitytest.py
++
+ install-data-local:
+ 	$(mkinstalldirs) $(DESTDIR)$(pyexecdir)
+ 	$(INSTALL) -m 0644 libvirt.py $(DESTDIR)$(pyexecdir)
+diff --git a/python/generator.py b/python/generator.py
+index 71ca883..ceade6b 100755
+--- a/python/generator.py
++++ b/python/generator.py
+@@ -122,8 +122,9 @@ class docParser(xml.sax.handler.ContentHandler):
+                 if attrs.has_key('field'):
+                     self.function_return_field = attrs['field']
+         elif tag == 'enum':
++            # enums come from header files, hence virterror.h
+             if (attrs['file'] == "libvirt" or
+-                attrs['file'] == "virerror"):
++                attrs['file'] == "virterror"):
+                 enum(attrs['type'],attrs['name'],attrs['value'])
+             elif attrs['file'] == "libvirt-lxc":
+                 lxc_enum(attrs['type'],attrs['name'],attrs['value'])
+@@ -134,6 +135,7 @@ class docParser(xml.sax.handler.ContentHandler):
+         if debug:
+             print "end %s" % tag
+         if tag == 'function':
++            # fuctions come from source files, hence 'virerror.c'
+             if self.function != None:
+                 if (self.function_module == "libvirt" or
+                     self.function_module == "virevent" or
+diff --git a/python/sanitytest.py b/python/sanitytest.py
+new file mode 100644
+index 0000000..047450b
+--- /dev/null
++++ b/python/sanitytest.py
+@@ -0,0 +1,31 @@
++#!/usr/bin/python
++
++import libvirt
++
++globals = dir(libvirt)
++
++# Sanity test that the generator hasn't gone wrong
++
++# Look for core classes
++assert("virConnect" in globals)
++assert("virDomain" in globals)
++assert("virDomainSnapshot" in globals)
++assert("virInterface" in globals)
++assert("virNWFilter" in globals)
++assert("virNodeDevice" in globals)
++assert("virNetwork" in globals)
++assert("virSecret" in globals)
++assert("virStoragePool" in globals)
++assert("virStorageVol" in globals)
++assert("virStream" in globals)
++assert("VIR_CONNECT_RO" in globals)
++
++# Error related bits
++assert("libvirtError" in globals)
++assert("VIR_ERR_AUTH_FAILED" in globals)
++assert("virGetLastError" in globals)
++
++# Some misc methods
++assert("virInitialize" in globals)
++assert("virEventAddHandle" in globals)
++assert("virEventRegisterDefaultImpl" in globals)
+-- 
+1.7.11.7
+
diff --git a/libvirt.spec b/libvirt.spec
index 952d8bc..2b0a0f7 100644
--- a/libvirt.spec
+++ b/libvirt.spec
@@ -341,7 +341,7 @@
 Summary: Library providing a simple virtualization API
 Name: libvirt
 Version: 1.0.2
-Release: 1%{?dist}%{?extra_release}
+Release: 2%{?dist}%{?extra_release}
 License: LGPLv2+
 Group: Development/Libraries
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
@@ -352,6 +352,7 @@ URL: http://libvirt.org/
 %endif
 Source: http://libvirt.org/sources/%{?mainturl}libvirt-%{version}.tar.gz
 Patch1: 0001-complete-virterror-virerror-name-change.patch
+Patch2: 0001-Fix-missing-error-constants-in-libvirt-python-module.patch
 
 %if %{with_libvirtd}
 Requires: libvirt-daemon = %{version}-%{release}
@@ -1080,6 +1081,7 @@ of recent versions of Linux (and other OSes).
 %prep
 %setup -q
 %patch1 -p1
+%patch2 -p1
 
 %build
 %if ! %{with_xen}
@@ -1996,6 +1998,9 @@ fi
 %endif
 
 %changelog
+* Tue Feb  5 2013 Daniel P. Berrange <berrange at redhat.com> - 1.0.2-2
+- Fix missing python binding constants
+
 * Fri Feb  1 2013 Daniel P. Berrange <berrange at redhat.com> - 1.0.2-1
 - Update to 1.0.2 release
 


More information about the scm-commits mailing list