else:
if len(df)>0:
dp_tmp = dp[l:]
- if dp_tmp.find('python\\lib') > -1:
- datafiles += "\n" +r'SetOutPath $INSTDIR'+dp[l:]+"\n\n"
- else:
- datafiles += "\n"+r'SetOutPath $BLENDERHOME'+dp[l:]+"\n\n"
+ datafiles += "\n" +r'SetOutPath $INSTDIR'+dp[l:]+"\n\n"
for f in df:
outfile = os.path.join(dp,f)
self.report({'ERROR'}, "Source path %r exists" % path_src)
else:
shutil.copytree(path_src, path_dst)
+
+ # in 2.57 and earlier windows installers, system scripts were copied
+ # into the configuration directory, don't want to copy those
+ system_script = os.path.join(path_dst, 'scripts/modules/bpy_types.py')
+ if os.path.isfile(system_script):
+ shutil.rmtree(os.path.join(path_dst, 'scripts'))
+ shutil.rmtree(os.path.join(path_dst, 'plugins'))
+
# dont loose users work if they open the splash later.
if bpy.data.is_saved is bpy.data.is_dirty is False:
bpy.ops.wm.read_homefile()
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
-Page custom DataLocation DataLocationOnLeave
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_WELCOME
+UninstPage custom un.OptionalRemoveConfig un.OptionalRemoveConfigOnLeave
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
LangString DESC_StartMenu ${LANG_ENGLISH} "Add shortcut items to the Start Menu. (Recommended)"
LangString DESC_DesktopShortcut ${LANG_ENGLISH} "Add a shortcut to Blender on your desktop."
LangString DESC_BlendRegister ${LANG_ENGLISH} "Blender can register itself with .blend files to allow double-clicking from Windows Explorer, etc."
- LangString TEXT_IO_TITLE ${LANG_ENGLISH} "Specify User Data Location"
;--------------------------------
;Data
SilentUnInstall normal
-Var BLENDERHOME
Var SHORTVERSION ; This is blender_version_decimal() from path_util.c
+Var BLENDERCONFIG
+Var REMOVECONFIG
; Custom controls
Var HWND
-Var HWND_APPDATA
-Var HWND_INSTDIR
-Var HWND_HOMEDIR
+Var HWND_KEEPCONFIG
+Var HWND_REMOVECONFIG
Function .onInit
ClearErrors
FunctionEnd
Function un.onInit
+ SetShellVarContext current
+ StrCpy $BLENDERCONFIG "$APPDATA\Blender Foundation\Blender"
+ SetShellVarContext all
FunctionEnd
-Function DataLocation
+Function un.OptionalRemoveConfig
nsDialogs::Create /NOUNLOAD 1018
Pop $HWND
Abort
${EndIf}
- ${NSD_CreateLabel} 0 0 100% 24u "Please specify where you wish to install Blender's user data files. Be aware that if you choose to use your Application Data directory, your preferences and scripts will only be accessible by the current user account."
- ${NSD_CreateRadioButton} 0 50 100% 12u "Use Application Data directory (recommended)"
- Pop $HWND_APPDATA
- ${NSD_CreateRadioButton} 0 80 100% 12u "Use installation directory"
- Pop $HWND_INSTDIR
- ${NSD_CreateRadioButton} 0 110 100% 12u "I have defined a %HOME% variable, please install files there"
- Pop $HWND_HOMEDIR
-
- ${If} ${AtMostWinME}
- GetDlgItem $0 $HWND $HWND_APPDATA
- EnableWindow $0 0
- SendMessage $HWND_INSTDIR ${BM_SETCHECK} 1 0
- ${Else}
- SendMessage $HWND_APPDATA ${BM_SETCHECK} 1 0
- ${EndIf}
+ ${NSD_CreateRadioButton} 0 50 100% 12u "Keep configuration files, autosaved .blend files and installed addons (recommended)"
+ Pop $HWND_KEEPCONFIG
+ ${NSD_CreateRadioButton} 0 80 100% 12u "Remove all files, including configuration files, autosaved .blend files and installed addons"
+ Pop $HWND_REMOVECONFIG
+
+ SendMessage $HWND_KEEPCONFIG ${BM_SETCHECK} 1 0
nsDialogs::Show
FunctionEnd
-Function DataLocationOnLeave
- ${NSD_GetState} $HWND_APPDATA $R0
+Function un.OptionalRemoveConfigOnLeave
+ ${NSD_GetState} $HWND_REMOVECONFIG $R0
${If} $R0 == "1"
- SetShellVarContext current
- StrCpy $BLENDERHOME "$APPDATA\Blender Foundation\Blender"
- SetShellVarContext all
+ StrCpy $REMOVECONFIG "1"
${Else}
- ${NSD_GetState} $HWND_INSTDIR $R0
- ${If} $R0 == "1"
- StrCpy $BLENDERHOME $INSTDIR
- ${Else}
- ${NSD_GetState} $HWND_HOMEDIR $R0
- ${If} $R0 == "1"
- ReadEnvStr $BLENDERHOME "HOME"
- ${EndIf}
- ${EndIf}
+ StrCpy $REMOVECONFIG "0"
${EndIf}
FunctionEnd
+
Section "Blender [VERSION] (required)" InstallFiles
SectionIn RO
; The contents of Blender installation root dir
[ROOTDIRCONTS]
- ; All datafiles (python, scripts, config)
+ ; All datafiles (python, scripts, datafiles)
[DODATAFILES]
SetOutPath $INSTDIR
${EndIf}
; Write the installation path into the registry
WriteRegStr HKLM "SOFTWARE\BlenderFoundation" "Install_Dir" "$INSTDIR"
- WriteRegStr HKLM "SOFTWARE\BlenderFoundation" "ConfigData_Dir" "$BLENDERHOME"
WriteRegStr HKLM "SOFTWARE\BlenderFoundation" "ShortVersion" "[SHORTVERSION]"
; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "DisplayName" "Blender"
ExecWait '"$INSTDIR\blender.exe" -r'
SectionEnd
-UninstallText "This will uninstall Blender [VERSION], and all installed files. Before continuing make sure you have created backup of all the files you may want to keep: startup.blend, bookmarks.txt, recent-files.txt. Hit 'Uninstall' to continue."
+UninstallText "This will uninstall Blender [VERSION], and all installed files. Hit 'Uninstall' to continue."
Section "Uninstall"
; Remove registry keys
SetRegView 64
${EndIf}
- ReadRegStr $BLENDERHOME HKLM "SOFTWARE\BlenderFoundation" "ConfigData_Dir"
ReadRegStr $SHORTVERSION HKLM "SOFTWARE\BlenderFoundation" "ShortVersion"
DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Blender"
DeleteRegKey HKLM "SOFTWARE\BlenderFoundation"
Delete "$INSTDIR\uninstall.exe"
- MessageBox MB_YESNO "Recursively erase contents of $BLENDERHOME\$SHORTVERSION\scripts? NOTE: This includes all installed scripts and *any* file and directory you have manually created, installed later or copied. This also including .blend files." IDNO NextNoScriptRemove
- RMDir /r "$BLENDERHOME\$SHORTVERSION\scripts"
-NextNoScriptRemove:
- MessageBox MB_YESNO "Recursively erase contents from $BLENDERHOME\$SHORTVERSION\config? NOTE: This includes your startup.blend, bookmarks and any other file and directory you may have created in that directory" IDNO NextNoConfigRemove
- RMDir /r "$BLENDERHOME\$SHORTVERSION\config"
-NextNoConfigRemove:
- MessageBox MB_YESNO "Recursively erase contents from $BLENDERHOME\$SHORTVERSION\plugins? NOTE: This includes files and subdirectories in this directory" IDNO NextNoPluginRemove
- RMDir /r "$BLENDERHOME\$SHORTVERSION\plugins"
-NextNoPluginRemove:
- ; Try to remove dirs, but leave them if they contain anything
- RMDir "$BLENDERHOME\$SHORTVERSION\plugins"
- RMDir "$BLENDERHOME\$SHORTVERSION\config"
- RMDir "$BLENDERHOME\$SHORTVERSION\scripts"
- RMDir "$BLENDERHOME\$SHORTVERSION"
- RMDir "$BLENDERHOME"
+ ${If} $REMOVECONFIG == "1"
+ RMDir /r "$BLENDERCONFIG\$SHORTVERSION"
+ ${Endif}
+
; Remove shortcuts
Delete "$SMPROGRAMS\Blender Foundation\Blender\*.*"
Delete "$DESKTOP\Blender.lnk"
/* folder_id */
/* general, will find based on user/local/system priority */
-#define BLENDER_CONFIG 1
#define BLENDER_DATAFILES 2
-#define BLENDER_SCRIPTS 3
-#define BLENDER_PLUGINS 4
-#define BLENDER_PYTHON 5
/* user-specific */
#define BLENDER_USER_CONFIG 31
#define BLENDER_USER_AUTOSAVE 35
/* system */
-#define BLENDER_SYSTEM_CONFIG 51 /* optional */
#define BLENDER_SYSTEM_DATAFILES 52
#define BLENDER_SYSTEM_SCRIPTS 53
#define BLENDER_SYSTEM_PLUGINS 54
return 0;
}
+static int is_portable_install(void)
+{
+ /* detect portable install by the existance of config folder */
+ const int ver= BLENDER_VERSION;
+ char path[FILE_MAX];
+
+ return get_path_local(path, "config", NULL, ver);
+}
+
static int get_path_user(char *targetpath, const char *folder_name, const char *subfolder_name, const char *envvar, const int ver)
{
char user_path[FILE_MAX];
const char *user_base_path;
+
+ /* for portable install, user path is always local */
+ if (is_portable_install())
+ return get_path_local(targetpath, folder_name, subfolder_name, ver);
user_path[0] = '\0';
}
}
+#if defined(WIN32) && BLENDER_VERSION < 258
+
+static int path_have_257_script_install(void)
+{
+ const int ver= BLENDER_VERSION;
+ char path[FILE_MAX] = "";
+ char system_pyfile[FILE_MAX];
+
+ if (get_path_user(path, "scripts", NULL, "BLENDER_USER_SCRIPTS", ver)) {
+ BLI_join_dirfile(system_pyfile, sizeof(system_pyfile), path, "modules/bpy_types.py");
+
+ if (BLI_exists(system_pyfile))
+ return 1;
+ }
+
+ return 0;
+}
+
+#endif
+
/* get a folder out of the 'folder_id' presets for paths */
/* returns the path if found, NULL string if not */
char *BLI_get_folder(int folder_id, const char *subfolder)
switch (folder_id) {
case BLENDER_DATAFILES: /* general case */
- if (get_path_local(path, "datafiles", subfolder, ver)) break;
if (get_path_user(path, "datafiles", subfolder, "BLENDER_USER_DATAFILES", ver)) break;
+ if (get_path_local(path, "datafiles", subfolder, ver)) break;
if (get_path_system(path, "datafiles", subfolder, "BLENDER_SYSTEM_DATAFILES", ver)) break;
return NULL;
case BLENDER_USER_DATAFILES:
- if (get_path_local(path, "datafiles", subfolder, ver)) break;
if (get_path_user(path, "datafiles", subfolder, "BLENDER_USER_DATAFILES", ver)) break;
return NULL;
return NULL;
case BLENDER_USER_AUTOSAVE:
- if (get_path_local(path, "autosave", subfolder, ver)) break;
if (get_path_user(path, "autosave", subfolder, "BLENDER_USER_DATAFILES", ver)) break;
return NULL;
- case BLENDER_CONFIG: /* general case */
- if (get_path_local(path, "config", subfolder, ver)) break;
- if (get_path_user(path, "config", subfolder, "BLENDER_USER_CONFIG", ver)) break;
- if (get_path_system(path, "config", subfolder, "BLENDER_SYSTEM_CONFIG", ver)) break;
- return NULL;
-
case BLENDER_USER_CONFIG:
- if (get_path_local(path, "config", subfolder, ver)) break;
if (get_path_user(path, "config", subfolder, "BLENDER_USER_CONFIG", ver)) break;
return NULL;
- case BLENDER_SYSTEM_CONFIG:
- if (get_path_local(path, "config", subfolder, ver)) break;
- if (get_path_system(path, "config", subfolder, "BLENDER_SYSTEM_CONFIG", ver)) break;
- return NULL;
-
- case BLENDER_SCRIPTS: /* general case */
- if (get_path_local(path, "scripts", subfolder, ver)) break;
- if (get_path_user(path, "scripts", subfolder, "BLENDER_USER_SCRIPTS", ver)) break;
- if (get_path_system(path, "scripts", subfolder, "BLENDER_SYSTEM_SCRIPTS", ver)) break;
- return NULL;
-
case BLENDER_USER_SCRIPTS:
- if (get_path_local(path, "scripts", subfolder, ver)) break;
- if (get_path_user(path, "scripts", subfolder, "BLENDER_USER_SCRIPTS", ver)) break;
+#if defined(WIN32) && BLENDER_VERSION < 258
+ /* if we have a 2.57 installation, then we may have system script
+ * files in the user configuration folder. avoid using that folder
+ * if they are there, until the version gets bumped to 2.58, so
+ * we can be sure that folder only has addons etc. */
+ if (path_have_257_script_install()) {
+ if (get_path_local(path, "scripts", subfolder, ver)) break;
+ }
+ else
+#endif
+ {
+ if (get_path_user(path, "scripts", subfolder, "BLENDER_USER_SCRIPTS", ver)) break;
+ }
+
return NULL;
case BLENDER_SYSTEM_SCRIPTS:
if (get_path_system(path, "scripts", subfolder, "BLENDER_SYSTEM_SCRIPTS", ver)) break;
return NULL;
- case BLENDER_PYTHON: /* general case */
- if (get_path_local(path, "python", subfolder, ver)) break;
- if (get_path_system(path, "python", subfolder, "BLENDER_SYSTEM_PYTHON", ver)) break;
- return NULL;
-
case BLENDER_SYSTEM_PYTHON:
if (get_path_local(path, "python", subfolder, ver)) break;
if (get_path_system(path, "python", subfolder, "BLENDER_SYSTEM_PYTHON", ver)) break;
void ED_file_init(void)
{
- char *cfgdir = BLI_get_folder(BLENDER_CONFIG, NULL);
+ char *cfgdir = BLI_get_folder(BLENDER_USER_CONFIG, NULL);
fsmenu_read_system(fsmenu_get());
PyObject *mod;
/* Needs to be first since this dir is needed for future modules */
- char *modpath= BLI_get_folder(BLENDER_SCRIPTS, "modules");
+ char *modpath= BLI_get_folder(BLENDER_SYSTEM_SCRIPTS, "modules");
if(modpath) {
// printf("bpy: found module path '%s'.\n", modpath);
PyObject *sys_path= PySys_GetObject("path"); /* borrow */
PyImport_ExtendInittab(bpy_internal_modules);
/* allow to use our own included python */
- PyC_SetHomePath(BLI_get_folder(BLENDER_PYTHON, NULL));
+ PyC_SetHomePath(BLI_get_folder(BLENDER_SYSTEM_PYTHON, NULL));
/* Python 3.2 now looks for '2.57/python/include/python3.2d/pyconfig.h' to parse
* from the 'sysconfig' module which is used by 'site', so for now disable site.
struct RecentFile *recent;
char *line;
int num;
- char *cfgdir = BLI_get_folder(BLENDER_CONFIG, NULL);
+ char *cfgdir = BLI_get_folder(BLENDER_USER_CONFIG, NULL);
if (!cfgdir) return;
printf ("\nEnvironment Variables:\n");
printf (" $BLENDER_USER_CONFIG Directory for user configuration files.\n");
- printf (" $BLENDER_SYSTEM_CONFIG Directory for system wide configuration files.\n");
printf (" $BLENDER_USER_SCRIPTS Directory for user scripts.\n");
printf (" $BLENDER_SYSTEM_SCRIPTS Directory for system wide scripts.\n");
printf (" $BLENDER_USER_DATAFILES Directory for user data files (icons, translations, ..).\n");
BLI_argsAdd(ba, 1, NULL, "--factory-startup", "\n\tSkip reading the "STRINGIFY(BLENDER_STARTUP_FILE)" in the users home directory", set_factory_startup, NULL);
/* TODO, add user env vars? */
- BLI_argsAdd(ba, 1, NULL, "--env-system-config", "\n\tSet the "STRINGIFY_ARG(BLENDER_SYSTEM_CONFIG)" environment variable", set_env, NULL);
BLI_argsAdd(ba, 1, NULL, "--env-system-datafiles", "\n\tSet the "STRINGIFY_ARG(BLENDER_SYSTEM_DATAFILES)" environment variable", set_env, NULL);
BLI_argsAdd(ba, 1, NULL, "--env-system-scripts", "\n\tSet the "STRINGIFY_ARG(BLENDER_SYSTEM_SCRIPTS)" environment variable", set_env, NULL);
BLI_argsAdd(ba, 1, NULL, "--env-system-plugins", "\n\tSet the "STRINGIFY_ARG(BLENDER_SYSTEM_PLUGINS)" environment variable", set_env, NULL);
PyImport_ExtendInittab(bge_internal_modules);
/* find local python installation */
- PyC_SetHomePath(BLI_get_folder(BLENDER_PYTHON, NULL));
+ PyC_SetHomePath(BLI_get_folder(BLENDER_SYSTEM_PYTHON, NULL));
Py_Initialize();