1 ## numpy.m4 - Check for numpy version on a system. -*-Autoconf-*-
2 ## Copyright (C) 2013 Arnaud Gardelein.
3 ## Author: Arnaud Gardelein <arnaud@oscopy.org>
5 ## This program is free software; you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 2 of the License, or
8 ## (at your option) any later version.
10 ## This program is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ## General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program; if not, write to the Free Software
17 ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 ## As a special exception to the GNU General Public License, if you
20 ## distribute this file as part of a program that contains a
21 ## configuration script generated by Autoconf, you may include it under
22 ## the same distribution terms that you use for the rest of that program.
24 # AM_PATH_NUMPY([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
25 # ---------------------------------------------------------------------------
26 # Adds support for distributing Numpy modules and packages.
27 # Call AM_PATH_IPYTHON before using it
29 # If the MINIMUM-VERSION argument is passed, AM_PATH_NUMPY will
30 # cause an error if the version of IPYTHON installed on the system
31 # doesn't meet the requirement. MINIMUM-VERSION should consist of
32 # numbers and dots only.
34 AC_DEFUN([AM_CHECK_NUMPY],
36 AC_CACHE_CHECK([for Numpy version], [am_cv_numpy_version],
37 [am_cv_numpy_version=`$IPYTHON -c "import numpy,sys; sys.stdout.write(numpy.version.version)"`])
38 AC_SUBST([NUMPY_VERSION], [$am_cv_numpy_version])
39 AM_NUMPY_CHECK_VERSION([$IPYTHON], [$1], [$2], [m4_default([$3], [AC_MSG_ERROR([Numpy version > $1 needed])])])
42 # AM_NUMPY_CHECK_VERSION(PROG, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
43 # ---------------------------------------------------------------------------
44 # Run ACTION-IF-TRUE if the IPYTHON interpreter PROG has version >= VERSION.
45 # Run ACTION-IF-FALSE otherwise.
47 AC_DEFUN([AM_NUMPY_CHECK_VERSION],
48 [prog="import sys, numpy;minver = list(map(int, '$2'.split('.'))) + [[0, 0, 0]];ver = list(map(int, numpy.version.version[[0:3]].split('.'))) + [[0, 0, 0]];minverhex = sum([[minver[i]<<((4-i)*8) for i in range(0, 4)]]);verhex = sum([[ver[i]<<((4-i)*8) for i in range(0, 4)]]);sys.stdout.write('1' if verhex < minverhex else '0');"
49 AS_IF([AM_RUN_LOG_IPYTHON([$1 -c "$prog"])], [$3], [$4])])