Commit 852b4e293cd66b7112c785786e27c63ece1ed36d

Authored by knodlseder
1 parent a92de4ae

use distutils to search for Python.h headers

Showing 1 changed file with 36 additions and 13 deletions
configure.ac
... ... @@ -138,23 +138,46 @@ AM_PATH_PYTHON([2.2],
138 138 [AC_MSG_WARN([Python >= 2.2 not found. Python >= 2.2 is required to build python binding. Python can be obtained from http://www.python.org])])
139 139 if test "x$has_python" = "xyes"; then
140 140  
141   - # Determine include path for python
142   - AC_PATH_PROG(PY_INCLUDE, python)
143   - PY_INCLUDE=`echo $PY_INCLUDE | sed -e "s/bin/include/"`
144   - PY_INCLUDE="$PY_INCLUDE$PYTHON_VERSION"
  141 + # Do we have distutils?
  142 + AC_MSG_CHECKING([for the distutils Python package])
  143 + ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`
  144 + if test -z "$ac_distutils_result"; then
  145 + AC_MSG_RESULT([yes])
  146 + else
  147 + AC_MSG_RESULT([no])
  148 + fi
  149 +
  150 + # If we have distutils then get python path from distutils ...
  151 + if test -z "$ac_distutils_result"; then
  152 + AC_MSG_CHECKING([for Python include path])
  153 + python_path=`$PYTHON -c "import distutils.sysconfig; \
  154 + print distutils.sysconfig.get_python_inc();"`
  155 + if test -n "${python_path}"; then
  156 + python_path="-I$python_path"
  157 + has_python_h="yes"
  158 + fi
  159 + PYTHON_CPPFLAGS=$python_path
  160 + CPPFLAGS="${CPPFLAGS} ${python_path}"
  161 + AC_MSG_RESULT([$python_path])
  162 + AC_SUBST([PYTHON_CPPFLAGS])
  163 +
  164 + # ... otherwise check for includes relative to exectuable (obsolete?)
  165 + else
  166 +
  167 + # Determine include path for python
  168 + AC_PATH_PROG(PY_INCLUDE, python)
  169 + PY_INCLUDE=`echo $PY_INCLUDE | sed -e "s/bin/include/"`
  170 + PY_INCLUDE="$PY_INCLUDE$PYTHON_VERSION"
145 171  
146   - # Check if we have Python.h
147   - AC_CHECK_HEADERS($PY_INCLUDE/Python.h, [has_python_h="yes"], [has_python_h="no"])
  172 + # Check if we have Python.h
  173 + AC_CHECK_HEADERS($PY_INCLUDE/Python.h, [has_python_h="yes"], [has_python_h="no"])
148 174  
149   - # Mac OS X kluge: if test before was unsuccessful then check for headers in /usr/include
150   - if test "x$has_python_h" = "xno"; then
151   - AC_CHECK_HEADERS("/usr/include/python$PYTHON_VERSION/Python.h", [has_python_h="yes"], [has_python_h="no"])
  175 + # Signal any problem
  176 + if test "x$has_python_h" = "xno"; then
  177 + AC_MSG_WARN([No Python header file "$PY_INCLUDE/Python.h" found. Please install appropriate Python development package.])
  178 + fi
152 179 fi
153 180  
154   - # Signal any problem
155   - if test "x$has_python_h" = "xno"; then
156   - AC_MSG_WARN([No Python header file "$PY_INCLUDE/Python.h" found. Please install appropriate Python development package.])
157   - fi
158 181 fi
159 182  
160 183 # Do we have swig?
... ...