Browse Source

python: detect availability of python numpy package

Nathalie Furmento 4 years ago
parent
commit
447beea936
3 changed files with 12 additions and 1 deletions
  1. 9 0
      configure.ac
  2. 2 0
      include/starpu_config.h.in
  3. 1 1
      starpupy/src/setup.py.in

+ 9 - 0
configure.ac

@@ -3388,6 +3388,15 @@ then
 	if test "$joblib_avail" = "no" ; then
 		AC_MSG_ERROR([python3 module joblib missing, cannot build StarPU python interface])
 	fi
+	AC_MSG_CHECKING(for python3 module numpy)
+	AC_PYTHON_MODULE(numpy,[numpy_avail=yes],[numpy_avail=no])
+	AC_MSG_RESULT($numpy_avail)
+	PYTHON_NUMPY_CFLAGS=""
+	if test "$numpy_avail" = "yes" ; then
+	   	AC_DEFINE(STARPU_PYTHON_HAVE_NUMPY, [1], [Python3 numpy package available])
+		PYTHON_NUMPY_CFLAGS="`$PYTHON -c "import numpy ; print(numpy.get_include())"`"
+	fi
+	AC_SUBST(PYTHON_NUMPY_CFLAGS)
 fi
 AM_CONDITIONAL(STARPU_BUILD_STARPUPY, [test x$starpupy_support = xyes])
 

+ 2 - 0
include/starpu_config.h.in

@@ -317,4 +317,6 @@ typedef ssize_t starpu_ssize_t;
 #undef STARPU_HAVE_STATEMENT_EXPRESSIONS
 #undef STARPU_PERF_MODEL_DIR
 
+#undef STARPU_PYTHON_HAVE_NUMPY
+
 #endif

+ 1 - 1
starpupy/src/setup.py.in

@@ -16,7 +16,7 @@
 from distutils.core import setup, Extension
 
 starpupy = Extension('starpu.starpupy',
-                     include_dirs = ['@STARPU_SRC_DIR@/include', '@STARPU_BUILD_DIR@/include'],
+                     include_dirs = ['@STARPU_SRC_DIR@/include', '@STARPU_BUILD_DIR@/include', '@PYTHON_NUMPY_CFLAGS@'],
                      libraries = ['starpu-@STARPU_EFFECTIVE_VERSION@'],
                      library_dirs = ['@STARPU_BUILD_DIR@/src/.libs'],
 	             sources = ['starpu/starpu_task_wrapper.c'])