diff options
author | Maxime Curioni <maxime.curioni@gmail.com> | 2008-05-26 20:19:30 +0400 |
---|---|---|
committer | Maxime Curioni <maxime.curioni@gmail.com> | 2008-05-26 20:19:30 +0400 |
commit | fc8cd192a3a22322f6127345dc14f8463b35ee1f (patch) | |
tree | 4c1f8a726edc49264b666d1405673a087e014647 /source/blender/freestyle/intern/system/PythonInterpreter.h | |
parent | 59df5a23b45675661135fdf4ce883998af2b5675 (diff) |
soc-2008-mxcurioni: Freestyle compiles but crashes at runtime because of the Python environment.
I analyzed the crash with gdb and PyImport_AddModule ("__main__") in Python/import.c:320 seems responsible for the crash: apparently, "__main__" is not found and causes the error "No such file or directory".
I have to figure out what's wrong with the current configuration, especially whether Freestyle's PythonInterpreter can be used as is. I am going to see whether it's just quicker to use Blender's functions.
Diffstat (limited to 'source/blender/freestyle/intern/system/PythonInterpreter.h')
-rwxr-xr-x | source/blender/freestyle/intern/system/PythonInterpreter.h | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/source/blender/freestyle/intern/system/PythonInterpreter.h b/source/blender/freestyle/intern/system/PythonInterpreter.h index f9a573ffb86..b8eaa4a8a3c 100755 --- a/source/blender/freestyle/intern/system/PythonInterpreter.h +++ b/source/blender/freestyle/intern/system/PythonInterpreter.h @@ -41,11 +41,17 @@ class LIB_SYSTEM_EXPORT PythonInterpreter : public Interpreter PythonInterpreter() { _language = "Python"; - Py_Initialize(); + //Py_Initialize(); + + cout << "Freestyle Python Init: " << endl; + cout << "- is init : " << Py_IsInitialized() << endl; + cout << "- prog path : " << Py_GetProgramFullPath() << endl; + cout << "- mod path : " << Py_GetPath() << endl; + cout << "- version : " << Py_GetVersion() << endl; } virtual ~PythonInterpreter() { - Py_Finalize(); + //Py_Finalize(); } int interpretCmd(const string& cmd) { @@ -88,19 +94,19 @@ private: if (_initialized) return; PyRun_SimpleString("import sys"); - vector<string> pathnames; - StringUtils::getPathName(_path, "", pathnames); - string cmd; - char* c_cmd; - for (vector<string>::const_iterator it = pathnames.begin(); + vector<string> pathnames; + StringUtils::getPathName(_path, "", pathnames); + string cmd; + char* c_cmd; + for (vector<string>::const_iterator it = pathnames.begin(); it != pathnames.end(); ++it) { - cmd = "sys.path.append(\"" + *it + "\")"; - c_cmd = strdup(cmd.c_str()); - PyRun_SimpleString(c_cmd); - free(c_cmd); - } - // PyRun_SimpleString("from Freestyle import *"); + cmd = "sys.path.append(\"" + *it + "\")"; + c_cmd = strdup(cmd.c_str()); + PyRun_SimpleString(c_cmd); + free(c_cmd); + } + PyRun_SimpleString("from Freestyle import *"); _initialized = true; } |