Peach: Local-first video metadata scraper and media manager.
fix(build): resolve bundled resource root
longmeidao3daa64bf711d
diff --git a/docs/HANDOFF.md b/docs/HANDOFF.mdindex 0e4b5089f..d4af474fb 100644--- a/docs/HANDOFF.md+++ b/docs/HANDOFF.md@@ -180,7 +180,7 @@ Claude 的 `.claude/settings.json` 已配置 Stop、StopFailure、SessionEnd hoo- Windows 日常入口是当前用户 Startup 中的唯一 `Peach.lnk`,指向 `C:\Users\longm\Desktop\peach\peach-app\dist\Peach\Peach.exe`。`R:\peach-app` 是迁移前的旧位置,不再用作运行入口。- Windows 发布入口使用 `scripts/build_windows.ps1`:先用 `scripts/generate_brand_assets.py` 从原始附件生成正方形 `resources/peach-logo.png` 和多尺寸 `resources/peach.ico`,再构建单一 `dist/Peach/Peach.exe`。无参数运行托盘,`serve`/`migrate` 运行 CLI;桌面快捷方式由 `scripts/create_desktop_shortcut.ps1` 创建,图标使用 `Peach.exe,0`,行为与 FlowLens 的快捷方式一致;Startup 安装仍由 `scripts/manage_tray_startup.ps1` 负责。-- `dist/Peach/Peach.exe` 是本机打包入口,不是可移动的独立发行版:托盘只打包了自己,服务进程仍由项目 venv 的 `peach.exe` 承担(`_peach_executable()` 从 exe 位置逐级向上找 `.venv\Scripts\peach.exe`)。脱离同一台机器的项目 `.venv` 复制不会工作,不要按「单文件绿色版」对外描述。+- `dist/Peach/Peach.exe` 是本机打包入口,不是可移动的独立发行版:托盘只打包了自己,服务进程仍由项目 venv 的 `peach.exe` 承担(`_peach_executable()` 从 exe 位置逐级向上找 `.venv\Scripts\peach.exe`)。脱离同一台机器的项目 `.venv` 复制不会工作,不要按「单文件绿色版」对外描述。PyInstaller 的资源直接位于 `sys._MEIPASS`,没有源码树的 `src/` 层;打包后的 `migrate`、Web 与品牌资源必须从这里解析,不能再对 `config.py` 固定取 `parents[2]`。- 托盘单击打开 HTTPS;macOS/Windows 菜单都提供「同步 Ledger」「接管 Ledger 写入」、状态、重启、日志和退出。HTTP/HTTPS 服务只观察角色,不自动复制;手动同步先停止自己创建的服务,再用 SQLite backup API 与原子替换复制,最后恢复服务。共享源在 macOS smbfs 上必须以 immutable 已关闭快照读取;共享目标不能由 SQLite 直接打开事务连接。健康端口不归本托盘时拒绝接管。- 创建 Win32 窗口前必须启用 Per-Monitor V2 DPI。正常动作不弹模态 MessageBox;更新检查在后台线程执行,用 pystray 原生非模态通知反馈。- `src/peach/__init__.py::__version__` 是版本唯一来源;采用 pre-1.0 SemVer。Git commit 是构建标识,`vX.Y.Z` 是本地发布点。更新检查只 fetch/比较,并行 worktree 模式下不自动覆盖安装。diff --git a/docs/STATUS.md b/docs/STATUS.mdindex ab3322deb..19f930c15 100644--- a/docs/STATUS.md+++ b/docs/STATUS.md@@ -174,7 +174,7 @@## 验证基线-- 2026-08-25 Windows `0.6.4`:`& .\scripts\test.ps1` 全量 640 项通过、12 项按平台跳过;新增迁移、数据事务、API、页面源与媒体删除引用测试均通过。+- 2026-08-25 Windows `0.6.4`:`& .\scripts\test.ps1` 全量 641 项通过、12 项按平台跳过;新增迁移、数据事务、API、页面源、媒体删除引用与 PyInstaller 资源根测试均通过。- 当前主分支基线:2026-08-25 于 macOS 主目录实测 `./scripts/test.sh` 全量 608 项通过、4 项按平台跳过。不接受「只跑本批相关」的缩水口径。覆盖版本、托盘、迁移、mDNS、媒体转码、Provider、DiskGuard、语义路由、标准 Range、Video.js、稳定时长、详情播放释放、多选、实体资料、分页性能边界、搜索历史、广告判据,以及回收站的还原/彻底删除/清空与删不掉文件的降级。- 前一生产版本已分别通过 HTTP/HTTPS health、`peach.local` 解析、真实 CloudDrive Range、桌面 1280×720 和手机 390×844 检查。本次 HLS 代码已切换生产托盘;真实资产 `31222/MIDE-981-C.mp4` 的中段 HLS 片段在严格 CA HTTPS 下返回 `200`、约 9.7 MB,响应后的临时文件已清理。尚未完成浏览器 seek 和手机 HLS 视觉验收。- 浏览器验收不得写真实喜欢、反馈或播放数据;需要交互写入时使用隔离 ledger 副本。diff --git a/src/peach/config.py b/src/peach/config.pyindex 463938ddb..3ad7d8bc3 100644--- a/src/peach/config.py+++ b/src/peach/config.py@@ -1,11 +1,18 @@import os+import sysfrom dataclasses import dataclassfrom pathlib import Pathfrom .platform import translate_ledger_path, translate_roots-PROJECT_ROOT = Path(__file__).resolve().parents[2]+def _project_root(module_file=__file__, bundle_root=None) -> Path:+ """源码树保留 `src/` 层;PyInstaller 的资源直接落在 `_MEIPASS`。"""+ return (Path(bundle_root) if bundle_root is not None+ else Path(module_file).resolve().parents[2])+++PROJECT_ROOT = _project_root(bundle_root=getattr(sys, "_MEIPASS", None))# 运行数据目录按平台给默认值,两个平台各自持有一份可独立运行的 peach-data。# `PEACH_DATA_ROOT` 覆盖默认值;worktree 也靠这个绝对路径找到同一份数据。diff --git a/tests/test_config.py b/tests/test_config.pyindex 6b4ef60ca..939346a7b 100644--- a/tests/test_config.py+++ b/tests/test_config.py@@ -6,6 +6,14 @@ from peach import configclass DefaultPathTests(unittest.TestCase):+ def test_project_root_uses_pyinstaller_resource_directory_without_a_src_layer(self):+ source = Path("C:/repo/src/peach/config.py")+ self.assertEqual(config._project_root(source), Path("C:/repo"))+ self.assertEqual(+ config._project_root(source, "C:/bundle/_MEI123"),+ Path("C:/bundle/_MEI123"),+ )+def test_windows_runtime_defaults_to_the_desktop_project(self):project = Path.home() / "Desktop" / "peach"self.assertEqual(config._WINDOWS_DATA_ROOT, project / "peach-data")