[Bf-python] sitedirs and Python 2.4

Ken Hughes khughes at pacific.edu
Sun Oct 30 07:41:28 CET 2005


Ken Hughes wrote:

> I've played around some more this evening and first found that I could 
> also add SOME of the site-packages to sys.path by getting a PyObject * 
> for site.addsitepackages() and calling with PyObject_CallFunction(). But 
> after I read the documentation on Py_Initialize() in the Python/C API 
> Reference Manual:
> 
>   "The basic initialization function is Py_Initialize(). This
>    initializes the table of loaded modules, and creates the
>    fundamental modules __builtin__, __main__, sys, and exceptions.
>    It also initializes the module search path (sys.path)."
> 
>  From this I tried *not* setting the system path after calling 
> Py_Initialize() (there's a call to PySys_SetPath() in init_syspath).  I 
> ended up with exactly the same site-packages in my sys.path as the 
> python2.4 interpreter gave me (of course, the complete sys.path was 
> different since Blender includes paths to its script directories).
> 
> Bottom line; maybe we're doing too much in our initialization code?

OK, an additional point of information (then I'll shut up for a while, I 
promise):

I looked at the source for Py_InitializeEx(), and sure enough it
does:
	PySys_SetPath(Py_GetPath());
shortly before it calls initsite(), which does the "site" module.

Ken










More information about the Bf-python mailing list