Page 1 of 1

location of numpy include files

Posted: Mon Dec 06, 2010 7:05 pm
by don.fanucci
Hi!

In many linux distributions there is a soft link to the numpy-include in the Python include directory (the latter is given by distutils.sysconfig.get_python_inc() or by the python-config command line tool).
However, this soft link does not always exist.
E.g. on our compute clusters we provide several different versions of numpy using a modules system, and to get the location of the numpy include files one could e.g. get it through numpy.get_include().

Just as an illustration, I created a simple patch witch adds both include locations to PYTHON_CPPFLAGS (I'll try to attach it to this thread)

/Mattias

Re: location of numpy include files

Posted: Mon Dec 06, 2010 7:10 pm
by don.fanucci
(Hmm, the webform says "The extension patch is not allowed.", .txt doesn't seem to work either. Nevermind, I'll put it in the message instead)
So, this is not a suggested implementation, it is just to illustrate what I mean

Code: Select all

diff --git a/configure.ac b/configure.ac
index 35deee4..468947e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -500,19 +500,21 @@ ABI_MSG_SECTION([Python support])
 
 # Look for programs
 AC_CHECK_PROGS(PYTHON,[python python2.6 python2.5 python2.4])
-AC_CHECK_PROGS(PYTHON_CONFIG,[python-config python2.6-config python2.5-config python2.4-config])
-
-# Check name consistency
-if test "${PYTHON}" != "" -a "${PYTHON_CONFIG}" != ""; then
-  if test "${PYTHON}" != "`echo ${PYTHON_CONFIG} | sed -e 's/-config//'`"; then
-    AC_MSG_WARN([Python interpeter and configurator have different names])
-  fi
-fi
 
 # Get Python preprocessing options
 AC_MSG_CHECKING([for Python CPPFLAGS])
-if test "${PYTHON_CONFIG}" != "" -a "${PYTHON_CPPFLAGS}" = ""; then
-  PYTHON_CPPFLAGS=`${PYTHON_CONFIG} --includes`
+if test "${PYTHON}" != "" -a "${PYTHON_CPPFLAGS}" = ""; then
+  PYTHON_CPPFLAGS=`${PYTHON} -c "\
+try:
+    import distutils.sysconfig
+    print '-I' + distutils.sysconfig.get_python_inc(),
+except:
+    pass
+try:
+    import numpy
+    print '-I' + numpy.get_include(),
+except:
+    pass"`
 fi
 AC_MSG_RESULT([${PYTHON_CPPFLAGS}])

Re: location of numpy include files

Posted: Sun Jan 09, 2011 1:53 pm
by mverstra
Hi Don,

thanks for the suggestion. I will bring it to the attention of the authorities before 6.6 is frozen (hopefully).

Cheers
Matthieu

Re: location of numpy include files  [SOLVED]

Posted: Sun Jan 09, 2011 7:31 pm
by gonze
OK, included in forthcoming v6.6.0 and later !
Xavier