diff --git a/src/script_chainer/utils/runner_utils.py b/src/script_chainer/utils/runner_utils.py index c467b76..998b7d5 100644 --- a/src/script_chainer/utils/runner_utils.py +++ b/src/script_chainer/utils/runner_utils.py @@ -2,6 +2,7 @@ import os import sys +from one_dragon.utils.os_utils import get_path_under_work_dir def build_runner_command(chain_name: str, script_index: int | None = None) -> tuple[list[str], str | None]: @@ -13,19 +14,21 @@ def build_runner_command(chain_name: str, script_index: int | None = None) -> tu Returns: 启动命令及其工作目录。 - - Raises: - RuntimeError: 源码模式下不支持运行脚本链。 """ + common_args = ["--onedragon", "--chain", chain_name] + if script_index is not None: + common_args.extend(["--debug-index", str(script_index)]) + + # 可执行文件模式 if getattr(sys, 'frozen', False): + command = [sys.executable, *common_args] + return command, os.path.dirname(sys.executable) or None + else: # 源码模式 + launcher_work_dir = get_path_under_work_dir("src") command = [ sys.executable, - '--onedragon', - '--chain', - chain_name, + "-m", + "script_chainer.win_exe.launcher", + *common_args, ] - if script_index is not None: - command.extend(['--debug-index', str(script_index)]) - return command, os.path.dirname(sys.executable) or None - - raise RuntimeError('源码模式下不支持运行脚本链,请使用打包后的程序。') + return command, launcher_work_dir