changeset 15:1b8ccabfa296 lp-trunk

Use octave_main() to initiate Octave. Better checking for Python dependencies.
author David Grundberg <c04dgg@cs.umu.se>
date Thu, 23 Oct 2008 20:47:12 +0200
parents 1427e0870812 (current diff) 56254a2e18e3 (diff)
children ae09a25b1206 1a2c103d1789
files
diffstat 3 files changed, 39 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Oct 20 11:16:30 2008 +0200
+++ b/ChangeLog	Thu Oct 23 20:47:12 2008 +0200
@@ -1,3 +1,11 @@
+2008-10-23  David Grundberg  <individ@acc.umu.se>
+
+	* pytave.cc: Use octave_main() to initialize Octave. Introduces
+	readline history clashes with interactive Python interpreter.
+	* configure.ac: Better testing for Python dependencies.
+	* configure.ac: Renamed my_ to pytave_
+	* configure.ac: Fixed whitespace.
+
 2008-10-20  David Grundberg  <individ@acc.umu.se>
 
 	* Makefile.am: added test/exceptions.py to extra dist.
--- a/configure.ac	Mon Oct 20 11:16:30 2008 +0200
+++ b/configure.ac	Thu Oct 23 20:47:12 2008 +0200
@@ -22,10 +22,9 @@
 AC_ARG_WITH([octave],
             [AS_HELP_STRING([--with-octave],
                             [Optionally set Octave package to use.
-							@<:@default=check@:>@])],
+                            @<:@default=check@:>@])],
             [with_octave=$withval],
             [with_octave=check])
-          
 AS_IF([test "x$with_octave" == xno],
 [
    AC_MSG_FAILURE([--without-octave was given but Octave required])
@@ -48,8 +47,7 @@
 [
    AC_MSG_WARN([Could not find octave-config.])
 ],
-[ 
-
+[
    PYTAVE_OCTAVE_RPATH=`$octaveconfig -p OCTLIBDIR`
    PYTAVE_OCTAVE_INCLUDE_PATH=`$octaveconfig -p OCTINCLUDEDIR`
    AC_MSG_RESULT([  results of the Octave check:])
@@ -67,15 +65,17 @@
    old_libs="$LIBS"
    LIBS="-loctave -lcruft -loctinterp $LIBS"
 
-   AC_CACHE_CHECK([whether linking to Octave library works], [my_cv_lib_octave],
+   AC_CACHE_CHECK([whether linking to Octave library works], [pytave_cv_lib_octave],
    [
-      my_cv_lib_octave=no
-	  AC_LANG_ASSERT(C++)
-	  AC_LINK_IFELSE(AC_LANG_PROGRAM([[#include <octave/oct.h>
-									   #include <octave/Matrix.h> ]],
-									 [[MatrixType()]]),
-						   [my_cv_lib_octave=yes],
-						   [my_cv_lib_octave=no])
+      pytave_cv_lib_octave=no
+      AC_LANG_ASSERT(C++)
+      AC_LINK_IFELSE(
+         AC_LANG_PROGRAM(
+            [[#include <octave/oct.h>
+              #include <octave/Matrix.h> ]],
+            [[MatrixType()]]),
+         [pytave_cv_lib_octave=yes],
+         [pytave_cv_lib_octave=no])
    ])
 
 
@@ -88,21 +88,25 @@
 
 # Look for boost::python
 AX_PYTHON()
+old_libs="$LIBS"
+AS_IF([test "x$PYTHON_LIB" != "x"],[
+LIBS="-l$PYTHON_LIB $LIBS"
+],[])
 AX_BOOST_PYTHON()
+LIBS="$old_libs"
 
 # Now check the two vital libs, if they have problems, halt.
 pytave_fatal_errors=no
 
-AS_IF(test "x$my_cv_lib_octave" != "xyes",
+AS_IF(test "x$pytave_cv_lib_octave" != "xyes",
 [
    AC_MSG_WARN([Linking to Octave failed.])
    pytave_fatal_errors=yes
 ], [])
 
-# XXX: hohoho, this is ugly.
-AS_IF(test "x$ac_cv_boost_python" != "xyes",
+AS_IF(test "x$BOOST_PYTHON_LIB" == "x",
 [
-   AC_MSG_WARN([Boost::Python test failed.])
+   AC_MSG_WARN([Cannot find Boost::Python lib.])
    pytave_fatal_errors=yes
 ], [])
 
@@ -125,7 +129,6 @@
 AC_PROG_MAKE_SET
 
 # Checks for libraries.
-		  
 
 # Checks for header files.
 
@@ -141,7 +144,7 @@
    PYTAVE_MODULE_INSTALL_PATH=/../invalidpath,
 ],
 [
-   PYTAVE_MODULE_INSTALL_PATH=${prefix}  
+   PYTAVE_MODULE_INSTALL_PATH=${prefix}
 ])
 
 # Substitutes for the Makefile/Jamfile
--- a/pytave.cc	Mon Oct 20 11:16:30 2008 +0200
+++ b/pytave.cc	Thu Oct 23 20:47:12 2008 +0200
@@ -24,21 +24,14 @@
 
 #undef HAVE_STAT /* Both boost.python and octave define HAVE_STAT... */
 #include <octave/oct.h>
+#include <octave/octave.h>
+#include <octave/ov.h>
 #include <octave/parse.h>
-#include <octave/load-path.h>
-#include <octave/file-io.h>
-#include <octave/ops.h>
 
 #include <iostream>
 #include <sstream>
-
 #include <sys/types.h>
 
-#include <octave/Matrix.h>
-#include <octave/ov.h>
-#include <octave/builtins.h>
-#include <octave/defaults.h>
-
 #include "pytavedefs.h"
 
 #include "exceptions.h"
@@ -59,27 +52,16 @@
          return;
       }
 
-      set_liboctave_error_handler(error);
-      set_liboctave_warning_handler(warning);
-      set_liboctave_warning_with_id_handler(warning_with_id);
-
-      // New in Octave 3
-      initialize_default_warning_state();
+      // Initialize Octave.
+      // Also print Octave startup message.
+      char* argv[] = {"octave", "--no-line-editing", "--no-history", NULL};
+      octave_main(3, argv, 1);
 
-      install_defaults();
-      initialize_file_io();
-      initialize_symbol_tables();
-      install_types();
-
-      install_ops();
+      // Initialize Python Numeric Array
 
-      install_builtins();
-
-      // true argument new in Octave 3
-      load_path::initialize(true); // or use false to set empty path
-
-      // initialize python numeric array
-      import_array();
+      // This is actually a macro that becomes a block expression. If an error
+      // occurs, e.g. Numeric Array not installed, an exception is set.
+      import_array()
    }
 
    boost::python::tuple get_exceptions() {