Doug Goldstein wrote:
On Thu, Dec 12, 2013 at 4:29 PM, Eric Blake <eblake(a)redhat.com>
wrote:
> On 12/11/2013 08:43 PM, Doug Goldstein wrote:
>> The method getVersion() retrieves the version of the libvirt library
>> that the binaries are linked against but there is no way to retrieve the
>> version of the bindings you are using. In the future if we support new
>> APIs in Python that don't rely on features in the library there needs to
>> be a way for programmers to detect the version.
>> ---
>> I would expect there's a cleaner way to implement this than I've done
>> but I opted for what I saw as the smallest implementation. If anyone
>> has a suggestion for a better way to do this I'm ok with redoing this
>> patch.
>
> The idea sounds sane to me.
>
>> ---
>> libvirt-override.py | 3 +++
>> setup.py | 16 ++++++++++++++++
>> 2 files changed, 19 insertions(+)
>
> Alas, my python is too weak to give either a meaningful review to the
> code, or to suggest an alternative. :(
>
> --
> Eric Blake eblake redhat com +1-919-301-3266
> Libvirt virtualization library
http://libvirt.org
>
Ping for some more feedback from others.
A have a shorter but probably a little hacky way to do this:
diff --git a/libvirt-override.py b/libvirt-override.py
index 63f8ecb..93b6e0a 100644
--- a/libvirt-override.py
+++ b/libvirt-override.py
@@ -2,6 +2,9 @@
# Manually written part of python bindings for libvirt
#
+version = (1, 2, 0)
+__version__ = '.'.join(str(x) for x in version)
+
# On cygwin, the DLL is called cygvirtmod.dll
import sys
diff --git a/setup.py b/setup.py
index 24d4cf2..1138e15 100755
--- a/setup.py
+++ b/setup.py
@@ -278,7 +278,7 @@ class my_clean(clean):
remove_tree("build")
setup(name = 'libvirt-python',
- version = '1.2.0',
+ version = __import__('libvirt-override').__version__,
url = 'http://www.libvirt.org',
maintainer = 'Libvirt Maintainers',
maintainer_email = 'libvir-list(a)redhat.com',
Roman Bogorodskiy