Hilko Bengen
2013-May-23 23:31 UTC
[Libguestfs] hivex: Improvents in building Python bindings
Building against multiple versions of Python is a lot of fun as it is. Add autoconf/automake/libtool (and possible distribution-specific stuff) to the mix and things get really interesting: On Debian and Ubuntu, building against python 3.3 requires an extra include path as documented in <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=692387>. As discussed in <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=692387>, special version- and ABI-specific suffixes have been introduced, those are now part of what is built using libtool. Cheers, -Hilko
Hilko Bengen
2013-May-23 23:31 UTC
[Libguestfs] [PATCH 1/2] Fix bindings for python 3.3 (as shipped with Debian and Ubuntu).
---
configure.ac | 18 ++++++++++++------
python/Makefile.am | 2 +-
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/configure.ac b/configure.ac
index b398fcb..3714c60 100644
--- a/configure.ac
+++ b/configure.ac
@@ -274,7 +274,7 @@ AM_CONDITIONAL([HAVE_PERL],
dnl Check for Python (optional, for Python bindings).
PYTHON_PREFIX PYTHON_VERSION-PYTHON_INCLUDEDIR+PYTHON_CFLAGS PYTHON_INSTALLDIR
AC_ARG_ENABLE([python],
@@ -297,12 +297,18 @@ AS_IF([test "x$enable_python" !=
"xno"],
AC_MSG_RESULT([$PYTHON_VERSION])
AC_MSG_CHECKING([for Python include path])
- if test -z "$PYTHON_INCLUDEDIR"; then
+ if test -z "$PYTHON_CFLAGS"; then
python_path=`$PYTHON -c "import distutils.sysconfig; \
print
(distutils.sysconfig.get_python_inc ());"`
- PYTHON_INCLUDEDIR=$python_path
+ python_platpath=`$PYTHON -c "import distutils.sysconfig; \
+ print
(distutils.sysconfig.get_python_inc (plat_specific=1));"`
+ if test "$python_path" =
"$python_platpath"; then
+ PYTHON_CFLAGS=-I$python_path
+ else
+ PYTHON_CFLAGS="-I$python_path -I$python_platpath"
+ fi
fi
- AC_MSG_RESULT([$PYTHON_INCLUDEDIR])
+ AC_MSG_RESULT([$PYTHON_CFLAGS])
AC_ARG_WITH([python-installdir],
[AS_HELP_STRING([--with-python-installdir],
@@ -340,11 +346,11 @@ AS_IF([test "x$enable_python" !=
"xno"],
AC_SUBST(PYTHON_PREFIX)
AC_SUBST(PYTHON_VERSION)
- AC_SUBST(PYTHON_INCLUDEDIR)
+ AC_SUBST(PYTHON_CFLAGS)
AC_SUBST(PYTHON_INSTALLDIR)
])
AM_CONDITIONAL([HAVE_PYTHON],
- [test "x$PYTHON" != "xno" && test
"x$PYTHON_INCLUDEDIR" != "x" && test
"x$PYTHON_INSTALLDIR" != "x"])
+ [test "x$PYTHON" != "xno" && test
"x$PYTHON_CFLAGS" != "x" && test
"x$PYTHON_INSTALLDIR" != "x"])
dnl Check for Ruby and rake (optional, for Ruby bindings).
AC_ARG_ENABLE([ruby],
diff --git a/python/Makefile.am b/python/Makefile.am
index be1523e..ead52b4 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -33,7 +33,7 @@ python_DATA = hivex.py
python_LTLIBRARIES = libhivexmod.la
libhivexmod_la_SOURCES = hivex-py.c
-libhivexmod_la_CFLAGS = -Wall -I$(PYTHON_INCLUDEDIR) \
+libhivexmod_la_CFLAGS = -Wall $(PYTHON_CFLAGS) \
-I$(top_srcdir)/lib -I$(top_builddir)/lib
libhivexmod_la_LIBADD = $(top_builddir)/lib/libhivex.la
libhivexmod_la_LDFLAGS = -avoid-version -shared
--
1.7.10.4
Hilko Bengen
2013-May-23 23:31 UTC
[Libguestfs] [PATCH 2/2] Build Python extension with PEP-3149 compliant suffix if defined.
---
configure.ac | 9 +++++++++
python/Makefile.am | 2 +-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 3714c60..aa63110 100644
--- a/configure.ac
+++ b/configure.ac
@@ -327,6 +327,14 @@ AS_IF([test "x$enable_python" !=
"xno"],
AC_MSG_RESULT([$PYTHON_INSTALLDIR])
fi
+ AC_MSG_CHECKING([for Python extension suffix (PEP-3149)])
+ if test -z "$PYTHON_EXT_SUFFIX"; then
+ python_ext_suffix=`$PYTHON -c "import sysconfig; \
+ print
(sysconfig.get_config_var('EXT_SUFFIX') or
sysconfig.get_config_var('SO'))"`
+ PYTHON_EXT_SUFFIX=$python_ext_suffix
+ fi
+ AC_MSG_RESULT([$PYTHON_EXT_SUFFIX])
+
dnl Look for some optional symbols in libpython.
old_LIBS="$LIBS"
@@ -348,6 +356,7 @@ AS_IF([test "x$enable_python" != "xno"],
AC_SUBST(PYTHON_VERSION)
AC_SUBST(PYTHON_CFLAGS)
AC_SUBST(PYTHON_INSTALLDIR)
+ AC_SUBST(PYTHON_EXT_SUFFIX)
])
AM_CONDITIONAL([HAVE_PYTHON],
[test "x$PYTHON" != "xno" && test
"x$PYTHON_CFLAGS" != "x" && test
"x$PYTHON_INSTALLDIR" != "x"])
diff --git a/python/Makefile.am b/python/Makefile.am
index ead52b4..034f9c7 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -36,7 +36,7 @@ libhivexmod_la_SOURCES = hivex-py.c
libhivexmod_la_CFLAGS = -Wall $(PYTHON_CFLAGS) \
-I$(top_srcdir)/lib -I$(top_builddir)/lib
libhivexmod_la_LIBADD = $(top_builddir)/lib/libhivex.la
-libhivexmod_la_LDFLAGS = -avoid-version -shared
+libhivexmod_la_LDFLAGS = -avoid-version -shared -module -shrext
$(PYTHON_EXT_SUFFIX)
TESTS_ENVIRONMENT = \
PYTHONPATH=$(builddir):$(builddir)/.libs
--
1.7.10.4
Richard W.M. Jones
2013-May-24 09:21 UTC
[Libguestfs] hivex: Improvents in building Python bindings
On Fri, May 24, 2013 at 01:31:47AM +0200, Hilko Bengen wrote:> Building against multiple versions of Python is a lot of fun as it is. > Add autoconf/automake/libtool (and possible distribution-specific > stuff) to the mix and things get really interesting: > > On Debian and Ubuntu, building against python 3.3 requires an extra > include path as documented in > <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=692387>. > > As discussed in > <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=692387>, special > version- and ABI-specific suffixes have been introduced, those are now > part of what is built using libtool.Thanks - I pushed both. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW