[systemd-commits] 3 commits - configure.ac Makefile.am src/python-systemd

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Fri Jul 26 08:30:28 PDT 2013


 Makefile.am                  |   20 ++++++++--------
 configure.ac                 |   35 ++++++++++++----------------
 src/python-systemd/_reader.c |   53 +++++++++----------------------------------
 3 files changed, 38 insertions(+), 70 deletions(-)

New commits:
commit fd587c876d480863d56bbbdc5e9fcf7e735d98f3
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Fri Jul 26 11:02:27 2013 -0400

    systemd-python: fix gcc warning
    
    src/python-systemd/_reader.c: In function Reader_get_catalog:
    src/python-systemd/_reader.c:912:53: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 assert(mid_len > l);
                                ^

diff --git a/src/python-systemd/_reader.c b/src/python-systemd/_reader.c
index 98a99aa..a678f69 100644
--- a/src/python-systemd/_reader.c
+++ b/src/python-systemd/_reader.c
@@ -908,9 +908,9 @@ static PyObject* Reader_get_catalog(Reader *self, PyObject *args)
 
         r = sd_journal_get_data(self->j, "MESSAGE_ID", &mid, &mid_len);
         if (r == 0) {
-            const int l = sizeof("MESSAGE_ID");
+            const size_t l = sizeof("MESSAGE_ID");
             assert(mid_len > l);
-            PyErr_Format(PyExc_KeyError, "%.*s", (int) mid_len - l,
+            PyErr_Format(PyExc_KeyError, "%.*s", (int) (mid_len - l),
                          (const char*) mid + l);
         } else if (r == -ENOENT)
             PyErr_SetString(PyExc_IndexError, "no MESSAGE_ID field");

commit a6c0b31d509f76023d8efbcd5e912863c8fb254c
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Fri Jul 26 10:08:15 2013 -0400

    build-sys: use pkg-config for python compilation flags
    
    Python 2.7, and 3.2 and higher support querying compilation
    flags through pkg-config. This makes python support follow
    rules similar to various other optional compilation-time
    libraries. New flags are called PYTHON_DEVEL_CFLAGS and
    PYTHON_DEVEL_LIBS, because PYTHON (without _DEVEL), is
    already used for the python binary name, and things would
    be confusing if the same prefix was used for two things.
    configure has --disable-python-devel to disable python modules.
    
    One advantage is that CFLAGS for modules gets smaller:
    - -I/usr/include/python3.3m -I/usr/include/python3.3m -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv
    + -I/usr/include/python3.3m
    as does LIBS:
    - -lpthread -ldl -lutil -lm -lpython3.3m
    + -lpython3.3m
    
    Support for Python 2.6 is removed, but can be easily
    restored by using
    PYTHON_DEVEL_CFLAGS="$(python2.6-config --cflags)",
    etc., as ./configure parameters.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=57800

diff --git a/Makefile.am b/Makefile.am
index 8ac1d8d..7b4753d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3905,7 +3905,7 @@ _journal_la_SOURCES = \
 _journal_la_CFLAGS = \
 	$(AM_CFLAGS) \
 	-fvisibility=default \
-	$(PYTHON_CFLAGS)
+	$(PYTHON_DEVEL_CFLAGS)
 
 _journal_la_LDFLAGS = \
 	$(AM_LDFLAGS) \
@@ -3914,7 +3914,7 @@ _journal_la_LDFLAGS = \
 	-avoid-version
 
 _journal_la_LIBADD = \
-	$(PYTHON_LIBS) \
+	$(PYTHON_DEVEL_LIBS) \
 	libsystemd-journal.la
 
 id128_la_SOURCES = \
@@ -3926,7 +3926,7 @@ id128_la_SOURCES = \
 id128_la_CFLAGS = \
 	$(AM_CFLAGS) \
 	-fvisibility=default \
-	$(PYTHON_CFLAGS) \
+	$(PYTHON_DEVEL_CFLAGS) \
 	-I$(top_builddir)/src/python-systemd
 
 id128_la_LDFLAGS = \
@@ -3936,7 +3936,7 @@ id128_la_LDFLAGS = \
 	-avoid-version
 
 id128_la_LIBADD = \
-	$(PYTHON_LIBS) \
+	$(PYTHON_DEVEL_LIBS) \
 	libsystemd-id128.la
 
 _daemon_la_SOURCES = \
@@ -3947,7 +3947,7 @@ _daemon_la_SOURCES = \
 _daemon_la_CFLAGS = \
 	$(AM_CFLAGS) \
 	-fvisibility=default \
-	$(PYTHON_CFLAGS) \
+	$(PYTHON_DEVEL_CFLAGS) \
 	-I$(top_builddir)/src/python-systemd
 
 _daemon_la_LDFLAGS = \
@@ -3957,7 +3957,7 @@ _daemon_la_LDFLAGS = \
 	-avoid-version
 
 _daemon_la_LIBADD = \
-	$(PYTHON_LIBS) \
+	$(PYTHON_DEVEL_LIBS) \
 	libsystemd-daemon.la
 
 _reader_la_SOURCES = \
@@ -3968,7 +3968,7 @@ _reader_la_SOURCES = \
 _reader_la_CFLAGS = \
 	$(AM_CFLAGS) \
 	-fvisibility=default \
-	$(PYTHON_CFLAGS)
+	$(PYTHON_DEVEL_CFLAGS)
 
 _reader_la_LDFLAGS = \
 	$(AM_LDFLAGS) \
@@ -3977,7 +3977,7 @@ _reader_la_LDFLAGS = \
 	-avoid-version
 
 _reader_la_LIBADD = \
-	$(PYTHON_LIBS) \
+	$(PYTHON_DEVEL_LIBS) \
 	libsystemd-journal.la \
 	libsystemd-id128.la \
 	libsystemd-shared.la \
@@ -3991,7 +3991,7 @@ login_la_SOURCES = \
 login_la_CFLAGS = \
 	$(AM_CFLAGS) \
 	-fvisibility=default \
-	$(PYTHON_CFLAGS)
+	$(PYTHON_DEVEL_CFLAGS)
 
 login_la_LDFLAGS = \
 	$(AM_LDFLAGS) \
@@ -4000,7 +4000,7 @@ login_la_LDFLAGS = \
 	-avoid-version
 
 login_la_LIBADD = \
-	$(PYTHON_LIBS) \
+	$(PYTHON_DEVEL_LIBS) \
 	libsystemd-journal.la \
 	libsystemd-login.la \
 	libsystemd-shared.la \
diff --git a/configure.ac b/configure.ac
index 759073a..4e8c573 100644
--- a/configure.ac
+++ b/configure.ac
@@ -144,11 +144,10 @@ CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
         --param=ssp-buffer-size=4])
 AC_SUBST([OUR_CFLAGS], $with_cflags)
 
-AS_CASE([$CFLAGS], [*-O[[12345g\ ]]*], [
-        CC_CHECK_FLAGS_APPEND([with_cppflags], [CPPFLAGS], [\
-               -Wp,-D_FORTIFY_SOURCE=2])], [
-        python_extra_cflags=-Wp,-U_FORTIFY_SOURCE
-        AC_MSG_RESULT([skipping -D_FORTIFY_SOURCE, optimization not enabled])])
+AS_CASE([$CFLAGS], [*-O[[12345g\ ]]*],
+        [CC_CHECK_FLAGS_APPEND([with_cppflags], [CPPFLAGS], [\
+               -Wp,-D_FORTIFY_SOURCE=2])],
+        [AC_MSG_RESULT([skipping -D_FORTIFY_SOURCE, optimization not enabled])])
 AC_SUBST([OUR_CPPFLAGS], $with_cppflags)
 
 CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [\
@@ -162,8 +161,6 @@ AC_SUBST([OUR_LDFLAGS], $with_ldflags)
 # ------------------------------------------------------------------------------
 # we use python to build the man page index, and for systemd-python
 have_python=no
-have_python_devel=no
-
 AC_ARG_WITH([python],
         [AS_HELP_STRING([--without-python], [Disable building the man page index and systemd-python (default: test)])])
 
@@ -178,16 +175,16 @@ AS_IF([test "x$PYTHON_BINARY" = "x"],
              [PYTHON_BINARY=/usr/bin/python])])
 AC_ARG_VAR(PYTHON_BINARY, [Python binary used to launch installed scripts])
 
-AS_IF([test "x$with_python" != "xno"], [
-        AC_PATH_PROG(PYTHON_CONFIG, python${PYTHON_VERSION}-config)
-        AS_IF([test -n "$PYTHON_CONFIG"], [
-              have_python_devel=yes
-              PYTHON_CFLAGS="$($PYTHON_CONFIG --cflags) $python_extra_cflags"
-              PYTHON_LIBS="$($PYTHON_CONFIG --ldflags)"
-              AC_SUBST(PYTHON_CFLAGS)
-              AC_SUBST(PYTHON_LIBS)
-              AC_PATH_PROGS(SPHINX_BUILD, sphinx-build-${PYTHON_VERSION} sphinx-build)
-        ])
+have_python_devel=no
+AC_ARG_ENABLE(python_devel, AS_HELP_STRING([--disable-python-devel], [Do not build python modules]))
+AS_IF([test "x$enable_python_devel" != "xno"], [
+      PKG_CHECK_MODULES([PYTHON_DEVEL], [python-${PYTHON_VERSION}],
+            [have_python_devel=yes],
+            [PKG_CHECK_MODULES([PYTHON_DEVEL], [python],
+                  [have_python_devel=yes],
+                  [have_python_devel=no])])
+      AS_IF([test "x$have_python_devel" = xno -a "x$enable_python_devel" = xyes],
+            [AC_MSG_ERROR([*** python-devel support requested but libraries not found])])
 ])
 AM_CONDITIONAL([HAVE_PYTHON_DEVEL], [test "$have_python_devel" = "yes"])
 
@@ -1039,6 +1036,6 @@ AC_MSG_RESULT([
         CFLAGS:                  ${OUR_CFLAGS} ${CFLAGS}
         CPPFLAGS:                ${OUR_CPPFLAGS} ${CPPFLAGS}
         LDFLAGS:                 ${OUR_LDFLAGS} ${LDFLAGS}
-        PYTHON_CFLAGS:           ${PYTHON_CFLAGS}
-        PYTHON_LIBS:             ${PYTHON_LIBS}
+        PYTHON_CFLAGS:           ${PYTHON_DEVEL_CFLAGS}
+        PYTHON_LIBS:             ${PYTHON_DEVEL_LIBS}
 ])

commit b59f043c3d0c84b578cf170b255bb6ac5670beeb
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Thu Jul 25 18:55:08 2013 -0400

    systemd-python: use modern C

diff --git a/src/python-systemd/_reader.c b/src/python-systemd/_reader.c
index 6ac2f20..98a99aa 100644
--- a/src/python-systemd/_reader.c
+++ b/src/python-systemd/_reader.c
@@ -1046,48 +1046,20 @@ static PyMethodDef Reader_methods[] = {
 
 static PyTypeObject ReaderType = {
     PyVarObject_HEAD_INIT(NULL, 0)
-    "_reader._Reader",                        /*tp_name*/
-    sizeof(Reader),                           /*tp_basicsize*/
-    0,                                        /*tp_itemsize*/
-    (destructor)Reader_dealloc,               /*tp_dealloc*/
-    0,                                        /*tp_print*/
-    0,                                        /*tp_getattr*/
-    0,                                        /*tp_setattr*/
-    0,                                        /*tp_compare*/
-    0,                                        /*tp_repr*/
-    0,                                        /*tp_as_number*/
-    0,                                        /*tp_as_sequence*/
-    0,                                        /*tp_as_mapping*/
-    0,                                        /*tp_hash */
-    0,                                        /*tp_call*/
-    0,                                        /*tp_str*/
-    0,                                        /*tp_getattro*/
-    0,                                        /*tp_setattro*/
-    0,                                        /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    Reader__doc__,                            /* tp_doc */
-    0,                                        /* tp_traverse */
-    0,                                        /* tp_clear */
-    0,                                        /* tp_richcompare */
-    0,                                        /* tp_weaklistoffset */
-    0,                                        /* tp_iter */
-    0,                                        /* tp_iternext */
-    Reader_methods,                           /* tp_methods */
-    0,                                        /* tp_members */
-    Reader_getsetters,                        /* tp_getset */
-    0,                                        /* tp_base */
-    0,                                        /* tp_dict */
-    0,                                        /* tp_descr_get */
-    0,                                        /* tp_descr_set */
-    0,                                        /* tp_dictoffset */
-    (initproc) Reader_init,                   /* tp_init */
-    0,                                        /* tp_alloc */
-    PyType_GenericNew,                        /* tp_new */
+    .tp_name = "_reader._Reader",
+    .tp_basicsize = sizeof(Reader),
+    .tp_dealloc = (destructor) Reader_dealloc,
+    .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+    .tp_doc = Reader__doc__,
+    .tp_methods = Reader_methods,
+    .tp_getset = Reader_getsetters,
+    .tp_init = (initproc) Reader_init,
+    .tp_new = PyType_GenericNew,
 };
 
 static PyMethodDef methods[] = {
         { "_get_catalog", get_catalog, METH_VARARGS, get_catalog__doc__},
-        { NULL, NULL, 0, NULL }        /* Sentinel */
+        {} /* Sentinel */
 };
 
 #if PY_MAJOR_VERSION >= 3
@@ -1097,7 +1069,6 @@ static PyModuleDef module = {
     module__doc__,
     -1,
     methods,
-    NULL, NULL, NULL, NULL
 };
 #endif
 



More information about the systemd-commits mailing list