chiark / gitweb /
systemd-python: add __version__ strings
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 9 May 2013 01:08:14 +0000 (21:08 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 9 May 2013 01:34:44 +0000 (21:34 -0400)
src/journal/sd-journal.c
src/python-systemd/_daemon.c
src/python-systemd/_journal.c
src/python-systemd/_reader.c
src/python-systemd/daemon.py
src/python-systemd/id128.c
src/python-systemd/journal.py

index d81e4ddfa94b3dd3d52063e2d5ac3c29e4408285..c21712b7c47abf6f0c8893b4753b61de17e7220e 100644 (file)
@@ -415,7 +415,7 @@ _public_ void sd_journal_flush_matches(sd_journal *j) {
 }
 
 static int compare_entry_order(JournalFile *af, Object *_ao,
-                         JournalFile *bf, uint64_t bp) {
+                               JournalFile *bf, uint64_t bp) {
 
         uint64_t a, b;
         Object *ao, *bo;
index ce2064935debbc15f9886f78272bc9c19ec1ccc5..d3b4807368aced0c0a07a825ab3851934fe8bc59 100644 (file)
@@ -291,6 +291,7 @@ PyMODINIT_FUNC init_daemon(void) {
                 return;
 
         PyModule_AddIntConstant(m, "LISTEN_FDS_START", SD_LISTEN_FDS_START);
+        PyModule_AddStringConstant(m, "__version__", PACKAGE_VERSION);
 }
 
 #else
@@ -310,7 +311,8 @@ PyMODINIT_FUNC PyInit__daemon(void) {
         if (m == NULL)
                 return NULL;
 
-        if (PyModule_AddIntConstant(m, "LISTEN_FDS_START", SD_LISTEN_FDS_START)) {
+        if (PyModule_AddIntConstant(m, "LISTEN_FDS_START", SD_LISTEN_FDS_START) ||
+            PyModule_AddStringConstant(m, "__version__", PACKAGE_VERSION)) {
                 Py_DECREF(m);
                 return NULL;
         }
index 2de0d4f91d5f5eb37511e08810c2eaf2a717d4d5..f8e0b4f7f29e661700bd1b9d0d6c7a7d7499d0a6 100644 (file)
@@ -119,7 +119,13 @@ static PyMethodDef methods[] = {
 #if PY_MAJOR_VERSION < 3
 
 PyMODINIT_FUNC init_journal(void) {
-        (void) Py_InitModule("_journal", methods);
+        PyObject *m;
+
+        m = Py_InitModule("_journal", methods);
+        if (m == NULL)
+                return;
+
+        PyModule_AddStringConstant(m, "__version__", PACKAGE_VERSION);
 }
 
 #else
@@ -133,7 +139,18 @@ static struct PyModuleDef module = {
 };
 
 PyMODINIT_FUNC PyInit__journal(void) {
-        return PyModule_Create(&module);
+        PyObject *m;
+
+        m = PyModule_Create(&module);
+        if (m == NULL)
+                return NULL;
+
+        if (PyModule_AddStringConstant(m, "__version__", PACKAGE_VERSION)) {
+                Py_DECREF(m);
+                return NULL;
+        }
+
+        return m;
 }
 
 #endif
index b8365977466f3f19d5c31a22d6d89a29d323432a..50ad8892015e33ee0d034ce6d0117baad3ee5cfd 100644 (file)
@@ -30,6 +30,7 @@
 #include "pyutil.h"
 #include "macro.h"
 #include "util.h"
+#include "build.h"
 
 typedef struct {
     PyObject_HEAD
@@ -1126,7 +1127,8 @@ init_reader(void)
         PyModule_AddIntConstant(m, "INVALIDATE", SD_JOURNAL_INVALIDATE) ||
         PyModule_AddIntConstant(m, "LOCAL_ONLY", SD_JOURNAL_LOCAL_ONLY) ||
         PyModule_AddIntConstant(m, "RUNTIME_ONLY", SD_JOURNAL_RUNTIME_ONLY) ||
-        PyModule_AddIntConstant(m, "SYSTEM_ONLY", SD_JOURNAL_SYSTEM_ONLY)) {
+        PyModule_AddIntConstant(m, "SYSTEM_ONLY", SD_JOURNAL_SYSTEM_ONLY) ||
+        PyModule_AddStringConstant(m, "__version__", PACKAGE_VERSION)) {
 #if PY_MAJOR_VERSION >= 3
         Py_DECREF(m);
         return NULL;
index 4a022044334a8accdf7100b1c5e3ae38a211c5b9..e2829d1671ec461c9ac70afcce180a5072c9bfad 100644 (file)
@@ -1,4 +1,5 @@
-from ._daemon import (booted,
+from ._daemon import (__version__,
+                      booted,
                       _listen_fds,
                       _is_fifo,
                       _is_socket,
index 1c2fe5dd0b2fa4cc62d8f16f18e07b493d289b77..ec1d9fb4a2b530d6d7929bd0cf07356c40219108 100644 (file)
@@ -19,8 +19,6 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include <stdbool.h>
-
 #include <Python.h>
 
 #include <systemd/sd-messages.h>
@@ -126,6 +124,7 @@ PyMODINIT_FUNC initid128(void) {
 #define JOINER ;
 #include "id128-constants.h"
 #undef JOINER
+        PyModule_AddStringConstant(m, "__version__", PACKAGE_VERSION);
 }
 
 #else
@@ -149,7 +148,7 @@ PyMODINIT_FUNC PyInit_id128(void) {
 #define JOINER ||
 #include "id128-constants.h"
 #undef JOINER
-                false) {
+            PyModule_AddStringConstant(m, "__version__", PACKAGE_VERSION)) {
                 Py_DECREF(m);
                 return NULL;
         }
index 9e40cbc57e9384f7710dee0b68b66a174615633e..9ef1ede229e8f9b695f252e97cbe726fe50d278a 100644 (file)
@@ -31,7 +31,7 @@ if _sys.version_info >= (3,3):
     from collections import ChainMap as _ChainMap
 from syslog import (LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR,
                     LOG_WARNING, LOG_NOTICE, LOG_INFO, LOG_DEBUG)
-from ._journal import sendv, stream_fd
+from ._journal import __version__, sendv, stream_fd
 from ._reader import (_Reader, NOP, APPEND, INVALIDATE,
                       LOCAL_ONLY, RUNTIME_ONLY, SYSTEM_ONLY,
                       _get_catalog)