fix: APP_ROOT handles both root/ and app/ script locations

This commit is contained in:
yumoqing 2026-05-05 14:15:59 +08:00
parent 77cdacf878
commit b4785d49ab
2 changed files with 12 additions and 2 deletions

View File

@ -32,7 +32,12 @@ import importlib.util
# 配置 # 配置
# ============================================================ # ============================================================
APP_ROOT = os.path.dirname(os.path.abspath(__file__)) _script_dir = os.path.dirname(os.path.abspath(__file__))
# 脚本可能在项目根目录或 app/ 子目录,统一指向项目根
if os.path.basename(_script_dir) == 'app':
APP_ROOT = os.path.dirname(_script_dir)
else:
APP_ROOT = _script_dir
sys.path.insert(0, APP_ROOT) sys.path.insert(0, APP_ROOT)
# perm_config.py 路径 # perm_config.py 路径

View File

@ -32,7 +32,12 @@ import importlib.util
# 配置 # 配置
# ============================================================ # ============================================================
APP_ROOT = os.path.dirname(os.path.abspath(__file__)) _script_dir = os.path.dirname(os.path.abspath(__file__))
# 脚本可能在项目根目录或 app/ 子目录,统一指向项目根
if os.path.basename(_script_dir) == 'app':
APP_ROOT = os.path.dirname(_script_dir)
else:
APP_ROOT = _script_dir
sys.path.insert(0, APP_ROOT) sys.path.insert(0, APP_ROOT)
# perm_config.py 路径 # perm_config.py 路径