diff options
author | Maxime Curioni <maxime.curioni@gmail.com> | 2008-05-27 07:29:43 +0400 |
---|---|---|
committer | Maxime Curioni <maxime.curioni@gmail.com> | 2008-05-27 07:29:43 +0400 |
commit | 4245f8160555f12139a44d4bb8c3eac7bfc5970b (patch) | |
tree | 0122f0603f078c06ca2de48a822afe9e050714dd /source/blender/freestyle/intern/system | |
parent | 373d42dbeaef014ce6d8c9d337242966d7ca8e5f (diff) |
soc-2008-mxcurioni: PythonInterpreter now properly handles its initialization (in accordance with original Freestyle code). This is achieved by creating a temporary Text structure, adding the required import and appending the necessary Python path. The text is executed using the BPY_txt_do_python_Text command.
When Freestyle is run within Blender, it should not crash; the Python interpreter should report an ImportError on _Freestyle (the SWIG wrapper).
Diffstat (limited to 'source/blender/freestyle/intern/system')
-rwxr-xr-x | source/blender/freestyle/intern/system/PythonInterpreter.h | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/source/blender/freestyle/intern/system/PythonInterpreter.h b/source/blender/freestyle/intern/system/PythonInterpreter.h index d9b563fabaa..540d0b3ddec 100755 --- a/source/blender/freestyle/intern/system/PythonInterpreter.h +++ b/source/blender/freestyle/intern/system/PythonInterpreter.h @@ -105,15 +105,22 @@ private: if (_initialized) return; - // vector<string> pathnames; - // StringUtils::getPathName(_path, "", pathnames); - // - // for (vector<string>::const_iterator it = pathnames.begin(); it != pathnames.end();++it) { - // if ( !it->empty() ) { - // cout << "Adding Python path: " << *it << endl; - // syspath_append( const_cast<char*>(it->c_str()) ); - // } - // } + vector<string> pathnames; + StringUtils::getPathName(_path, "", pathnames); + + struct Text *text = add_empty_text("initpath_test.txt"); + string cmd = "import sys\n"; + txt_insert_buf(text, const_cast<char*>(cmd.c_str())); + + for (vector<string>::const_iterator it = pathnames.begin(); it != pathnames.end();++it) { + if ( !it->empty() ) { + cout << "Adding Python path: " << *it << endl; + cmd = "sys.path.append(\"" + *it + "\")\n"; + txt_insert_buf(text, const_cast<char*>(cmd.c_str())); + } + } + + BPY_txt_do_python_Text(text); //PyRun_SimpleString("from Freestyle import *"); _initialized = true; |