[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30394] trunk/blender: == installation paths ==

Andrea Weikert elubie at gmx.net
Thu Jul 15 22:02:53 CEST 2010


Revision: 30394
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30394
Author:   elubie
Date:     2010-07-15 22:02:53 +0200 (Thu, 15 Jul 2010)

Log Message:
-----------
== installation paths ==
remove deprecated python BLI_gethome_folder calls

Patch by Brecht, thanks a lot

Modified Paths:
--------------
    trunk/blender/release/scripts/modules/bpy/utils.py
    trunk/blender/source/blender/blenlib/BLI_path_util.h
    trunk/blender/source/blender/blenlib/intern/path_util.c
    trunk/blender/source/blender/python/intern/bpy.c
    trunk/blender/source/creator/creator.c

Modified: trunk/blender/release/scripts/modules/bpy/utils.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy/utils.py	2010-07-15 19:58:23 UTC (rev 30393)
+++ trunk/blender/release/scripts/modules/bpy/utils.py	2010-07-15 20:02:53 UTC (rev 30394)
@@ -19,7 +19,7 @@
 # <pep8 compliant>
 
 """
-This module contains utility functions spesific to blender but
+This module contains utility functions specific to blender but
 not assosiated with blenders internal data.
 """
 
@@ -27,7 +27,8 @@
 import os as _os
 import sys as _sys
 
-from _bpy import home_paths, blend_paths
+from _bpy import blend_paths
+from _bpy import script_paths as _bpy_script_paths
 
 
 def _test_import(module_name, loaded_modules):
@@ -313,7 +314,7 @@
     else:
         user_script_path = None
 
-    for path in home_paths("scripts") + (user_script_path, ):
+    for path in _bpy_script_paths() + (user_script_path, ):
         if path:
             path = _os.path.normpath(path)
             if path not in scripts and _os.path.isdir(path):

Modified: trunk/blender/source/blender/blenlib/BLI_path_util.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_path_util.h	2010-07-15 19:58:23 UTC (rev 30393)
+++ trunk/blender/source/blender/blenlib/BLI_path_util.h	2010-07-15 20:02:53 UTC (rev 30394)
@@ -41,32 +41,7 @@
 struct direntry;
 
 char *BLI_gethome(void);
-char *BLI_gethome_folder(char *folder_name, int flag);
 
-/* BLI_gethome_folder flag */
-#define BLI_GETHOME_LOCAL		1<<1 /* relative location for portable binaries */
-#define BLI_GETHOME_SYSTEM		1<<2 /* system location, or set from the BLENDERPATH env variable (UNIX only) */
-#define BLI_GETHOME_USER		1<<3 /* home folder ~/.blender */
-#define BLI_GETHOME_ALL			(BLI_GETHOME_SYSTEM|BLI_GETHOME_LOCAL|BLI_GETHOME_USER)
-
-
-#ifdef __APPLE__
-typedef enum {
-	BasePath_Temporary = 1,
-	BasePath_BlenderShared,
-	BasePath_BlenderUser,
-	BasePath_ApplicationBundle
-} basePathesTypes;
-
-/**
- * Gets the base path. The path may not exist.
- * Note that return string must be copied as its persistence is not guaranteed
- *
- * @return base path of pathType
- */
-const char* BLI_osx_getBasePath(basePathesTypes pathType);
-#endif
-
 char *BLI_get_folder(int folder_id, char *subfolder);
 char *BLI_get_folder_create(int folder_id, char *subfolder);
 

Modified: trunk/blender/source/blender/blenlib/intern/path_util.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/path_util.c	2010-07-15 19:58:23 UTC (rev 30393)
+++ trunk/blender/source/blender/blenlib/intern/path_util.c	2010-07-15 20:02:53 UTC (rev 30394)
@@ -795,121 +795,6 @@
 	#endif
 }
 
-/* this function returns the path to a blender folder, if it exists
- * utility functions for BLI_gethome_folder */
-
-// #define PATH_DEBUG /* for testing paths that are checked */
-
-static int test_data_path(char *targetpath, char *path_base, char *path_sep, char *folder_name)
-{
-	char tmppath[FILE_MAXDIR];
-	
-	if(path_sep)	BLI_join_dirfile(tmppath, path_base, path_sep);
-	else			BLI_strncpy(tmppath, path_base, sizeof(tmppath));
-	
-	BLI_make_file_string("/", targetpath, tmppath, folder_name);
-	
-	if (BLI_is_dir(targetpath)) {
-#ifdef PATH_DEBUG
-		printf("\tpath found: %s\n", targetpath);
-#endif
-		return 1;
-	}
-	else {
-#ifdef PATH_DEBUG
-		printf("\tpath missing: %s\n", targetpath);
-#endif
-		targetpath[0] = '\0';
-		return 0;
-	}
-}
-
-static int gethome_path_local(char *targetpath, char *folder_name)
-{
-	extern char bprogname[]; /* argv[0] from creator.c */
-	char bprogdir[FILE_MAXDIR];
-	char cwd[FILE_MAXDIR];
-	char *s;
-	int i;
-	
-#ifdef PATH_DEBUG
-	printf("gethome_path_local...\n");
-#endif
-	
-	/* try release/folder_name (binary relative) */
-	/* use argv[0] (bprogname) to get the path to the executable */
-	s = BLI_last_slash(bprogname);
-	i = s - bprogname + 1;
-	BLI_strncpy(bprogdir, bprogname, i);
-
-	/* try release/folder_name (BIN relative) */
-	if(test_data_path(targetpath, bprogdir, "release", folder_name))
-		return 1;
-
-	/* try release/folder_name (CWD relative) */
-	if(test_data_path(targetpath, BLI_getwdN(cwd), "release", folder_name))
-		return 1;
-
-	/* try ./.blender/folder_name */
-	if(test_data_path(targetpath, bprogdir, ".blender", folder_name))
-		return 1;
-	
-	return 0;
-}
-
-static int gethome_path_user(char *targetpath, char *folder_name)
-{
-	char *home_path= BLI_gethome();
-
-#ifdef PATH_DEBUG
-	printf("gethome_path_user...\n");
-#endif
-	
-	/* try $HOME/folder_name */
-	return test_data_path(targetpath, home_path, ".blender", folder_name);
-}
-
-static int gethome_path_system(char *targetpath, char *folder_name)
-{
-	extern char blender_path[]; /* unix prefix eg. /usr/share/blender/2.5 creator.c */
-	
-	if(!blender_path[0])
-		return 0;
-	
-#ifdef PATH_DEBUG
-	printf("gethome_path_system...\n");
-#endif
-	
-	/* try $BLENDERPATH/folder_name */
-	return test_data_path(targetpath, blender_path, NULL, folder_name);
-}
-
-char *BLI_gethome_folder(char *folder_name, int flag)
-{
-	static char fulldir[FILE_MAXDIR] = "";
-	
-	/* first check if this is a redistributable bundle */
-	if(flag & BLI_GETHOME_LOCAL) {
-		if (gethome_path_local(fulldir, folder_name))
-			return fulldir;
-	}
-
-	/* then check if the OS has blender data files installed in a global location */
-	if(flag & BLI_GETHOME_SYSTEM) {
-		if (gethome_path_system(fulldir, folder_name))
-			return fulldir;
-	}
-	
-	/* now check the users home dir for data files */
-	if(flag & BLI_GETHOME_USER) {
-		if (gethome_path_user(fulldir, folder_name))
-			return fulldir;
-	}
-	
-	return NULL;
-}
-
-
 /* NEW stuff, to be cleaned up when fully migrated */
 /* ************************************************************* */
 /* ************************************************************* */

Modified: trunk/blender/source/blender/python/intern/bpy.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy.c	2010-07-15 19:58:23 UTC (rev 30393)
+++ trunk/blender/source/blender/python/intern/bpy.c	2010-07-15 20:02:53 UTC (rev 30394)
@@ -41,33 +41,23 @@
 #include "../generic/blf_api.h"
 #include "../generic/IDProp.h"
 
-static char bpy_home_paths_doc[] =
-".. function:: home_paths(subfolder)\n"
+static char bpy_script_paths_doc[] =
+".. function:: script_paths()\n"
 "\n"
-"   Return 3 paths to blender home directories.\n"
+"   Return 2 paths to blender scripts directories.\n"
 "\n"
-"   :arg subfolder: The name of a subfolder to find within the blenders home directory.\n"
-"   :type subfolder: string\n"
-"   :return: (system, local, user) strings will be empty when not found.\n"
+"   :return: (system, user) strings will be empty when not found.\n"
 "   :rtype: tuple of strigs\n";
 
-PyObject *bpy_home_paths(PyObject *self, PyObject *args)
+PyObject *bpy_script_paths(PyObject *self)
 {
-	PyObject *ret= PyTuple_New(3);
+	PyObject *ret= PyTuple_New(2);
 	char *path;
-	char *subfolder= "";
     
-	if (!PyArg_ParseTuple(args, "|s:blender_homes", &subfolder))
-		return NULL;
-
-	path= BLI_gethome_folder(subfolder, BLI_GETHOME_SYSTEM);
+	path= BLI_get_folder(BLENDER_USER_SCRIPTS, NULL);
 	PyTuple_SET_ITEM(ret, 0, PyUnicode_FromString(path?path:""));
-
-	path= BLI_gethome_folder(subfolder, BLI_GETHOME_LOCAL);
+	path= BLI_get_folder(BLENDER_SYSTEM_SCRIPTS, NULL);
 	PyTuple_SET_ITEM(ret, 1, PyUnicode_FromString(path?path:""));
-
-	path= BLI_gethome_folder(subfolder, BLI_GETHOME_USER);
-	PyTuple_SET_ITEM(ret, 2, PyUnicode_FromString(path?path:""));
     
 	return ret;
 }
@@ -120,7 +110,7 @@
 	return list;
 }
 
-static PyMethodDef meth_bpy_home_paths[] = {{ "home_paths", (PyCFunction)bpy_home_paths, METH_VARARGS, bpy_home_paths_doc}};
+static PyMethodDef meth_bpy_script_paths[] = {{ "script_paths", (PyCFunction)bpy_script_paths, METH_NOARGS, bpy_script_paths_doc}};
 static PyMethodDef meth_bpy_blend_paths[] = {{ "blend_paths", (PyCFunction)bpy_blend_paths, METH_VARARGS|METH_KEYWORDS, bpy_blend_paths_doc}};
 
 static void bpy_import_test(char *modname)
@@ -191,7 +181,7 @@
 	PyModule_AddObject(mod, "context", (PyObject *)bpy_context_module);
 
 	/* utility func's that have nowhere else to go */
-	PyModule_AddObject(mod, meth_bpy_home_paths->ml_name, (PyObject *)PyCFunction_New(meth_bpy_home_paths, NULL));
+	PyModule_AddObject(mod, meth_bpy_script_paths->ml_name, (PyObject *)PyCFunction_New(meth_bpy_script_paths, NULL));
 	PyModule_AddObject(mod, meth_bpy_blend_paths->ml_name, (PyObject *)PyCFunction_New(meth_bpy_blend_paths, NULL));
 
 	/* add our own modules dir, this is a python package */

Modified: trunk/blender/source/creator/creator.c
===================================================================
--- trunk/blender/source/creator/creator.c	2010-07-15 19:58:23 UTC (rev 30393)
+++ trunk/blender/source/creator/creator.c	2010-07-15 20:02:53 UTC (rev 30394)
@@ -131,14 +131,6 @@
 char bprogname[FILE_MAXDIR+FILE_MAXFILE]; /* from blenpluginapi:pluginapi.c */
 char btempdir[FILE_MAXDIR+FILE_MAXFILE];
 
-/* unix path support.
- * defined by the compiler. eg "/usr/share/blender/2.5" "/opt/blender/2.5" */
-#ifndef BLENDERPATH
-#define BLENDERPATH ""
-#endif
- 
-char blender_path[FILE_MAXDIR+FILE_MAXFILE] = BLENDERPATH;
-
 /* Initialise callbacks for the modules that need them */
 static void setCallbacks(void); 
 
@@ -297,14 +289,14 @@
 	printf ("  $BLENDER_SYSTEM_DATAFILES Directory for system wide data files.\n");
 	printf ("  $BLENDER_SYSTEM_PYTHON    Directory for system python libraries.\n");
 #ifdef WIN32
-	printf ("  $TEMP         Store temporary files here.\n");
+	printf ("  $TEMP                     Store temporary files here.\n");
 #else
-	printf ("  $TMP or $TMPDIR  Store temporary files here.\n");
+	printf ("  $TMP or $TMPDIR           Store temporary files here.\n");
 #endif
 #ifndef DISABLE_SDL
-	printf ("  $SDL_AUDIODRIVER  LibSDL audio driver - alsa, esd, alsa, dma.\n");
+	printf ("  $SDL_AUDIODRIVER          LibSDL audio driver - alsa, esd, dma.\n");
 #endif
-	printf ("  $PYTHONHOME   Path to the python directory, eg. /usr/lib/python.\n\n");
+	printf ("  $PYTHONHOME               Path to the python directory, eg. /usr/lib/python.\n\n");
 
 	exit(0);
 
@@ -1040,12 +1032,6 @@
 
 	BLI_where_am_i(bprogname, argv[0]);
 	
-	{	/* override the hard coded blender path */
-		char *blender_path_env = getenv("BLENDERPATH");
-		if(blender_path_env)

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list