Extensions: default to paths in {BLENDER_RESOURCE_PATH_USER}/extensions

Replace: {BLENDER_RESOURCE_PATH_USER}/scripts/extensions
With:    {BLENDER_RESOURCE_PATH_USER}/extensions

This makes more sense as not all extensions are scripts.
This commit is contained in:
Campbell Barton
2024-02-03 14:12:36 +11:00
parent 547516a3ba
commit 63ce2fbc0c
3 changed files with 14 additions and 10 deletions
+7 -2
View File
@@ -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):
@@ -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<std::string> 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<std::string> 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)
+1 -1
View File
@@ -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 */