Python bindings ready for first commit
Seth Nickell
seth@gnome.org
21 Sep 2003 21:21:59 -0700
--=-HLPeqdGF8jHD1Jqywv5Y
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Attached is a patch, sans new files, to dbus adding the python bindings.
Python bindings default to "auto", same as glib and qt. If you specify
"no" all Python related checks are skipped. Can I commit this (along
with the bindings themselves)?
-Seth
--=-HLPeqdGF8jHD1Jqywv5Y
Content-Disposition: attachment; filename=python-bindings-patch
Content-Type: text/plain; name=python-bindings-patch; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
? python-bindings-patch
? python/hold
Index: ChangeLog
===================================================================
RCS file: /cvs/dbus/dbus/ChangeLog,v
retrieving revision 1.390.2.39
diff -u -p -r1.390.2.39 ChangeLog
--- ChangeLog 22 Sep 2003 03:11:11 -0000 1.390.2.39
+++ ChangeLog 22 Sep 2003 04:18:59 -0000
@@ -1,3 +1,28 @@
+2003-09-21 Seth Nickell <seth@gnome.org>
+
+ First checkin of the Python bindings.
+
+ * python/.cvsignore:
+ * python/Makefile.am:
+ * python/dbus_bindings.pyx.in:
+ * python/dbus_h_wrapper.h:
+
+ Pieces for Pyrex to operate on, building a dbus_bindings.so
+ python module for low-level access to the DBus APIs.
+
+ * python/dbus.py:
+
+ High-level Python module for accessing DBus objects.
+
+ * configure.in:
+ * Makefile.am:
+
+ Build stuff for the python bindings.
+
+ * acinclude.m4:
+
+ Extra macro needed for finding the Python C header files.
+
2003-09-21 Havoc Pennington <hp@pobox.com>
* glib/dbus-gproxy.c (dbus_gproxy_manager_new): start
Index: Makefile.am
===================================================================
RCS file: /cvs/dbus/dbus/Makefile.am,v
retrieving revision 1.14.2.1
diff -u -p -r1.14.2.1 Makefile.am
--- Makefile.am 17 Sep 2003 03:52:06 -0000 1.14.2.1
+++ Makefile.am 22 Sep 2003 04:18:59 -0000
@@ -16,8 +16,11 @@ if DBUS_USE_MCS
MONO_SUBDIR=mono
endif
+if HAVE_PYTHON
+ PYTHON_SUBDIR=python
+endif
-SUBDIRS=dbus bus doc $(GLIB_SUBDIR) $(GCJ_SUBDIR) $(MONO_SUBDIR) $(QT_SUBDIR) test tools
+SUBDIRS=dbus bus doc $(GLIB_SUBDIR) $(GCJ_SUBDIR) $(MONO_SUBDIR) $(QT_SUBDIR) $(PYTHON_SUBDIR) test tools
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = dbus-1.pc $(GLIB_PC)
Index: acinclude.m4
===================================================================
RCS file: /cvs/dbus/dbus/acinclude.m4,v
retrieving revision 1.1
diff -u -p -r1.1 acinclude.m4
--- acinclude.m4 27 Dec 2002 21:32:38 -0000 1.1
+++ acinclude.m4 22 Sep 2003 04:18:59 -0000
@@ -55,3 +55,29 @@ AC_DEFUN(PKG_CHECK_MODULES, [
])
+
+dnl a macro to check for ability to create python extensions
+dnl AM_CHECK_PYTHON_HEADERS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE])
+dnl function also defines PYTHON_INCLUDES
+AC_DEFUN([AM_CHECK_PYTHON_HEADERS],
+[AC_REQUIRE([AM_PATH_PYTHON])
+AC_MSG_CHECKING(for headers required to compile python extensions)
+dnl deduce PYTHON_INCLUDES
+py_prefix=`$PYTHON -c "import sys; print sys.prefix"`
+py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"`
+PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}"
+if test "$py_prefix" != "$py_exec_prefix"; then
+ PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
+fi
+AC_SUBST(PYTHON_INCLUDES)
+dnl check if the headers exist:
+save_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"
+AC_TRY_CPP([#include <Python.h>],dnl
+[AC_MSG_RESULT(found)
+$1],dnl
+[AC_MSG_RESULT(not found)
+$2])
+CPPFLAGS="$save_CPPFLAGS"
+])
+
Index: configure.in
===================================================================
RCS file: /cvs/dbus/dbus/configure.in,v
retrieving revision 1.68.2.4
diff -u -p -r1.68.2.4 configure.in
--- configure.in 17 Sep 2003 03:52:06 -0000 1.68.2.4
+++ configure.in 22 Sep 2003 04:19:00 -0000
@@ -35,6 +35,8 @@ AC_ARG_ENABLE(gcov, [ --ena
AC_ARG_ENABLE(abstract-sockets, [ --enable-abstract-sockets use abstract socket namespace (linux only)],enable_abstract_sockets=$enableval,enable_abstract_sockets=auto)
AC_ARG_ENABLE(gcj, [ --enable-gcj build gcj bindings],enable_gcj=$enableval,enable_gcj=no)
AC_ARG_ENABLE(mono, [ --enable-mono build mono bindings],enable_mono=$enableval,enable_mono=no)
+AC_ARG_ENABLE(python, [ --enable-python build python bindings],enable_python=$enableval,enable_python=auto)
+
AC_ARG_WITH(xml, [ --with-xml=[libxml/expat] XML library to use])
AC_ARG_WITH(init-scripts, [ --with-init-scripts=[redhat] Style of init scripts to install])
@@ -834,6 +836,42 @@ fi
AC_DEFINE_UNQUOTED(DBUS_SESSION_SOCKET_DIR, "$DBUS_SESSION_SOCKET_DIR", [Where per-session bus puts its sockets])
AC_SUBST(DBUS_SESSION_SOCKET_DIR)
+# Detect if we can build Python bindings (need python, python headers, and pyrex)
+if test x$enable_python = xno; then
+ have_python=no
+else
+ AC_MSG_NOTICE([Checking to see if we can build Python bindings])
+ have_python=no
+ AM_PATH_PYTHON(2.2)
+
+ if test -z "$PYTHON" ; then
+ AC_MSG_WARN([Python not found])
+ else
+ AC_CHECK_PROGS(PYREX, pyrexc)
+
+ if test -z "$PYREX" ; then
+ have_pyrex=no
+ else
+ have_pyrex=yes
+ fi
+
+ AM_CHECK_PYTHON_HEADERS(have_python_headers=yes,have_python_headers=no)
+
+ if test x$have_pyrex = xyes -a x$have_python_headers = xyes ; then
+ have_python=yes
+ fi
+ fi
+
+ if test x$have_python = xno ; then
+ if test x$enable_python = xyes ; then
+ AC_MSG_ERROR([Building python explicitly requested, but can't build python bindings])
+ else
+ AC_MSG_WARN([Couldn't find either Pyrex or the Python headers, not building Python bindings])
+ fi
+ fi
+fi
+
+AM_CONDITIONAL(HAVE_PYTHON, test x$have_python = xyes)
AC_OUTPUT([
@@ -846,6 +884,7 @@ bus/dbus-daemon-1.1
Makefile
dbus/Makefile
glib/Makefile
+python/Makefile
qt/Makefile
gcj/Makefile
gcj/org/Makefile
@@ -914,6 +953,7 @@ echo "
Building checks: ${enable_checks}
Building Qt bindings: ${have_qt}
Building GLib bindings: ${have_glib}
+ Building Python bindings: ${have_python}
Building GTK+ tools: ${have_gtk}
Building X11 code: ${enable_x11}
Building documentation: ${enable_docs}
--=-HLPeqdGF8jHD1Jqywv5Y--