diff --git a/bioflow_service/app/services/bioflow/extension_exec.py b/bioflow_service/app/services/bioflow/extension_exec.py index 460250c..608f0a9 100644 --- a/bioflow_service/app/services/bioflow/extension_exec.py +++ b/bioflow_service/app/services/bioflow/extension_exec.py @@ -15,6 +15,7 @@ from __future__ import annotations import asyncio import logging +import os import shlex from dataclasses import dataclass, field from pathlib import Path @@ -261,8 +262,22 @@ def _default_exec_config() -> ExtensionExecConfig: def _resolve_extension_entry_dir() -> str: - """宿主入口脚本目录 = repo 根 bioflow_kernel/cli(按 __file__ 推导,零硬编码)。""" + """宿主入口脚本目录 = 部署树 bioflow_kernel/cli(env 优先 + 多候选推导)。 + + 2026-09-15 实测:parents[4] 推导在 175 仓库布局成立,176 部署树路径深度 + 不同 → 找到不存在位置 → 试运行报「入口脚本缺失」。修复: + 1. BIOFLOW_EXT_ENTRY_DIR env 显式指定(部署树配置) + 2. 从 __file__ 向上逐级找 */bioflow_kernel/cli/run_extension.py + 3. 兜底 parents[4] 推导 + """ + env_dir = os.environ.get("BIOFLOW_EXT_ENTRY_DIR", "").strip() + if env_dir and Path(env_dir).is_dir(): + return env_dir here = Path(__file__).resolve() + for parent in [here] + list(here.parents): + candidate = parent / "bioflow_kernel" / "cli" + if (candidate / "run_extension.py").is_file(): + return str(candidate) return str(here.parents[4] / "bioflow_kernel" / "cli")