diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-09-28 08:29:01 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-09-28 08:29:01 +0400 |
commit | dab61acd458ef53eee2df014ccb28579b947ec5b (patch) | |
tree | 824a06bee19aa5d7ccc5235a64530294540b0f78 /source | |
parent | 8ea2904693707209d739928a70072d339c547b84 (diff) |
Added "scripts/modules" as permanent module search path.
- added bpy.sys as a python module - with bpy.sys.expandpath()
- moved bpy.ops into scripts/modules
- moved autocomplete into its own module from space_console.py
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/python/intern/bpy_interface.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index f83f605bafc..675ef973ca2 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -176,7 +176,34 @@ static void bpy_init_modules( void ) PyDict_SetItemString(PySys_GetObject("modules"), "bpy", mod); Py_DECREF(mod); - + /* add our own modules dir */ + { + char *modpath= BLI_gethome_folder("scripts/modules", BLI_GETHOME_ALL); + + if(modpath) { + PyObject *sys_path= PySys_GetObject("path"); /* borrow */ + PyObject *py_modpath= PyUnicode_FromString(modpath); + PyList_Insert(sys_path, 0, py_modpath); /* add first */ + Py_DECREF(py_modpath); + } + + mod= PyImport_ImportModuleLevel("bpy_ops", NULL, NULL, NULL, 0); /* adds its self to bpy.ops */ + if(mod) { + Py_DECREF(mod); + } + else { + PyErr_Clear(); + } + + mod= PyImport_ImportModuleLevel("bpy_sys", NULL, NULL, NULL, 0); /* adds its self to bpy.sys */ + if(mod) { + Py_DECREF(mod); + } + else { + PyErr_Clear(); + } + } + /* stand alone utility modules not related to blender directly */ Geometry_Init(); Mathutils_Init(); |