]> git.ipfire.org Git - location/libloc.git/commitdiff
python: Expose version of the module
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 1 Feb 2018 13:33:38 +0000 (13:33 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 1 Feb 2018 13:33:38 +0000 (13:33 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/python/location-query.in
src/python/locationmodule.c

index 260f4bd88abe0102629d98006c0f338377551c7e..e750ea4bb15cacfe36b3aa9498c6ea3825aefcbe 100644 (file)
@@ -42,6 +42,10 @@ class CLI(object):
                parser.add_argument("--debug", action="store_true",
                        help=_("Enable debug output"))
 
+               # version
+               parser.add_argument("--version", action="version",
+                       version="%%(prog)s %s" % location.__version__)
+
                # lookup an IP address
                lookup = subparsers.add_parser("lookup",
                        help=_("Lookup one or multiple IP addresses"),
index 40b0c35ffb032d4e2cf1a917437580bdec17659e..dcb5a47560d174565c1e01c609d395087af23b69 100644 (file)
@@ -106,5 +106,11 @@ PyMODINIT_FUNC PyInit_location(void) {
        Py_INCREF(&WriterType);
        PyModule_AddObject(m, "Writer", (PyObject *)&WriterType);
 
+       // Add constants
+       PyObject* d = PyModule_GetDict(m);
+
+       // Version
+       PyDict_SetItemString(d, "__version__", PyUnicode_FromString(VERSION));
+
        return m;
 }