[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14992] branches/soc-2008-mxcurioni/source /blender/freestyle: soc-2008-mxcurioni: PythonInterpreter now properly handles its initialization ( in accordance with original Freestyle code).

Maxime Curioni maxime.curioni at gmail.com
Tue May 27 05:29:43 CEST 2008


Revision: 14992
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14992
Author:   mxcurioni
Date:     2008-05-27 05:29:43 +0200 (Tue, 27 May 2008)

Log Message:
-----------
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).

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/source/blender/freestyle/SConscript
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/system/PythonInterpreter.h

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/SConscript
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/SConscript	2008-05-27 01:30:17 UTC (rev 14991)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/SConscript	2008-05-27 03:29:43 UTC (rev 14992)
@@ -92,4 +92,4 @@
 
 # g++ -w  -I../geometry -I../image -I../scene_graph -I../stroke -I../system -I../view_map -I../winged_edge -I/usr/include/python2.5 -I../../../blenlib -I../../../blenkernel -I../../../imbuf -I../../../makesdna -c ModuleWrapper.cpp -o ModuleWrapper.o
 # 
-# g++ -bundle -flat_namespace -undefined suppress  -w  -L/usr/lib/python2.5/config -lpython2.5 -o ../../python/_Freestyle.so ModuleWrapper.o
\ No newline at end of file
+# g++ -bundle -flat_namespace -undefined suppress  -w  -L/Users/mx/Documents/work/GSoC_2008/bf-blender/branches/build/darwin/lib -L/usr/lib/python2.5/config -lbf_freestyle -lbf_blenlib -lbf_blenkernel -lbf_guardedalloc -lbf_imbuf -lpython2.5 -o ../../python/_Freestyle.so ModuleWrapper.o

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/system/PythonInterpreter.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/system/PythonInterpreter.h	2008-05-27 01:30:17 UTC (rev 14991)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/system/PythonInterpreter.h	2008-05-27 03:29:43 UTC (rev 14992)
@@ -105,16 +105,23 @@
 	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;
   }





More information about the Bf-blender-cvs mailing list