fix(load_path): app根从脚本自身位置上溯三级解析(~/pipeline在部署机不存在)

This commit is contained in:
yumoqing 2026-08-28 16:39:39 +08:00
parent 34a13ebf37
commit a484e5f46c

View File

@ -15,9 +15,19 @@ PATHS_LOGINED = [
def main():
root = os.path.expanduser("~/pipeline")
if not os.path.isfile(os.path.join(root, "set_role_perm.py")):
print("ERROR: pipeline root not found")
# app root: 本脚本位于 <app>/pkgs/<mod>/scripts/,上溯三级即 app 根
script_dir = os.path.dirname(os.path.abspath(__file__))
candidates = [
os.path.dirname(os.path.dirname(os.path.dirname(script_dir))),
os.path.expanduser("~/pipeline"),
]
root = None
for c in candidates:
if os.path.isfile(os.path.join(c, "set_role_perm.py")):
root = c
break
if not root:
print("ERROR: pipeline root not found (set_role_perm.py missing)")
sys.exit(1)
set_perm = os.path.join(root, "set_role_perm.py")
py = sys.executable