Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storage and Local directory paths #144

Merged
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,23 @@ Environment variables that are set during startup:
- **AYON_HEADLESS_MODE** - Headless mode flag enabled when set to '1'.
- **AYON_EXECUTABLE** - Path to executable that is used to run AYON.
- **AYON_ROOT** - Root to AYON launcher content.
- **AYON_LAUNCHER_STORAGE_DIR** - Directory where are stored dependency packages, addons and files related to addons. At own risk can be shared (NOT TESTED).
- **AYON_LAUNCHER_LOCAL_DIR** - Directory where are stored user/machine specific files. This MUST NOT be shared.
- **AYON_ADDONS_DIR** - Path to AYON addons directory - Still used but considered as deprecated. Please rather use 'AYON_LAUNCHER_STORAGE_DIR' to change location.
- **AYON_DEPENDENCIES_DIR** - Path to AYON dependencies directory - Still used but considered as deprecated. Please rather use 'AYON_LAUNCHER_STORAGE_DIR' to change location.

> [!NOTE]
> Environment variables **AYON_LAUNCHER_STORAGE_DIR** and **AYON_LAUNCHER_LOCAL_DIR** are by default set to the same folder. Path is based on OS.
> - Windows: `%LOCALAPPDATA%\Ynput\AYON`
> - Linux: `~/.local/share/AYON`
> - macOS: `~/Library/Application Support/AYON`
> It is required to set the environment variables before AYON launcher is started as it is required for bootstrap.

> [!TIP]
> Environment variables **AYON_ADDONS_DIR** and **AYON_DEPENDENCIES_DIR** by default lead relative to **AYON_LAUNCHER_STORAGE_DIR**.
> - **AYON_ADDONS_DIR** -> `{AYON_LAUNCHER_STORAGE_DIR}/addons`
> - **AYON_DEPENDENCIES_DIR** -> `{AYON_LAUNCHER_STORAGE_DIR}/dependency_packages`
> Changing their values will change where addons and dependency packages are stored even if you change **AYON_LAUNCHER_STORAGE_DIR**!

- **AYON_MENU_LABEL** - Label for AYON menu -> TODO move to openpype addon.
- **PYBLISH_GUI** - Default pyblish UI that should be used in pyblish -> TODO move to openpype addon.
Expand Down
4 changes: 4 additions & 0 deletions common/ayon_common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
is_dev_mode_enabled,
get_local_site_id,
get_ayon_appdirs,
get_launcher_local_dir,
get_launcher_storage_dir,
get_ayon_launch_args,
get_downloads_dir,
get_archive_ext_and_type,
Expand All @@ -21,6 +23,8 @@
"is_dev_mode_enabled",
"get_local_site_id",
"get_ayon_appdirs",
"get_launcher_local_dir",
"get_launcher_storage_dir",
"get_ayon_launch_args",
"get_downloads_dir",
"get_archive_ext_and_type",
Expand Down
4 changes: 2 additions & 2 deletions common/ayon_common/connection/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
)

from ayon_common.utils import (
get_ayon_appdirs,
get_launcher_local_dir,
get_local_site_id,
get_ayon_launch_args,
)
Expand Down Expand Up @@ -56,7 +56,7 @@ def __init__(


def _get_servers_path():
return get_ayon_appdirs("used_servers.json")
return get_launcher_local_dir("used_servers.json")


def _get_ui_dir_path(*args) -> str:
Expand Down
29 changes: 7 additions & 22 deletions common/ayon_common/distribution/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,7 @@
import subprocess
import tempfile

from ayon_common.utils import get_ayon_appdirs, get_ayon_launch_args


def get_local_dir(*subdirs):
"""Get product directory in user's home directory.

Each user on machine have own local directory where are downloaded updates,
addons etc.

Returns:
str: Path to product local directory.
"""

if not subdirs:
raise ValueError("Must fill dir_name if nothing else provided!")

local_dir = get_ayon_appdirs(*subdirs)
os.makedirs(local_dir, exist_ok=True)

return local_dir
from ayon_common.utils import get_launcher_storage_dir, get_ayon_launch_args


def get_addons_dir():
Expand All @@ -40,7 +21,9 @@ def get_addons_dir():

addons_dir = os.environ.get("AYON_ADDONS_DIR")
if not addons_dir:
addons_dir = get_local_dir("addons")
addons_dir = get_launcher_storage_dir(
"addons", create=True
)
os.environ["AYON_ADDONS_DIR"] = addons_dir
return addons_dir

Expand All @@ -60,7 +43,9 @@ def get_dependencies_dir():

dependencies_dir = os.environ.get("AYON_DEPENDENCIES_DIR")
if not dependencies_dir:
dependencies_dir = get_local_dir("dependency_packages")
dependencies_dir = get_launcher_storage_dir(
"dependency_packages", create=True
)
os.environ["AYON_DEPENDENCIES_DIR"] = dependencies_dir
return dependencies_dir

Expand Down
Loading