From b9ed9d5a4645971e0e2153558d8a46cef00a20d5 Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Thu, 28 Mar 2013 16:33:42 -0400 Subject: [PATCH] use python-config if it is present to get Python include path --- NEWS | 4 ++++ configure.ac | 14 +++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 67f4e9c..b5aad90 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,10 @@ NLopt 2.4 * Fix swig dir for VPATH builds, thanks to Sandro Vitenti for the bug report. +* Use python-config program in the configure script to find the include + directories for Python, if possible (may be overridden by PYTHON_CONFIG + environment variable). + * Bugfix in copy constructor for C++ and Python interfaces. NLopt 2.3.1 (16 September 2012) diff --git a/configure.ac b/configure.ac index 69247c2..11e112c 100644 --- a/configure.ac +++ b/configure.ac @@ -162,10 +162,18 @@ else dnl Python: AM_PATH_PYTHON([],[have_python=yes],[have_python=no]) if test $have_python = yes; then - AC_MSG_CHECKING([for Python include directory]) - pinc=`echo "import distutils.sysconfig; print distutils.sysconfig.get_python_inc()" | $PYTHON - 2>/dev/null` + AC_ARG_VAR([PYTHON_CONFIG], [python-config program]) + AC_PATH_PROGS([PYTHON_CONFIG], [python$PYTHON_VERSION-config python-config], + [unknown], [`dirname $PYTHON`:$PATH]) + AC_MSG_CHECKING([for Python include flags]) + if test "x$PYTHON_CONFIG" = "xunknown"; then + pinc=-I`echo "import distutils.sysconfig; print distutils.sysconfig.get_python_inc()" | $PYTHON - 2>/dev/null` + test "x$pinc" = "x-I" && pinc="" + else + pinc=`$PYTHON_CONFIG --includes 2>/dev/null` + fi AC_MSG_RESULT([${pinc:-unknown}]) - test -n "$pinc" && PYTHON_INCLUDES="-I$pinc" + PYTHON_INCLUDES="$pinc" save_CPPFLAGS=$CPPFLAGS CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES" AC_CHECK_HEADER([Python.h], [], [AC_MSG_WARN([disabling Python wrappers]) -- 2.30.2