diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-05-04 12:44:08 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-05-04 12:44:08 +0400 |
commit | 5a0dca41e5aed566ce6427c863c2f3072f7d044c (patch) | |
tree | fd6b22154d6fb4c1ab2914cafa29377e6f25346f /release/scripts/modules/bpy/utils.py | |
parent | 7c5d6c9c39cb7caf1c334295e60f0454b270bfd2 (diff) |
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.
Diffstat (limited to 'release/scripts/modules/bpy/utils.py')
-rw-r--r-- | release/scripts/modules/bpy/utils.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/release/scripts/modules/bpy/utils.py b/release/scripts/modules/bpy/utils.py index 96967a8e4be..27ac1d6ea79 100644 --- a/release/scripts/modules/bpy/utils.py +++ b/release/scripts/modules/bpy/utils.py @@ -33,6 +33,7 @@ import sys as _sys 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 @@ def load_scripts(reload_scripts=False, refresh_scripts=False): _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 @@ def script_paths(subdir=None, user_pref=True, all=False): 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 @@ def script_paths(subdir=None, user_pref=True, all=False): 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 |