[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36478] trunk/blender/release/scripts: fix 2 bugs with addon installation
Campbell Barton
ideasman42 at gmail.com
Wed May 4 10:44:08 CEST 2011
Revision: 36478
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36478
Author: campbellbarton
Date: 2011-05-04 08:44:08 +0000 (Wed, 04 May 2011)
Log Message:
-----------
fix 2 bugs with addon installation
- installing an addon which creates a new script directory didn't add this to the sys.path.
- installing the addon was meant to set the search string to the addon name but was broken.
Modified Paths:
--------------
trunk/blender/release/scripts/modules/bpy/utils.py
trunk/blender/release/scripts/startup/bl_ui/space_userpref.py
Modified: trunk/blender/release/scripts/modules/bpy/utils.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy/utils.py 2011-05-04 06:45:58 UTC (rev 36477)
+++ trunk/blender/release/scripts/modules/bpy/utils.py 2011-05-04 08:44:08 UTC (rev 36478)
@@ -33,6 +33,7 @@
import addon_utils as _addon_utils
+_script_module_dirs = "startup", "modules"
def _test_import(module_name, loaded_modules):
use_time = _bpy.app.debug
@@ -183,7 +184,7 @@
_global_loaded_modules[:] = []
for base_path in script_paths():
- for path_subdir in ("startup", "modules"):
+ for path_subdir in _script_module_dirs:
path = _os.path.join(base_path, path_subdir)
if _os.path.isdir(path):
_sys_path_ensure(path)
@@ -260,7 +261,7 @@
if path not in scripts and _os.path.isdir(path):
scripts.append(path)
- if not subdir:
+ if subdir is None:
return scripts
script_paths = []
@@ -272,6 +273,24 @@
return script_paths
+def refresh_script_paths():
+ """
+ Run this after creating new script paths to update sys.path
+ """
+
+ for base_path in script_paths():
+ for path_subdir in _script_module_dirs:
+ path = _os.path.join(base_path, path_subdir)
+ if _os.path.isdir(path):
+ _sys_path_ensure(path)
+
+ for path in _addon_utils.paths():
+ _sys_path_ensure(path)
+ path = _os.path.join(path, "modules")
+ if _os.path.isdir(path):
+ _sys_path_ensure(path)
+
+
_presets = _os.path.join(_scripts[0], "presets") # FIXME - multiple paths
Modified: trunk/blender/release/scripts/startup/bl_ui/space_userpref.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_userpref.py 2011-05-04 06:45:58 UTC (rev 36477)
+++ trunk/blender/release/scripts/startup/bl_ui/space_userpref.py 2011-05-04 08:44:08 UTC (rev 36478)
@@ -1106,7 +1106,8 @@
del pyfile_dir
# done checking for exceptional case
- contents = set(os.listdir(path_addons))
+ addon_files_old = set(os.listdir(path_addons))
+ addons_old = {mod.__name__ for mod in addon_utils.modules(USERPREF_PT_addons._addons_fake_modules)}
#check to see if the file is in compressed format (.zip)
if zipfile.is_zipfile(pyfile):
@@ -1155,11 +1156,13 @@
traceback.print_exc()
return {'CANCELLED'}
+ addons_new = {mod.__name__ for mod in addon_utils.modules(USERPREF_PT_addons._addons_fake_modules)} - addons_old
+ addons_new.discard("modules")
+
# disable any addons we may have enabled previously and removed.
# this is unlikely but do just incase. bug [#23978]
- addons_new = set(os.listdir(path_addons)) - contents
for new_addon in addons_new:
- addon_utils.disable(os.path.splitext(new_addon)[0])
+ addon_utils.disable(new_addon)
# possible the zip contains multiple addons, we could disallow this
# but for now just use the first
@@ -1172,6 +1175,9 @@
context.window_manager.addon_search = info["name"]
break
+ # incase a new module path was created to install this addon.
+ bpy.utils.refresh_script_paths()
+
# TODO, should not be a warning.
# self.report({'WARNING'}, "File installed to '%s'\n" % path_dest)
return {'FINISHED'}
More information about the Bf-blender-cvs
mailing list