From 36cbf80470f44866026cfb4428680155f6361a59 Mon Sep 17 00:00:00 2001 From: winsanyu <973530837@qq.com> Date: Sun, 14 Jun 2026 16:12:42 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat(runner):=20=E6=94=AF=E6=8C=81=E6=BA=90?= =?UTF-8?q?=E7=A0=81=E6=A8=A1=E5=BC=8F=E8=BF=90=E8=A1=8C=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E9=93=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/script_chainer/utils/runner_utils.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/script_chainer/utils/runner_utils.py b/src/script_chainer/utils/runner_utils.py index c467b76..49a1ddc 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 pathlib import Path def build_runner_command(chain_name: str, script_index: int | None = None) -> tuple[list[str], str | None]: @@ -13,9 +14,6 @@ def build_runner_command(chain_name: str, script_index: int | None = None) -> tu Returns: 启动命令及其工作目录。 - - Raises: - RuntimeError: 源码模式下不支持运行脚本链。 """ if getattr(sys, 'frozen', False): command = [ @@ -27,5 +25,18 @@ def build_runner_command(chain_name: str, script_index: int | None = None) -> tu if script_index is not None: command.extend(['--debug-index', str(script_index)]) return command, os.path.dirname(sys.executable) or None - - raise RuntimeError('源码模式下不支持运行脚本链,请使用打包后的程序。') + else: # 源码模式 + command = [ + sys.executable, + "-m", + "src.script_chainer.win_exe.launcher", + "--onedragon", + "--chain", + chain_name, + ] + if script_index is not None: + command.extend(["--debug-index", str(script_index)]) + # 根据该文件路径OneDragon-ScriptChainer\\src\\script_chainer\\utils\\runner_utils.py + # 上跳三级得到仓库根目录 OneDragon-ScriptChainer + repo_root = str(Path(__file__).resolve().parents[3]) + return command, repo_root \ No newline at end of file From 338ceb7101703a3adad7d2e102f78a332516bc20 Mon Sep 17 00:00:00 2001 From: winsanyu <973530837@qq.com> Date: Sun, 14 Jun 2026 16:35:27 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=94=B9=E4=B8=BA=E7=9B=B4=E6=8E=A5?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=B7=AF=E5=BE=84=E6=89=A7=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/script_chainer/utils/runner_utils.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/script_chainer/utils/runner_utils.py b/src/script_chainer/utils/runner_utils.py index 49a1ddc..770e070 100644 --- a/src/script_chainer/utils/runner_utils.py +++ b/src/script_chainer/utils/runner_utils.py @@ -26,17 +26,17 @@ def build_runner_command(chain_name: str, script_index: int | None = None) -> tu command.extend(['--debug-index', str(script_index)]) return command, os.path.dirname(sys.executable) or None else: # 源码模式 + # 根据该文件路径OneDragon-ScriptChainer\\src\\script_chainer\\utils\\runner_utils.py + # 上跳三级得到仓库根目录 OneDragon-ScriptChainer + repo_root = str(Path(__file__).resolve().parents[3]) + launcher_path = os.path.join(repo_root, "src", "script_chainer", "win_exe", "launcher.py") command = [ sys.executable, - "-m", - "src.script_chainer.win_exe.launcher", + launcher_path, "--onedragon", "--chain", chain_name, ] if script_index is not None: command.extend(["--debug-index", str(script_index)]) - # 根据该文件路径OneDragon-ScriptChainer\\src\\script_chainer\\utils\\runner_utils.py - # 上跳三级得到仓库根目录 OneDragon-ScriptChainer - repo_root = str(Path(__file__).resolve().parents[3]) return command, repo_root \ No newline at end of file From cd3ac74f50040504fe9d82f94f45be8993859144 Mon Sep 17 00:00:00 2001 From: winsanyu <973530837@qq.com> Date: Sun, 14 Jun 2026 17:13:01 +0800 Subject: [PATCH 3/5] refine code --- src/script_chainer/utils/runner_utils.py | 30 +++++++++++------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/script_chainer/utils/runner_utils.py b/src/script_chainer/utils/runner_utils.py index 770e070..43b7680 100644 --- a/src/script_chainer/utils/runner_utils.py +++ b/src/script_chainer/utils/runner_utils.py @@ -15,28 +15,26 @@ def build_runner_command(chain_name: str, script_index: int | None = None) -> tu Returns: 启动命令及其工作目录。 """ + 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, - '--onedragon', - '--chain', - chain_name, - ] - if script_index is not None: - command.extend(['--debug-index', str(script_index)]) + command = [sys.executable, *common_args] return command, os.path.dirname(sys.executable) or None else: # 源码模式 + file_path = Path(__file__).resolve() + if len(file_path.parents) < 4: + raise RuntimeError(f"无法确定仓库根目录: {file_path}") + # 根据该文件路径OneDragon-ScriptChainer\\src\\script_chainer\\utils\\runner_utils.py # 上跳三级得到仓库根目录 OneDragon-ScriptChainer - repo_root = str(Path(__file__).resolve().parents[3]) - launcher_path = os.path.join(repo_root, "src", "script_chainer", "win_exe", "launcher.py") + repo_root = str(file_path.parents[3]) + launcher_path = str(Path(repo_root) / "src" / "script_chainer" / "win_exe" / "launcher.py") command = [ sys.executable, launcher_path, - "--onedragon", - "--chain", - chain_name, + *common_args, ] - if script_index is not None: - command.extend(["--debug-index", str(script_index)]) - return command, repo_root \ No newline at end of file + return command, repo_root From c5269faa3dee428b1af90fc25b08d14a70d966d4 Mon Sep 17 00:00:00 2001 From: winsanyu <973530837@qq.com> Date: Mon, 15 Jun 2026 13:07:32 +0800 Subject: [PATCH 4/5] refine code --- src/script_chainer/utils/runner_utils.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/script_chainer/utils/runner_utils.py b/src/script_chainer/utils/runner_utils.py index 43b7680..106c676 100644 --- a/src/script_chainer/utils/runner_utils.py +++ b/src/script_chainer/utils/runner_utils.py @@ -2,9 +2,14 @@ import os import sys -from pathlib import Path +from one_dragon.utils.os_utils import get_work_dir, get_path_under_work_dir +def get_launcher_path() -> str: + """获取 launcher 路径。""" + repo_root = get_work_dir() + return get_path_under_work_dir(repo_root, "src", "script_chainer", "win_exe", "launcher.py") + def build_runner_command(chain_name: str, script_index: int | None = None) -> tuple[list[str], str | None]: """构造 runner 启动命令。 @@ -24,14 +29,8 @@ def build_runner_command(chain_name: str, script_index: int | None = None) -> tu command = [sys.executable, *common_args] return command, os.path.dirname(sys.executable) or None else: # 源码模式 - file_path = Path(__file__).resolve() - if len(file_path.parents) < 4: - raise RuntimeError(f"无法确定仓库根目录: {file_path}") - - # 根据该文件路径OneDragon-ScriptChainer\\src\\script_chainer\\utils\\runner_utils.py - # 上跳三级得到仓库根目录 OneDragon-ScriptChainer - repo_root = str(file_path.parents[3]) - launcher_path = str(Path(repo_root) / "src" / "script_chainer" / "win_exe" / "launcher.py") + repo_root = get_work_dir() + launcher_path = get_launcher_path() command = [ sys.executable, launcher_path, From 63171417709b12736b221652530fef8685ea6f25 Mon Sep 17 00:00:00 2001 From: winsanyu <973530837@qq.com> Date: Mon, 15 Jun 2026 13:17:14 +0800 Subject: [PATCH 5/5] fix get_launcher_path --- src/script_chainer/utils/runner_utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/script_chainer/utils/runner_utils.py b/src/script_chainer/utils/runner_utils.py index 106c676..1f05f19 100644 --- a/src/script_chainer/utils/runner_utils.py +++ b/src/script_chainer/utils/runner_utils.py @@ -7,8 +7,7 @@ def get_launcher_path() -> str: """获取 launcher 路径。""" - repo_root = get_work_dir() - return get_path_under_work_dir(repo_root, "src", "script_chainer", "win_exe", "launcher.py") + return get_path_under_work_dir("src", "script_chainer", "win_exe", "launcher.py") def build_runner_command(chain_name: str, script_index: int | None = None) -> tuple[list[str], str | None]: """构造 runner 启动命令。