diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-04-05 13:33:28 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-04-05 13:33:28 +0400 |
commit | 165a40e7425baa8ffe9acc2b972014c9702e84c4 (patch) | |
tree | fdcd36b1a4624b39e0e65d4c5524dca11b7eb2e4 | |
parent | 1f45f5c15d542fb0f17ea8debc86b0af22f4dfdb (diff) |
add support for installing addons to custom script path [#26751] installing addon to custom script directory doesn't work
-rw-r--r-- | release/scripts/startup/bl_ui/space_userpref.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 4a45b55c010..13ff09d7f23 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -21,7 +21,7 @@ import bpy import os import addon_utils -from bpy.props import StringProperty, BoolProperty +from bpy.props import StringProperty, BoolProperty, EnumProperty def ui_items_general(col, context): @@ -1044,6 +1044,10 @@ class WM_OT_addon_install(bpy.types.Operator): bl_label = "Install Add-On..." overwrite = BoolProperty(name="Overwrite", description="Remove existing addons with the same ID", default=True) + target = EnumProperty( + name="Target Path", + items=(('DEFAULT', "Default", ""), + ('PREFS', "User Prefs", ""))) filepath = StringProperty(name="File Path", description="File path to write file to") filter_folder = BoolProperty(name="Filter folders", description="", default=True, options={'HIDDEN'}) @@ -1070,13 +1074,22 @@ class WM_OT_addon_install(bpy.types.Operator): pyfile = self.filepath - # dont use bpy.utils.script_paths("addons") because we may not be able to write to it. - path_addons = bpy.utils.user_resource('SCRIPTS', "addons", create=True) + if self.target == 'DEFAULT': + # dont use bpy.utils.script_paths("addons") because we may not be able to write to it. + path_addons = bpy.utils.user_resource('SCRIPTS', "addons", create=True) + else: + path_addons = bpy.context.user_preferences.filepaths.script_directory + if path_addons: + path_addons = os.path.join(path_addons, "addons") if not path_addons: self.report({'ERROR'}, "Failed to get addons path") return {'CANCELLED'} + # create dir is if missing. + if not os.path.exists(path_addons): + os.makedirs(path_addons) + # Check if we are installing from a target path, # doing so causes 2+ addons of same name or when the same from/to # location is used, removal of the file! |