Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-09-21 07:16:26 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-09-21 07:16:26 +0400
commite7abdd7d56256b57d9e33326af253188ed9d96dc (patch)
tree0e8aeb686bc3ad434c1c3ba528c2eed3b6512dfa /source/blender/python/intern/bpy_interface.c
parent6c655aa2a762e440ba3f64ce8520c6ce41268d3e (diff)
Better unix filesystem integration as documented here
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/Unix_FHS for scons WITH_BF_FHS enabled an alternative layout eg. scons WITH_BF_FHS=1 BF_INSTALLDIR="/usr/local" for CMake just run "make install" after make (CMAKE_INSTALL_PREFIX is used for the base path) Currently only scripts use both the system and user path correctly, other areas of blender have their own path code inline with lots of ifdefs, needs to be carefully updated.
Diffstat (limited to 'source/blender/python/intern/bpy_interface.c')
-rw-r--r--source/blender/python/intern/bpy_interface.c99
1 files changed, 44 insertions, 55 deletions
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index a850809b4a5..fd8cfc47f55 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -232,26 +232,10 @@ static PyObject *CreateGlobalDictionary( bContext *C )
return dict;
}
-/* Use this so we can include our own python bundle */
-#if 0
-wchar_t* Py_GetPath(void)
-{
- int i;
- static wchar_t py_path[FILE_MAXDIR] = L"";
- char *dirname= BLI_gethome_folder("python");
- if(dirname) {
- i= mbstowcs(py_path, dirname, FILE_MAXDIR);
- printf("py path %s, %d\n", dirname, i);
- }
- return py_path;
-}
-#endif
-
-
/* must be called before Py_Initialize */
void BPY_start_python_path(void)
{
- char *py_path_bundle= BLI_gethome_folder("python");
+ char *py_path_bundle= BLI_gethome_folder("python", BLI_GETHOME_ALL);
if(py_path_bundle==NULL)
return;
@@ -589,7 +573,8 @@ void BPY_run_ui_scripts(bContext *C, int reload)
char *dirname;
char path[FILE_MAX];
char *dirs[] = {"ui", "io", NULL};
- int a, err;
+ int path_flags[] = {BLI_GETHOME_LOCAL|BLI_GETHOME_SYSTEM, BLI_GETHOME_USER}; /* SYSTEM / NON-SYSTEM */
+ int a, err, flag_iter;
PyGILState_STATE gilstate;
PyObject *sys_path;
@@ -599,56 +584,60 @@ void BPY_run_ui_scripts(bContext *C, int reload)
sys_path= PySys_GetObject("path"); /* borrow */
PyList_Insert(sys_path, 0, Py_None); /* place holder, resizes the list */
- for(a=0; dirs[a]; a++) {
- dirname= BLI_gethome_folder(dirs[a]);
+ /* Scan system scripts first, then local/user */
+ for(flag_iter=0; flag_iter < sizeof(path_flags)/sizeof(int); flag_iter++) {
+
+ for(a=0; dirs[a]; a++) {
+ dirname= BLI_gethome_folder(dirs[a], path_flags[flag_iter]);
- if(!dirname)
- continue;
+ if(!dirname)
+ continue;
- dir = opendir(dirname);
+ dir = opendir(dirname);
- if(!dir)
- continue;
-
- /* set the first dir in the sys.path for fast importing of modules */
- PyList_SetItem(sys_path, 0, PyUnicode_FromString(dirname)); /* steals the ref */
+ if(!dir)
+ continue;
- while((de = readdir(dir)) != NULL) {
- /* We could stat the file but easier just to let python
- * import it and complain if theres a problem */
- err = 0;
-
- if (de->d_name[0] == '.') {
- /* do nothing, probably .svn */
- }
- else if ((file_extension = strstr(de->d_name, ".py"))) {
- /* normal py files? */
- if(file_extension && file_extension[3] == '\0') {
- de->d_name[(file_extension - de->d_name)] = '\0';
- err= bpy_import_module(de->d_name, reload);
+ /* set the first dir in the sys.path for fast importing of modules */
+ PyList_SetItem(sys_path, 0, PyUnicode_FromString(dirname)); /* steals the ref */
+
+ while((de = readdir(dir)) != NULL) {
+ /* We could stat the file but easier just to let python
+ * import it and complain if theres a problem */
+ err = 0;
+
+ if (de->d_name[0] == '.') {
+ /* do nothing, probably .svn */
+ }
+ else if ((file_extension = strstr(de->d_name, ".py"))) {
+ /* normal py files? */
+ if(file_extension && file_extension[3] == '\0') {
+ de->d_name[(file_extension - de->d_name)] = '\0';
+ err= bpy_import_module(de->d_name, reload);
+ }
}
- }
#ifndef __linux__
- else if( BLI_join_dirfile(path, dirname, de->d_name), S_ISDIR(BLI_exist(path))) {
+ else if( BLI_join_dirfile(path, dirname, de->d_name), S_ISDIR(BLI_exist(path))) {
#else
- else if(de->d_type==DT_DIR) {
- BLI_join_dirfile(path, dirname, de->d_name);
+ else if(de->d_type==DT_DIR) {
+ BLI_join_dirfile(path, dirname, de->d_name);
#endif
- /* support packages */
- BLI_join_dirfile(path, path, "__init__.py");
+ /* support packages */
+ BLI_join_dirfile(path, path, "__init__.py");
- if(BLI_exists(path)) {
- err= bpy_import_module(de->d_name, reload);
+ if(BLI_exists(path)) {
+ err= bpy_import_module(de->d_name, reload);
+ }
}
- }
- if(err==-1) {
- BPy_errors_to_report(NULL);
- fprintf(stderr, "unable to import %s/%s\n", dirname, de->d_name);
+ if(err==-1) {
+ BPy_errors_to_report(NULL);
+ fprintf(stderr, "unable to import %s/%s\n", dirname, de->d_name);
+ }
}
- }
- closedir(dir);
+ closedir(dir);
+ }
}
PyList_SetSlice(sys_path, 0, 1, NULL); /* remove the first item */