diff --git a/scripts/modules/bpy_types.py b/scripts/modules/bpy_types.py index dd5cbd2b49c..a9562854030 100644 --- a/scripts/modules/bpy_types.py +++ b/scripts/modules/bpy_types.py @@ -1320,9 +1320,14 @@ class UserExtensionRepo(StructRNA): """Return ``directory`` or a default path derived from the users scripts path.""" if self.use_custom_directory: return self.custom_directory - import os import bpy - return os.path.join(bpy.utils.user_resource('SCRIPTS', path="extensions"), self.module) + import os + # TODO: this should eventually be accessed via `bpy.utils.user_resource('EXTENSIONS')` + # which points to the same location (by default). + if (path := bpy.utils.resource_path('USER')): + return os.path.join(path, "extensions", self.module) + # Unlikely this is ever encountered. + return "" class HydraRenderEngine(RenderEngine): diff --git a/source/blender/blenkernel/intern/preferences.cc b/source/blender/blenkernel/intern/preferences.cc index 88bc0d78407..155b92eb2ca 100644 --- a/source/blender/blenkernel/intern/preferences.cc +++ b/source/blender/blenkernel/intern/preferences.cc @@ -242,15 +242,14 @@ void BKE_preferences_extension_repo_dirpath_get(const bUserExtensionRepo *repo, return; } - char subdir[16 + sizeof(bUserExtensionRepo::module)]; - BLI_string_join(subdir, sizeof(subdir), "extensions", SEP_STR, repo->module); - const std::optional path = BKE_appdir_folder_id(BLENDER_USER_SCRIPTS, subdir); - if (path.has_value()) { - BLI_strncpy(dirpath, path.value().c_str(), dirpath_maxncpy); - } - else { + /* TODO: support `BLENDER_USER_EXTENSIONS`, until then add to user resource. */ + std::optional path = BKE_appdir_resource_path_id(BLENDER_RESOURCE_PATH_USER, false); + /* Highly unlikely to fail as the directory doesn't have to exist. */ + if (!path) { dirpath[0] = '\0'; + return; } + BLI_path_join(dirpath, dirpath_maxncpy, path.value().c_str(), "extensions", repo->module); } bUserExtensionRepo *BKE_preferences_extension_repo_find_index(const UserDef *userdef, int index) diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 53a66012f99..96977c5cd11 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -625,7 +625,7 @@ typedef struct bUserExtensionRepo { /** * The "local" directory where extensions are stored. - * When unset, use `{BLENDER_USER_SCRIPTS}/extensions/{bUserExtensionRepo::module}`. + * When unset, use `{BLENDER_RESOURCE_PATH_USER}/extensions/{bUserExtensionRepo::module}`. */ char custom_dirpath[1024]; /* FILE_MAX */ char remote_path[1024]; /* FILE_MAX */