[Libguestfs] [PATCH 1/3] python: expose package version

Peter Wu peter at lekensteyn.nl
Sat Aug 9 15:33:04 UTC 2014


Exposing the module version through the `__version__` property conforms
to PEP-396. The recommended versioning scheme is specified in
PEP-386[1].

 [1]: https://www.python.org/dev/peps/pep-0386/
---
 generator/generator.ml | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/generator/generator.ml b/generator/generator.ml
index 40c1981..f6c34e9 100755
--- a/generator/generator.ml
+++ b/generator/generator.ml
@@ -3310,6 +3310,10 @@ moduleinit (void)
   m = Py_InitModule ((char *) \"libhivexmod\", methods);
 #endif
 
+  if (m) {
+    PyModule_AddStringConstant (m, \"__version__\", PACKAGE_VERSION);
+  }
+
   return m; /* m might be NULL if module init failed */
 }
 
@@ -3345,6 +3349,8 @@ Read the hivex(3) man page to find out how to use the API.
 
 import libhivexmod
 
+__version__ = libhivexmod.__version__
+
 class Hivex(object):
     \"\"\"Instances of this class are hivex API handles.\"\"\"
 
-- 
2.0.2




More information about the Libguestfs mailing list