From b289e7d17cc8e23f8b3884c4b6c1f783e20caf3e Mon Sep 17 00:00:00 2001 From: qing <1776177662@qq.com> Date: Fri, 14 Aug 2026 09:34:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(pybot):=20Windows=20=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E5=85=BC=E5=AE=B9=EF=BC=88scripts=20?= =?UTF-8?q?=E8=BD=AF=E9=93=BE=E8=A7=A3=E6=9E=90=E3=80=81os.pathsep=20?= =?UTF-8?q?=E5=88=86=E9=9A=94=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - conftest:pybot/scripts 为 git 符号链接,Windows 落盘为文本文件(内容=目标相对路径),测试时手动解析到 bot4cj/scripts - plugin:PYBOT_MODULES_PATH 改按 os.pathsep 分隔,避免 Windows 盘符冒号被切碎导致 find_module 返回丢盘符的路径 --- pybot/pybot/plugin.py | 2 +- pybot/tests/conftest.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pybot/pybot/plugin.py b/pybot/pybot/plugin.py index 1e3c931..1f499a2 100644 --- a/pybot/pybot/plugin.py +++ b/pybot/pybot/plugin.py @@ -52,7 +52,7 @@ def search_dirs(): """插件搜索目录(按优先级):$PYBOT_MODULES_PATH → 包内置 → cwd""" dirs = [] env = os.environ.get("PYBOT_MODULES_PATH", "") - for p in env.split(":"): + for p in env.split(os.pathsep): if p: dirs.append(Path(p)) dirs.append(Path(__file__).resolve().parent.parent / "modules") # 包内置 diff --git a/pybot/tests/conftest.py b/pybot/tests/conftest.py index c73806f..961e615 100644 --- a/pybot/tests/conftest.py +++ b/pybot/tests/conftest.py @@ -12,6 +12,9 @@ from pybot.hd import i2c, spi # noqa: E402 SCRIPTS_DIR = ROOT / "scripts" +if not SCRIPTS_DIR.is_dir(): + # Windows:git 符号链接落盘为文本文件(内容 = 目标相对路径),手动解析 + SCRIPTS_DIR = (ROOT / SCRIPTS_DIR.read_text().strip()).resolve() @pytest.fixture()