diff pycall.cc @ 405:478d83448b0b

Refactor Python initialization into a common function * oct-py-init.cc, oct-py-init.h: New files defining a pytave::py_init function. * __py_struct_from_dict__.cc, pycall.cc, pyeval.cc, pyexec.cc: Use it instead of initializing Python differently in each entry point. * Makefile.am (COMMON_SOURCE_FILES): Include oct-py-init.cc in the list. (PYTAVE_HEADER_FILES): Include oct-py-init.h in the list.
author Mike Miller <mtmiller@octave.org>
date Sat, 29 Apr 2017 15:43:42 -0700
parents aef165ff92b0
children 16e79a1e96b8
line wrap: on
line diff
--- a/pycall.cc	Fri Apr 28 16:21:39 2017 -0700
+++ b/pycall.cc	Sat Apr 29 15:43:42 2017 -0700
@@ -30,10 +30,9 @@
 #include <octave/oct.h>
 #include <octave/parse.h>
 
-#define PYTAVE_DO_DECLARE_SYMBOL
-#include "arrayobjectdefs.h"
 #include "exceptions.h"
 #include "oct-py-eval.h"
+#include "oct-py-init.h"
 #include "oct-py-object.h"
 #include "oct-py-util.h"
 #include "octave_to_python.h"
@@ -94,10 +93,7 @@
                                   && args(0).class_name () == "pyobject")))
     error ("pycall: FUNC must be a string or a Python reference");
 
-  Py_Initialize ();
-
-  numeric::array::set_module_and_type ("numpy", "ndarray");
-  _import_array ();
+  pytave::py_init ();
 
   try
     {