From: Michael Tremer Date: Thu, 1 Feb 2018 13:33:38 +0000 (+0000) Subject: python: Expose version of the module X-Git-Tag: 0.9.0~76 X-Git-Url: http://git.ipfire.org/?p=people%2Fms%2Flibloc.git;a=commitdiff_plain;h=ddb184be550d54345cfa71fe33d7a2a281e2ae2e python: Expose version of the module Signed-off-by: Michael Tremer --- diff --git a/src/python/location-query.in b/src/python/location-query.in index 260f4bd..e750ea4 100644 --- a/src/python/location-query.in +++ b/src/python/location-query.in @@ -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"), diff --git a/src/python/locationmodule.c b/src/python/locationmodule.c index 40b0c35..dcb5a47 100644 --- a/src/python/locationmodule.c +++ b/src/python/locationmodule.c @@ -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; }