- Added user defined python dir to Python's sys.path:
Had to add a function call to creator.c, explained in a note there (look for pythondir in the file)
This commit is contained in:
@@ -47,6 +47,7 @@ struct _object; // forward declaration for PyObject !
|
|||||||
|
|
||||||
void BPY_start_python(void);
|
void BPY_start_python(void);
|
||||||
void BPY_end_python(void);
|
void BPY_end_python(void);
|
||||||
|
void BPY_syspath_append_pythondir(void);
|
||||||
int BPY_Err_getLinenumber(void);
|
int BPY_Err_getLinenumber(void);
|
||||||
const char *BPY_Err_getFilename(void);
|
const char *BPY_Err_getFilename(void);
|
||||||
/* void BPY_Err_Handle(struct Text *text); */
|
/* void BPY_Err_Handle(struct Text *text); */
|
||||||
|
@@ -178,6 +178,9 @@ void init_syspath(void)
|
|||||||
|
|
||||||
if (U.pythondir) { /* XXX not working, U.pythondir is NULL here ?!?*/
|
if (U.pythondir) { /* XXX not working, U.pythondir is NULL here ?!?*/
|
||||||
/* maybe it wasn't defined yet at this point in start-up ...*/
|
/* maybe it wasn't defined yet at this point in start-up ...*/
|
||||||
|
/* Update: definitely that is the reason. We need to start python
|
||||||
|
* after U.pythondir is defined (better after the other U.xxxx are
|
||||||
|
* too. */
|
||||||
p = Py_BuildValue("s", U.pythondir);
|
p = Py_BuildValue("s", U.pythondir);
|
||||||
syspath_append(p); /* append to module search path */
|
syspath_append(p); /* append to module search path */
|
||||||
}
|
}
|
||||||
@@ -192,6 +195,18 @@ void init_syspath(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Description: This function adds the user defined folder for Python */
|
||||||
|
/* scripts to sys.path. This is done in init_syspath, too, but */
|
||||||
|
/* when Blender's main() runs BPY_start_python(), U.pythondir */
|
||||||
|
/* isn't set yet, so we provide this function to be executed */
|
||||||
|
/* after U.pythondir is defined. */
|
||||||
|
/*****************************************************************************/
|
||||||
|
void BPY_syspath_append_pythondir(void)
|
||||||
|
{
|
||||||
|
syspath_append(Py_BuildValue("s", U.pythondir));
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Description: This function will return the linenumber on which an error */
|
/* Description: This function will return the linenumber on which an error */
|
||||||
/* has occurred in the Python script. */
|
/* has occurred in the Python script. */
|
||||||
|
@@ -388,6 +388,15 @@ int main(int argc, char **argv)
|
|||||||
sound_init_audio();
|
sound_init_audio();
|
||||||
|
|
||||||
BIF_init();
|
BIF_init();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NOTE: the U.pythondir string is NULL until BIF_init() is executed,
|
||||||
|
* so we provide the BPY_ function below to append the user defined
|
||||||
|
* pythondir to Python's sys.path at this point. Simply putting
|
||||||
|
* BIF_init() before BPY_start_python() crashes Blender at startup.
|
||||||
|
*/
|
||||||
|
|
||||||
|
BPY_syspath_append_pythondir();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BPY_start_python();
|
BPY_start_python();
|
||||||
|
Reference in New Issue
Block a user