systemd-python: add __version__ strings

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2013-05-08 21:08:14 -04:00
parent 6866780115
commit 5afbe712db
7 changed files with 31 additions and 10 deletions

View 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;

View 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;
}

View 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

View 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;

View file

@ -1,4 +1,5 @@
from ._daemon import (booted,
from ._daemon import (__version__,
booted,
_listen_fds,
_is_fifo,
_is_socket,

View 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;
}

View 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)