make linking python optional
authorDiane Trout <diane@caltech.edu>
Mon, 22 May 2006 22:29:20 +0000 (22:29 +0000)
committerDiane Trout <diane@caltech.edu>
Mon, 22 May 2006 22:29:20 +0000 (22:29 +0000)
I'm getting a crash when running under rosetta which i think might
be related to having linked in python. So since I'm not currently
using the embedded interpreter, lets not bother linking it in.

qui/CMakeLists.txt
qui/mussagl.cpp

index e134342d9fb73e5ae0cb10741b82be3dc991c965..580c5afeca193c8f799c5f6c712efc127bb7b9fd 100644 (file)
@@ -78,8 +78,12 @@ TARGET_LINK_LIBRARIES(mussagl
                         ${OPENGL_gl_LIBRARY}
                         ${BOOST_PROGRAM_OPTIONS_LIBRARY}
                         ${BOOST_FILESYSTEM_LIBRARY}
-                        ${BOOST_PYTHON_LIBRARY}
-                        optimized ${PYTHON_LIBRARIES}
-                        debug ${PYTHON_DEBUG_LIBRARIES}
+                      )
+IF(USE_PYTHON)
+  TARGET_LINK_LIBRARIES(mussagl
+                          ${BOOST_PYTHON_LIBRARY}
+                          optimized ${PYTHON_LIBRARIES}
+                          debug ${PYTHON_DEBUG_LIBRARIES}
                         )
+ENDIF(USE_PYTHON)
 
index 1b6dd95464f83a4ed851d23f95705e0dd79a904b..15b01b23a3799fb0a7b83d930cfbdf9cb7cad12f 100644 (file)
@@ -1,5 +1,7 @@
 #include <boost/filesystem/operations.hpp>
+#ifdef USE_PYTHON
 #include <boost/python.hpp>
+#endif
 
 using namespace boost::filesystem;
 
@@ -22,8 +24,6 @@ int main(int argc, char **argv)
 
   QApplication app(argc, argv, opts.useGUI);
   Q_INIT_RESOURCE(icons);
-  //PyImport_AppendInittab("mussa", initmussa);
-  Py_Initialize();
 
   initialize_mussa(opts, argc, argv);
 
@@ -32,7 +32,9 @@ int main(int argc, char **argv)
   }
 
   try {
+#ifdef USE_PYTHON
     if (opts.runAsPythonInterpeter) {
+      Py_Initialize();
       boost::python::object main_module((boost::python::handle<>(boost::python::borrowed(PyImport_AddModule("__main__")))));
       boost::python::object main_namespace = main_module.attr("__dict__");
 
@@ -52,7 +54,9 @@ int main(int argc, char **argv)
       int result = boost::python::extract<int>(square(3));
       std::cout << "C++ has " << result << std::endl;
       PyRun_InteractiveLoop(stdin, "mussa");
-    } else if (opts.useGUI) { 
+    } else 
+#endif /* USE_PYTHON */
+    if (opts.useGUI) { 
       MussaWindow win(opts.analysis);
       win.show();
       app.exec();
@@ -62,13 +66,16 @@ int main(int argc, char **argv)
     qFatal(e.what());
   } catch (boost::filesystem::filesystem_error e) {
     qFatal(e.what());
-  } catch (boost::python::error_already_set e) {
+  }
+#ifdef USE_PYTHON
+  catch (boost::python::error_already_set e) {
     PyErr_Print();
-  }  catch (std::runtime_error e) {
+  }
+#endif /* USE_PYTHON */
+  catch (std::runtime_error e) {
     qFatal(e.what());
   } catch (...) {
     qFatal("unrecognized exception");
   }
-  Py_Finalize();
   return 1; 
 }