[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20544] trunk/blender: YoFrankie bug [ #18857] On start gives ImportError: No module named frankie_scripts
Campbell Barton
ideasman42 at gmail.com
Mon Jun 1 07:43:58 CEST 2009
Revision: 20544
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20544
Author: campbellbarton
Date: 2009-06-01 07:43:58 +0200 (Mon, 01 Jun 2009)
Log Message:
-----------
YoFrankie bug [#18857] On start gives ImportError: No module named frankie_scripts
GameEngine sys.path creation was broken because of a pesky slash at the end of each path name.
Win32 sys.paths were also failing when running a game that switched between blend files in different directories
On win32 for some reason making absolute paths from lib->name failed, work around this by using lib->filename.
STR_String.h, cast to float to quiet compiler warnings.
Modified Paths:
--------------
trunk/blender/intern/string/STR_String.h
trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp
Modified: trunk/blender/intern/string/STR_String.h
===================================================================
--- trunk/blender/intern/string/STR_String.h 2009-06-01 04:08:04 UTC (rev 20543)
+++ trunk/blender/intern/string/STR_String.h 2009-06-01 05:43:58 UTC (rev 20544)
@@ -142,7 +142,7 @@
inline operator const char *() const { return pData; }
inline char *Ptr() { return pData; }
inline const char *ReadPtr() const { return pData; }
- inline float ToFloat() const { float x=atof(pData); return x; }
+ inline float ToFloat() const { float x=(float)atof(pData); return x; }
inline int ToInt() const { return atoi(pData); }
// Operators
Modified: trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp 2009-06-01 04:08:04 UTC (rev 20543)
+++ trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp 2009-06-01 05:43:58 UTC (rev 20544)
@@ -1508,10 +1508,12 @@
char expanded[FILE_MAXDIR + FILE_MAXFILE];
BLI_split_dirfile_basic(filename, expanded, NULL); /* get the dir part of filename only */
- BLI_convertstringcode(expanded, gp_GamePythonPath);
-
+ BLI_convertstringcode(expanded, gp_GamePythonPath); /* filename from lib->filename is (always?) absolute, so this may not be needed but it wont hurt */
+ BLI_cleanup_file(gp_GamePythonPath, expanded); /* Dont use BLI_cleanup_dir because it adds a slash - BREAKS WIN32 ONLY */
item= PyString_FromString(expanded);
+// printf("SysPath - '%s', '%s', '%s'\n", expanded, filename, gp_GamePythonPath);
+
if(PySequence_Index(sys_path, item) == -1) {
PyErr_Clear(); /* PySequence_Index sets a ValueError */
PyList_Insert(sys_path, 0, item);
@@ -1535,7 +1537,9 @@
Library *lib= (Library *)maggie->library.first;
while(lib) {
- initPySysObjects__append(sys_path, lib->name);
+ /* lib->name wont work in some cases (on win32),
+ * even when expanding with gp_GamePythonPath, using lib->filename is less trouble */
+ initPySysObjects__append(sys_path, lib->filename);
lib= (Library *)lib->id.next;
}
@@ -2083,6 +2087,7 @@
void setGamePythonPath(char *path)
{
BLI_strncpy(gp_GamePythonPath, path, sizeof(gp_GamePythonPath));
+ BLI_cleanup_file(NULL, gp_GamePythonPath); /* not absolutely needed but makes resolving path problems less confusing later */
if (gp_GamePythonPathOrig[0] == '\0')
BLI_strncpy(gp_GamePythonPathOrig, path, sizeof(gp_GamePythonPathOrig));
More information about the Bf-blender-cvs
mailing list