Mercurial > pytave
changeset 90:935d69473ebd
Configuration changes.
author | David Grundberg <individ@acc.umu.se> |
---|---|
date | Sat, 26 Sep 2009 20:19:23 +0200 |
parents | 2e8b52a5e1b1 (current diff) 82459c7db185 (diff) |
children | 9c35b62f9eaf |
files | ChangeLog setup.py.in |
diffstat | 9 files changed, 321 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Mon Sep 21 11:03:02 2009 +0200 +++ b/ChangeLog Sat Sep 26 20:19:23 2009 +0200 @@ -1,3 +1,26 @@ +2009-09-26 David Grundberg <individ@acc.umu.se> + + * configure.ac: Make NumPy default. Replace --enable flags with + --with-type flags. Rework output. + * m4/ax_python_numeric.m4 (AX_PYTHON_NUMERIC): Check for Numeric + extentions for Python. + +2009-09-26 David Grundberg <individ@acc.umu.se> + + * m4/ax_python_numpy.m4 (AX_PYTHON_NUMPY): Restore CPPFLAGS. + +2009-09-26 David Grundberg <individ@acc.umu.se> + + * configure.ac: Look for NumPy. List which dependencies that are + missing. + * pytave.cc (init): One-line comment about NumPy. + * m4/ax_python_numpy.m4: New file. + * m4/ax_octave.m4: Send output variable by name. + * Makefile.am (_pytave_la_CPPFLAGS): Substitute NumPy include + directory from configuration. + * setup.py.in: Ditto. + * Jamfile.in: Add warning against using bjam. + 2009-09-21 Jaroslav Hajek <highegg@gmail.com> * python_to_octave.cc (copy_pyarrobj_to_octarray_boot,
--- a/Jamfile.in Mon Sep 21 11:03:02 2009 +0200 +++ b/Jamfile.in Sat Sep 26 20:19:23 2009 +0200 @@ -1,12 +1,15 @@ # @configure_input@ +# Building with bjam is no longer supported - this script probably +# does not work. + project py : requirements <library>/usr/lib/lib@BOOST_PYTHON_LIB@.so <library>@JAM_LIBOCTAVE@ <library>@JAM_LIBCRUFT@ <library>@JAM_LIBOCTINTERP@ -# <include>@PYTHON_INCLUDE_DIR@ +# <include>@PYTHON_INCLUDE_DIR@ # FIXME <include>@OCTAVE_INCLUDEDIR@ <include>@abs_srcdir@ <include>@abs_builddir@
--- a/Makefile.am Mon Sep 21 11:03:02 2009 +0200 +++ b/Makefile.am Sat Sep 26 20:19:23 2009 +0200 @@ -4,7 +4,7 @@ package/__init__.py package/pytave.py EXTRA_libdir = @PYTAVE_MODULE_INSTALL_PATH@ -_pytave_la_CPPFLAGS = @OCTAVE_CPPFLAGS@ @PYTHON_CPPFLAGS@ +_pytave_la_CPPFLAGS = @OCTAVE_CPPFLAGS@ @PYTHON_CPPFLAGS@ -I@NUMPY_INCLUDEDIR@ # Having -module in LDFLAGS lets us use a non-standard library name # (e.g. _pytave instead of libpytave)
--- a/configure.ac Mon Sep 21 11:03:02 2009 +0200 +++ b/configure.ac Sat Sep 26 20:19:23 2009 +0200 @@ -17,23 +17,61 @@ AC_PRESERVE_HELP_ORDER -AC_ARG_ENABLE(numpy, - [AS_HELP_STRING([--enable-numpy], +AC_ARG_WITH(numpy, + [AS_HELP_STRING([--with-numpy], [use NumPy module (experimental) - @<:@default=no@:>@])], + @<:@default=yes@:>@])], [pytave_enable_numpy="$enableval"], - [pytave_enable_numpy=no]) dnl TODO: Check? - -if test "$pytave_enable_numpy" == "yes" ; then - AC_DEFINE([HAVE_NUMPY], 1, [Define if using NumPy]) -fi + [pytave_enable_numpy=yes]) -pytave_libs_ok= +AC_ARG_WITH(numeric, + [AS_HELP_STRING([--with-numeric], + [use legacy Numeric module. NumPy must be disabled. + @<:@default=no@:>@])], + [pytave_enable_numeric="$enableval"], + [pytave_enable_numeric=no]) -AX_OCTAVE([], [], [pytave_libs_ok=no]) +dnl Define a convenience m4 macro for appending to pytave_missing_libs +define(addmissing,pytave_missing_libs="$1 +$pytave_missing_libs") +pytave_missing_libs= + +# Find Octave +AX_OCTAVE([OCTAVE_CONFIG], [], [addmissing([Octave development files])]) # Pick a Python library to use -AX_PYTHON_DEVEL([], [], [pytave_libs_ok=no]) +AX_PYTHON_DEVEL([], [], [addmissing([Python development files])]) + +# Check for bad arguments. +AS_IF(test "x$pytave_enable_numpy" == "xyes" -a "x$pytave_enable_numeric" == "xyes" -o dnl +"x$pytave_enable_numpy" == "xno" -a "x$pytave_enable_numeric" == "xno", +[ + AC_ERROR([NumPy or Numeric: select one.]) +]) + +# Select Python matrix interface, prefer numpy. +AS_IF(test "x$pytave_enable_numpy" == "xno", +[ + pytave_matrix_interface="numeric" +], +[ + pytave_matrix_interface="numpy" +]) + +# Look for selected matrix interface +AS_IF(test "$pytave_matrix_interace" == "numpy", +[ + AX_PYTHON_NUMPY( + [ + AC_DEFINE([HAVE_NUMPY], 1, [Define if using NumPy]) + ], + [ + addmissing([NumPy development files]) + ]) +], +[ + AX_PYTHON_NUMERIC([], [addmissing([Numeric development files])]) +]) # Look for boost::python pytave_old_libs="$LIBS" @@ -43,23 +81,12 @@ LDFLAGS="$LDFLAGS $PYTHON_LDFLAGS" CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS" -AX_BOOST_PYTHON([], [pytave_libs_ok=no]) +AX_BOOST_PYTHON([], [addmissing([Boost Python development files])]) LIBS="$pytave_old_libs" LDFLAGS="$pytave_old_ldflags" CPPFLAGS="$pytave_old_cppflags" -# Now check the libs, if they have problems, halt. -AS_IF(test -n "$pytave_libs_ok", -[ - AC_MSG_ERROR([ -======================================================================== -One or more library dependencies could not be resolved. - -Configuration failed. Halt. -========================================================================]) -]) - # Do some more initializations AM_INIT_AUTOMAKE() @@ -107,7 +134,6 @@ PYTAVE_OCTAVE_RPATH="$OCTAVE_LIBRARYDIR" AC_SUBST(PYTAVE_OCTAVE_RPATH) AC_SUBST(PYTAVE_MODULE_INSTALL_PATH) -AC_SUBST(pytave_enable_numpy) # Substitutes for the Jamfile. XXX: Replace lib*.so with OS independent name. AC_SUBST(JAM_LIBOCTAVE, $OCTAVE_LIBRARYDIR/liboctave.so) @@ -117,22 +143,38 @@ # setup.py AC_SUBST(PYTHON) +msg="One or more library dependencies could not be resolved. + +Missing dependencies: +$pytave_missing_libs +Configuration failed. Halt." + +AS_IF(test -z "$pytave_missing_libs", +[ # Substitute in these files, copy project-root.jam to VPATH too AC_OUTPUT([Makefile Jamfile setup.py project-root.jam]) chmod u+x "setup.py" +msg='Pytave is configured with the following setup' +]) AC_MSG_NOTICE([ ======================================================================== -Pytave now configured with the following setup: +$msg Dependencies Octave ............. $OCTAVE_INCLUDEDIR Python ............. $PYTHON_CPPFLAGS executable ....... $PYTHON + Python boost ....... $BOOST_PYTHON_LIB Features - NumPy .............. $pytave_enable_numpy + matrix interface ... $pytave_matrix_interface uselocale .......... $pytave_have_uselocale ========================================================================]) + +AS_IF(test -n "$pytave_missing_libs", +[ + AC_MSG_ERROR([[Configuration failure. Halt.]]) +]) \ No newline at end of file
--- a/m4/ax_octave.m4 Mon Sep 21 11:03:02 2009 +0200 +++ b/m4/ax_octave.m4 Sat Sep 26 20:19:23 2009 +0200 @@ -77,7 +77,7 @@ OCTAVE_CPPFLAGS= OCTAVE_INCLUDEDIR= OCTAVE_LIBRARYDIR= - ax_octave_config="$1" + ax_octave_config="[$]$1" ax_octave_ok= AC_MSG_CHECKING([for octave-config filename])
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m4/ax_python_numeric.m4 Sat Sep 26 20:19:23 2009 +0200 @@ -0,0 +1,101 @@ +# =========================================================================== +# +# =========================================================================== +# +# SYNOPSIS +# +# AX_PYTHON_NUMERIC([ACTION_IF_FOUND], [ACTION_IF_NOT_FOUND]) +# +# DESCRIPTION +# +# +# LAST MODIFICATION +# +# 2009-08-24 +# +# COPYING +# +# Copyright (c) 2009 David Grundberg +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see <http://www.gnu.org/licenses/>. +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Macro Archive. When you make and +# distribute a modified version of the Autoconf Macro, you may extend this +# special exception to the GPL to apply to your modified version as well. + +AC_DEFUN([AX_PYTHON_NUMERIC],[ + AC_MSG_CHECKING([for python]) + AS_IF([test -z "$PYTHON"], [ + AC_MSG_RESULT([unknown]) + ],[ + AC_MSG_RESULT([$PYTHON]) + ]) + + AS_IF([true], [ + + AC_CACHE_CHECK([whether linking to numeric library works], [ax_python_numeric_cv_check], + [ + ax_python_numeric_cv_check=no + + AC_LANG_PUSH([C++]) + + ax_python_numeric_cppflags="$CPPFLAGS" + ax_python_numeric_ldflags="$LDFLAGS" + CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS" + LDFLAGS="$LDFLAGS $PYTHON_LDFLAGS" + + AC_LANG_ASSERT(C++) + AC_LINK_IFELSE( + AC_LANG_PROGRAM( + [[ +#define PY_ARRAY_UNIQUE_SYMBOL my_array_symbol +#include <Python.h> +#include <Numeric/arrayobject.h> +typedef int npy_intp; +]], + [[ &PyArray_FromDims; ]]), + [ax_python_numeric_cv_check=yes], + [ax_python_numeric_cv_check=no]) + CPPFLAGS="$ax_python_numeric_cppflags" + LDFLAGS="$ax_python_numeric_ldflags" + + AC_LANG_POP([C++]) + ]) + ]) + + AS_IF([test "x$ax_python_numeric_cv_check" != "xyes"], [ + AC_MSG_WARN([[ +======================================================================== +Can not link with Numeric. + +Make sure the Numeric development package is installed. +========================================================================]]) + ]) + + # Execute ACTION_IF_FOUND or ACTION_IF_NOT_FOUND + if test "x$ax_python_numeric_cv_check" == "xyes" ; then + m4_ifvaln([$1],[$1],[:])dnl + m4_ifvaln([$2],[else $2])dnl + fi + +])
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m4/ax_python_numpy.m4 Sat Sep 26 20:19:23 2009 +0200 @@ -0,0 +1,114 @@ +# =========================================================================== +# +# =========================================================================== +# +# SYNOPSIS +# +# AX_PYTHON_NUMPY([ACTION_IF_FOUND], [ACTION_IF_NOT_FOUND]) +# +# COPYING +# +# Copyright (c) 2009 David Grundberg +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see <http://www.gnu.org/licenses/>. +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Macro Archive. When you make and +# distribute a modified version of the Autoconf Macro, you may extend this +# special exception to the GPL to apply to your modified version as well. + +AC_DEFUN([AX_PYTHON_NUMPY],[ + NUMPY_INCLUDEDIR= + + AC_MSG_CHECKING([for python]) + AS_IF([test -z "$PYTHON"], [ + AC_MSG_RESULT([unknown]) + ],[ + AC_MSG_RESULT([$PYTHON]) + ]) + + AC_MSG_CHECKING([for numpy includedir]) + AS_IF([test -z "$PYTHON"], [ + AC_MSG_RESULT([no (python unknown)]) + ],[ + NUMPY_INCLUDEDIR=`$PYTHON -c ' +try: + from numpy import get_include + print get_include() +except: + pass +'` + AC_MSG_RESULT([$NUMPY_INCLUDEDIR]) + ]) + + AS_IF([test -n "$NUMPY_INCLUDEDIR"], [ + + AC_CACHE_CHECK([whether linking to numpy library works], [ax_python_numpy_cv_check], + [ + ax_python_numpy_cv_check=no + + AC_LANG_PUSH([C++]) + + ax_python_numpy_cppflags="$CPPFLAGS" + ax_python_numpy_ldflags="$LDFLAGS" + CPPFLAGS="$CPPFLAGS -I$NUMPY_INCLUDEDIR $PYTHON_CPPFLAGS" + LDFLAGS="$LDFLAGS $PYTHON_LDFLAGS" + + AC_LANG_ASSERT(C++) + AC_LINK_IFELSE( + AC_LANG_PROGRAM( + [[ +#define PY_ARRAY_UNIQUE_SYMBOL my_array_symbol +#include <Python.h> +#include <numpy/oldnumeric.h> +#include <numpy/old_defines.h> +]], + [[ &PyArray_FromDims; ]]), + [ax_python_numpy_cv_check=yes], + [ax_python_numpy_cv_check=no]) + CPPFLAGS="$ax_python_numpy_cppflags" + LDFLAGS="$ax_python_numpy_ldflags" + + AC_LANG_POP([C++]) + ]) + ]) + + AS_IF([test "x$ax_python_numpy_cv_check" != "xyes"], [ + NUMPY_INCLUDEDIR= + + AC_MSG_WARN([[ +======================================================================== +Can not link with Numpy. + +Make sure the Numpy development package is installed. +========================================================================]]) + ]) + + AC_SUBST([NUMPY_INCLUDEDIR]) + + # Execute ACTION_IF_FOUND or ACTION_IF_NOT_FOUND + if test "x$ax_python_numpy_cv_check" == "xyes" ; then + m4_ifvaln([$1],[$1],[:])dnl + m4_ifvaln([$2],[else $2])dnl + fi + +])
--- a/pytave.cc Mon Sep 21 11:03:02 2009 +0200 +++ b/pytave.cc Sat Sep 26 20:19:23 2009 +0200 @@ -103,6 +103,7 @@ // occurs, e.g. Numeric Array not installed, an exception is set. import_array() #ifdef HAVE_NUMPY + // Let boost use numpy numeric::array::set_module_and_type ("numpy", "ndarray"); #endif }
--- a/setup.py.in Mon Sep 21 11:03:02 2009 +0200 +++ b/setup.py.in Sat Sep 26 20:19:23 2009 +0200 @@ -2,18 +2,7 @@ # -*- coding: utf-8; c-basic-offset: 3; indent-tabs-mode: nil; tab-width: 3; -*- # @configure_input@ -from distutils.core import setup, Extension, DistutilsModuleError - -include_dirs = ['@OCTAVE_INCLUDEDIR@', '@abs_builddir@', '@srcdir@'] # Python always included. - -# check for numpy. If it exists, define the path. - -if '@pytave_enable_numpy@' == 'yes': - try: - from numpy import get_include - include_dirs.append(get_include()) - except ImportError: - raise DistutilsModuleError("could not found numpy") +from distutils.core import setup, Extension setup( name = 'pytave', @@ -40,10 +29,15 @@ '@srcdir@/python_to_octave.h' ], + # Python always included, so don't bother. # TODO: Check whether paths work on Windows or not. # The file separator might be wrong. (Must be / in setup.cfg) - include_dirs = include_dirs, - define_macros = [('HAVE_CONFIG_H', '1')], + include_dirs = ['@OCTAVE_INCLUDEDIR@', + '@NUMPY_INCLUDEDIR@', + '@abs_builddir@', + '@srcdir@', + ], + define_macros = [('HAVE_CONFIG_H', '1')], library_dirs = ['@OCTAVE_LIBRARYDIR@'], runtime_library_dirs = ['@PYTAVE_OCTAVE_RPATH@'], libraries = ['octinterp', 'octave', 'cruft', '@BOOST_PYTHON_LIB@']