From 7f30548da656b9a6092e441b1179b4dbd7472a21 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Thu, 2 Apr 2020 10:11:23 +0200 Subject: [PATCH] bindings: python: add the __version__ module attribute The python module provides the version_string() function that returns the API version but the standard way to do this according to PEP 396 is by providing the __version__ attribute at the module level. Add __version__ constant to gpiod module and mark version_string() as deprecated in the doc. Signed-off-by: Bartosz Golaszewski --- bindings/python/gpiodmodule.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bindings/python/gpiodmodule.c b/bindings/python/gpiodmodule.c index 5b157e6..e5db26b 100644 --- a/bindings/python/gpiodmodule.c +++ b/bindings/python/gpiodmodule.c @@ -2690,6 +2690,7 @@ static gpiod_LineObject *gpiod_Module_find_line(PyObject *Py_UNUSED(self), PyDoc_STRVAR(gpiod_Module_version_string_doc, "version_string() -> string\n" "\n" +"DEPRECATED: use __version__ module attribute instead.\n" "Get the API version of the library as a human-readable string."); static PyObject *gpiod_Module_version_string(PyObject *Py_UNUSED(ignored0), @@ -2934,5 +2935,10 @@ PyMODINIT_FUNC PyInit_gpiod(void) return NULL; } + rv = PyModule_AddStringConstant(module, "__version__", + gpiod_version_string()); + if (rv < 0) + return NULL; + return module; } -- 2.30.2