Skip to content

armgit / peach

Public Imported from GitHub
0

Peach: Local-first video metadata scraper and media manager.

feat(desktop): 将双架构 macOS 安装镜像接入统一发版

Peach local maintenancee958d9f24d50
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index e62b3fbad..2672d4476 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -236,10 +236,95 @@ jobs:
if-no-files-found: ignore
retention-days: 14
+ macos:
+ name: macOS ${{ matrix.arch }} 独立测试包
+ needs: validate
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - arch: arm64
+ runner: macos-15
+ - arch: x86_64
+ runner: macos-15-intel
+ runs-on: ${{ matrix.runner }}
+ timeout-minutes: 30
+ env:
+ MACOSX_DEPLOYMENT_TARGET: '11.0'
+ ARCHFLAGS: '-arch ${{ matrix.arch }}'
+ steps:
+ - uses: actions/checkout@v7
+ - uses: actions/setup-python@v7
+ with:
+ python-version: '3.14'
+ - uses: actions/setup-node@v7
+ with:
+ node-version: '24'
+ cache: npm
+ cache-dependency-path: frontend/package-lock.json
+ - uses: astral-sh/[email protected]
+ with:
+ enable-cache: true
+ cache-dependency-glob: uv.lock
+ - name: 创建原生架构构建环境
+ run: |
+ uv sync --locked --all-extras --python python
+ uv pip check --python .venv/bin/python
+ npm ci --prefix frontend
+ - name: 构建独立应用与拖放安装镜像
+ run: .venv/bin/python scripts/build_macos_standalone.py --target-arch '${{ matrix.arch }}' --destination release
+ - uses: actions/upload-artifact@v7
+ with:
+ name: macos-candidate-${{ matrix.arch }}
+ if-no-files-found: error
+ retention-days: 7
+ path: |
+ release/*.dmg
+ scripts/smoke_macos.py
+ scripts/smoke_desktop.py
+ scripts/MACOS_DOWNLOADS.md
+
+ macos-smoke:
+ name: macOS ${{ matrix.arch }} 仅下载制品验收
+ needs: macos
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - arch: arm64
+ runner: macos-15
+ - arch: x86_64
+ runner: macos-15-intel
+ runs-on: ${{ matrix.runner }}
+ timeout-minutes: 15
+ steps:
+ - uses: actions/download-artifact@v8
+ with:
+ name: macos-candidate-${{ matrix.arch }}
+ - uses: actions/setup-python@v7
+ with:
+ python-version: '3.14'
+ - name: 挂载镜像并在源码树外验证应用
+ shell: bash
+ run: |
+ set -euo pipefail
+ image=(release/*-macos-${{ matrix.arch }}.dmg)
+ test "${#image[@]}" -eq 1
+ mount="$RUNNER_TEMP/Peach-install"
+ mkdir -p "$mount"
+ hdiutil verify "${image[0]}"
+ hdiutil attach "${image[0]}" -readonly -nobrowse -mountpoint "$mount"
+ trap 'hdiutil detach "$mount"' EXIT
+ test "$(readlink "$mount/Applications")" = /Applications
+ test -s "$mount/Peach.app/Contents/Resources/LICENSE"
+ codesign --verify --deep --strict "$mount/Peach.app"
+ lipo -verify_arch '${{ matrix.arch }}' "$mount/Peach.app/Contents/MacOS/Peach"
+ python scripts/smoke_macos.py "$mount/Peach.app"
+
release:
name: GitHub 预发布
if: github.ref_type == 'tag'
- needs: [windows, desktop-smoke]
+ needs: [windows, desktop-smoke, macos-smoke]
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
@@ -249,6 +334,11 @@ jobs:
with:
name: desktop-candidate
path: release
+ - uses: actions/download-artifact@v8
+ with:
+ pattern: macos-candidate-*
+ merge-multiple: true
+ path: macos-candidates
- name: 创建预发布
env:
GH_TOKEN: ${{ github.token }}
@@ -256,8 +346,10 @@ jobs:
VERSION: ${{ needs.windows.outputs.version }}
run: |
cd release
- sha256sum ./*.zip ./*-setup.exe > SHA256SUMS.txt
- gh release create "$GITHUB_REF_NAME" ./*.zip ./*-setup.exe SHA256SUMS.txt --verify-tag --prerelease --title "Peach $VERSION · Windows 测试版" --notes-file RELEASE_NOTES.md
+ cp ../macos-candidates/release/*.dmg .
+ tail -n +4 ../macos-candidates/scripts/MACOS_DOWNLOADS.md >> RELEASE_NOTES.md
+ sha256sum ./*.zip ./*-setup.exe ./*.dmg > SHA256SUMS.txt
+ gh release create "$GITHUB_REF_NAME" ./*.zip ./*-setup.exe ./*.dmg SHA256SUMS.txt --verify-tag --prerelease --title "Peach $VERSION · Windows / macOS 测试版" --notes-file RELEASE_NOTES.md
project-board:
name: 同步已发布版本到看板
diff --git a/README.en.md b/README.en.md
index ab107557f..9633824de 100644
--- a/README.en.md
+++ b/README.en.md
@@ -8,7 +8,7 @@
<p align="center">
<a href="https://peach.video">Website</a> ·
- <a href="https://github.com/peach-mitao/peach/releases">Download for Windows</a> ·
+ <a href="https://github.com/peach-mitao/peach/releases">Download installers</a> ·
<a href="https://demo.peach.video">Live demo</a> ·
<a href="https://github.com/peach-mitao/peach/releases/tag/intro-video">Intro video</a> ·
<a href="https://github.com/peach-mitao/peach/issues">Report a problem</a> ·
@@ -23,7 +23,7 @@
<a href="https://github.com/peach-mitao/peach/actions/workflows/test.yml"><img src="https://img.shields.io/github/actions/workflow/status/peach-mitao/peach/test.yml?branch=master&amp;label=tests&amp;logo=githubactions&amp;logoColor=white" alt="CI status"></a>
<a href="LICENSE"><img src="https://img.shields.io/badge/license-AGPL--3.0--or--later-blue?logo=gnu&amp;logoColor=white" alt="license"></a>
<a href="docs/TESTING_DESKTOP.md"><img src="https://img.shields.io/badge/Windows-x64-0078D4" alt="Windows x64"></a>
- <a href="docs/OPERATIONS.md#从源码运行windowsmacos"><img src="https://img.shields.io/badge/macOS-source-555555?logo=apple&amp;logoColor=white" alt="macOS from source"></a>
+ <a href="docs/OPERATIONS.md#macos-独立测试包"><img src="https://img.shields.io/badge/macOS-DMG-555555?logo=apple&amp;logoColor=white" alt="Build and install the standalone macOS app"></a>
<img src="https://img.shields.io/badge/18%2B-adult%20content-critical" alt="18+ adult content">
</p>
@@ -96,6 +96,8 @@ Test builds are unsigned. If Windows says “Windows protected your PC”, confi
Build a self-contained `.app` and DMG locally on macOS. Running it requires neither Python, a source checkout, nor another computer. See [the macOS build guide](docs/OPERATIONS.md#macos-独立测试包).
+The release workflow generates separate Apple Silicon (`macos-arm64.dmg`) and Intel (`macos-x86_64.dmg`) test packages. Check the actual assets on [Releases](https://github.com/peach-mitao/peach/releases) for availability. Check your chip in About This Mac, open the matching image, and drag Peach into Applications. Test packages are not notarized; media tools must be installed separately.
+
### Run from source (Windows, macOS)
Requires Git, uv and Python 3.14 or newer. See [running from source](docs/OPERATIONS.md#从源码运行windowsmacos).
diff --git a/README.md b/README.md
index 64cb0ce6f..8e9719155 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@
<p align="center">
<a href="https://peach.video">官网</a> ·
- <a href="https://github.com/peach-mitao/peach/releases">下载 Windows 版</a> ·
+ <a href="https://github.com/peach-mitao/peach/releases">下载安装包</a> ·
<a href="https://demo.peach.video">在线演示</a> ·
<a href="https://github.com/peach-mitao/peach/releases/tag/intro-video">介绍视频</a> ·
<a href="https://github.com/peach-mitao/peach/issues">问题反馈</a> ·
@@ -23,7 +23,7 @@
<a href="https://github.com/peach-mitao/peach/actions/workflows/test.yml"><img src="https://img.shields.io/github/actions/workflow/status/peach-mitao/peach/test.yml?branch=master&amp;label=tests&amp;logo=githubactions&amp;logoColor=white" alt="CI 状态"></a>
<a href="LICENSE"><img src="https://img.shields.io/badge/license-AGPL--3.0--or--later-blue?logo=gnu&amp;logoColor=white" alt="license"></a>
<a href="docs/TESTING_DESKTOP.md"><img src="https://img.shields.io/badge/Windows-x64-0078D4" alt="Windows x64"></a>
- <a href="docs/OPERATIONS.md#从源码运行windowsmacos"><img src="https://img.shields.io/badge/macOS-source-555555?logo=apple&amp;logoColor=white" alt="macOS 源码运行"></a>
+ <a href="docs/OPERATIONS.md#macos-独立测试包"><img src="https://img.shields.io/badge/macOS-DMG-555555?logo=apple&amp;logoColor=white" alt="macOS 独立应用构建与安装"></a>
<img src="https://img.shields.io/badge/18%2B-adult%20content-critical" alt="18+ 成人内容">
</p>
@@ -96,6 +96,8 @@ https://github.com/user-attachments/assets/a5610874-e611-41bb-be22-7d99f0d64b62
macOS 可在本机构建独立 `.app` 与 DMG,运行不需要 Python、源码或另一台电脑。构建与安装见 [macOS 独立测试包](docs/OPERATIONS.md#macos-独立测试包)。
+发版流程分别生成 Apple Silicon(`macos-arm64.dmg`)与 Intel(`macos-x86_64.dmg`)测试包;可下载版本以 [Releases](https://github.com/peach-mitao/peach/releases) 的实际资产为准。在「关于本机」确认芯片,打开对应镜像并将 Peach 拖入「应用程序」。测试包未完成 Apple 公证,媒体工具需另行准备。
+
### 从源码运行(Windows、macOS)
需要 Git、uv 和 Python 3.14 或更高,步骤见[源码运行](docs/OPERATIONS.md#从源码运行windowsmacos)。
diff --git a/docs/OPERATIONS.md b/docs/OPERATIONS.md
index 4be43e59b..cc14ed20d 100644
--- a/docs/OPERATIONS.md
+++ b/docs/OPERATIONS.md
@@ -41,6 +41,10 @@ MACOSX_DEPLOYMENT_TARGET=11.0 uv sync --locked --extra build --extra macos
打开匹配架构的 DMG,把 `Peach.app` 拖入 Applications,再打开应用完成首次设置。菜单栏提供打开页面、重启和退出入口;数据默认保存在 `~/Library/Application Support/Peach/peach-data`,可用 `PEACH_DATA_ROOT` 指定独立目录。
+安装镜像使用浅桃色背景,固定左侧 Peach、右侧 Applications 的拖放布局,隐藏工具栏与边栏,背景同时提供标准与 Retina 分辨率。许可证保留在应用的 `Contents/Resources/LICENSE`,安装窗口只显示两个入口。
+
+版本标签触发 Release 工作流,在 Apple Silicon 与 Intel 原生 runner 分别构建,再由干净 runner 下载并挂载 DMG,验证签名、架构和独立运行。两种 DMG 与 Windows 安装包全部通过后,才一同上传到 GitHub 预发布,统一生成 SHA-256 清单。手动运行工作流只验收候选制品,不创建 Release;推送普通提交不会触发安装包构建。发版检查见[测试与依赖](TESTING.md#每次发版检查),打标签统一使用 `scripts/release_tag.py`。
+
Mac 与 Windows 托盘的首层只显示简短状态与提醒数量,展开状态子菜单按行查看服务和媒体来源。长地址与路径会缩略,子菜单中的「查看完整配置」保留完整设置入口;提醒消失后会随下一轮健康检查更新。
单机设置默认关闭账本复制,不需要 Windows、SMB、LaunchAgent 或系统端口转发。各台电脑各自保存数据;共享馆藏仍按下文的[双机复制](#两台电脑之间的复制)配置,离线修改不能自动合并。已有数据目录不会自动导入。
diff --git a/docs/REUSE.md b/docs/REUSE.md
index 346fa8225..73064a093 100644
--- a/docs/REUSE.md
+++ b/docs/REUSE.md
@@ -576,6 +576,7 @@ A 盘垃圾隔离使用短名称 `peach-purge-<32 位 UUID>.peach-quarantine`,
| Windows 托盘 | pystray 0.19.5(LGPLv3)、Pillow、Win32 Per-Monitor V2 DPI | Peach 服务归属、后台更新检查、菜单动作、品牌图标 |
| Windows 托盘恢复 | Windows 自带 `OpenProcess`、`GetProcessTimes`、[`WaitForSingleObject`](https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitforsingleobject)、`GetExitCodeProcess`;Python 3.12+ 标准库 `ctypes` / `subprocess`,无新增依赖或分发体积 | `tray_lifecycle` 保留明确退出意图、创建时间校验、3 次 / 5 分钟预算与重启交接。pystray 0.19.5 的 `_message_handlers` 接收 `WM_STOP` / `WM_ENDSESSION`,已核对安装包源码;Windows 临时进程实验证明强制退出能恢复,明确退出不会恢复。原生 API 随受支持的 Windows 维护;pystray 使用项目固定版本。不采用 Task Scheduler `RestartOnFailure`:它只管理任务启动的实例,桌面快捷方式与现有重启脚本不归其管理;不新增 psutil 运行时依赖,进程句柄已覆盖等待与退出码。已知边界是监视器随整棵进程树被终止时不能恢复。 |
| macOS 菜单栏 | `pyobjc-framework-Cocoa==12.2.2`(MIT)提供 AppKit / PyObjCTools / objc | 附件应用策略、18 pt template 图、服务归属与菜单动作 |
+| macOS 拖放安装镜像 | [dmgbuild 1.6.7](https://github.com/dmgbuild/dmgbuild)(MIT,Python ≥3.10,macOS)直接写 Finder 元数据;仅安装于 `build` extra。纯 Python wheel 约 35 KB,依赖 `ds-store`、`mac-alias`;固定传递版本见 `uv.lock` | 已读取固定版的文件复制、背景多分辨率合成与图标布局实现;背景渲染复用 resvg-py 0.5.0,无运行时新增依赖。Peach 提供 640×420 拖放布局、双分辨率背景和应用内许可证;单元验证配置与图片尺寸,发布验收实际挂载镜像。磁盘镜像创建依赖 macOS 的 hdiutil;无需 Finder 自动化权限,挂载或文件系统失败会终止构建 |
| 人脸取景 | `opencv-python-headless==5.0.0.93`(Apache-2.0)的 `cv2.FaceDetectorYN` + opencv_zoo 定版模型 `face_detection_yunet_2023mar.onnx`(sha256 `8f2383e4…52fa4`,232 KB,放 `peach-data/tools/yunet/`,不进 Git);MetaTube SDK `6a5e6128c725187aeaf921d48ed7d9cd9f30671b` 的主脸聚类只作算法参考 | 头像/封面离线脚本共用 `peach.face_detect`(主脸、归一化焦点与 sidecar)。`detect` 按长边 320/640/1280 各检一次、分数取中位数;`main_face` 先筛掉分数落后最好那张 0.1 以上的框,再取最大。不用 Haar 级联(OpenCV 5 wheel 里没有、检出率低)与 Pigo v1.4.6(有无脸误报)。[实测](SOURCING.md#人脸与水印实测) |
| 人脸比对 | 同一 OpenCV 的 `cv2.FaceRecognizerSF` + opencv_zoo 定版模型 `face_recognition_sface_2021dec.onnx`(sha256 `0ba9fbfa…34e79`,与 LFS 指针的 oid 一致,37 MB,放 `peach-data/tools/sface/`,不进 Git) | `peach.face_match` 提特征、算余弦,阈值用 SFace 官方的 0.363;补头像后继拿图库候选与单人封面截到的脸比(ADR-0056),小脸先放大再检(ADR-0070)。检脸用 `peach.face_detect`,取模型走同一条 `fetch_model`。不引 `face_recognition`/dlib(要编译、体积大)与 InsightFace(模型限非商用、需 onnxruntime)。[实测](SOURCING.md#人脸与水印实测) |
| 头像水印检出 | 同一 OpenCV 的 `cv2.dnn.TextDetectionModel_DB` + opencv_zoo 定版模型 `text_detection_en_ppocrv3_2023may.onnx`(sha256 `03f550c6…66587`,2.4 MB,放 `peach-data/tools/ppocr/`,不进 Git) | `peach.avatar_watermark` 检出,`scripts/scrub_avatar_watermarks.py` 复核与移除。不用 MSER 自写启发式(抓不到半透明水印)。`MIN_SCORE` 0.9、框宽占图宽 ≥ 4%、框整体落在距边 15% 带内;半透明水印给不出框,所以检出只是候选,人看标注图确认、漏的自己补框。移除优先裁边、不 inpaint。[实测](SOURCING.md#人脸与水印实测) |
diff --git a/docs/TESTING.md b/docs/TESTING.md
index 467b15aee..9783d10b5 100644
--- a/docs/TESTING.md
+++ b/docs/TESTING.md
@@ -76,7 +76,7 @@ Python 静态检查使用开发依赖 Ruff,随每个正式测试域扫描全
| 实际依赖、迁移、共享测试设施、未知影响面 | Windows 与 macOS 的 Python 3.14 全量 |
| 手动 CI | 完整系统矩阵 |
| wheel | Windows 与 macOS 各一次 Python 3.14 独立最小安装 |
-| Release | 复用同 SHA 主线成功 CI;构建后执行独立 EXE 冒烟 |
+| Release | 复用同 SHA 主线成功 CI;Windows 独立 EXE 与 Apple Silicon、Intel DMG 分别构建和验收 |
Python 全量按文件稳定分片,Windows 四片、macOS 两片,每片使用独立 runner;汇总任务要求所有分片和计划选择的任务成功。分片子进程不签发记录。
@@ -188,6 +188,8 @@ macOS/Linux 的相同入口:
Windows Release 工作流使用 `uv sync --locked --all-extras` 准备完整依赖。安装目录回归与 PyInstaller 构建共用这份 venv,测试入口按完整锁文件核验依赖。
+macOS Release 使用 `macos-15`(Apple Silicon)和 `macos-15-intel`(Intel)分别构建,解释器、依赖与目标架构必须一致。独立验收任务只下载候选制品与冒烟脚本,挂载只读 DMG,核对 Applications 链接、许可证、签名与原生架构,再执行 `scripts/smoke_macos.py`。该脚本将应用移到源码树外,在移除开发工具的 PATH 下验证首次设置、迁移、单机账本、登录、前端资源与配置保存,数据全部使用临时目录。所有平台验收成功才发布;普通 push 不构建安装包,手动运行 Release 不上传公开资产。
+
`auto` 从同环境、24 小时内的记录计算差异:有效全量基线保留原时间戳;有效局部基线只复用未受差异影响且本次需要的域。相同代码状态补跑缺少的域。新增、删除与修改文件均参与比较;共享设施、未知影响面和环境差异不能复用局部记录。局部记录不会变成全量,继承时间戳不延长有效期。单域失败撤销该域与全量证明,保留其他域的原成功时间;失败域必须补测,不能从旧基线恢复。全量失败撤销所有证明。`-Fresh` 与显式 `full` 始终实际执行。
## 记录的环境身份
diff --git a/docs/TESTING_DESKTOP.md b/docs/TESTING_DESKTOP.md
index 82c899a18..2638cb34c 100644
--- a/docs/TESTING_DESKTOP.md
+++ b/docs/TESTING_DESKTOP.md
@@ -1,6 +1,6 @@
# Windows 测试版
-Windows 版提供完整安装包、轻量安装包和免安装包,均无需另装 Python、Git、Node 或 OpenSSL。macOS 请按[源码运行](OPERATIONS.md#从源码运行windowsmacos)安装。
+Windows 版提供完整安装包、轻量安装包和免安装包,均无需另装 Python、Git、Node 或 OpenSSL。macOS 的 DMG 构建、安装和测试包限制见 [macOS 独立测试包](OPERATIONS.md#macos-独立测试包)。
| 文件 | 用途 |
| --- | --- |
diff --git a/pyproject.toml b/pyproject.toml
index 945547270..000c65593 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -73,7 +73,10 @@ dev = [
"ruff==0.17.1",
"seiso==0.4.0",
]
-build = ["pyinstaller==6.22.3"]
+build = [
+ "pyinstaller==6.22.3",
+ "dmgbuild==1.6.7; sys_platform == 'darwin'",
+]
macos = ["pyobjc-framework-Cocoa==12.2.2; sys_platform == 'darwin'"]
# numpy 本来就是 opencv 的传递依赖,这里显式钉住:`face_detect.decode` 直接 import 它
# 把字节喂给 `cv2.imdecode`,被 import 的外部模块必须有声明的归属。
diff --git a/resources/dmg-background.svg b/resources/dmg-background.svg
new file mode 100644
index 000000000..ddb1e91a8
--- /dev/null
+++ b/resources/dmg-background.svg
@@ -0,0 +1,14 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="640" height="420" viewBox="0 0 640 420">
+ <defs>
+ <radialGradient id="peach" cx="50%" cy="0%" r="78%">
+ <stop stop-color="#fff0e9"/><stop offset="1" stop-color="#fcfaf8"/>
+ </radialGradient>
+ </defs>
+ <path fill="url(#peach)" d="M0 0h640v420H0z"/>
+ <g text-anchor="middle" font-family="PingFang SC, sans-serif">
+ <text x="320" y="62" font-size="24" font-weight="600" fill="#292625">安装 Peach</text>
+ <text x="320" y="94" font-size="14" fill="#82736c">将 Peach 拖到右侧的「应用程序」</text>
+ <text x="320" y="382" font-size="12" fill="#98867b">安装后,从「应用程序」打开 Peach。</text>
+ </g>
+ <path d="M291 220h52m-9-8 9 8-9 8" fill="none" stroke="#bc9a89" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
+</svg>
diff --git a/scripts/MACOS_DOWNLOADS.md b/scripts/MACOS_DOWNLOADS.md
new file mode 100644
index 000000000..7241d2772
--- /dev/null
+++ b/scripts/MACOS_DOWNLOADS.md
@@ -0,0 +1,11 @@
+---
+kind: howto
+---
+
+### macOS 测试包
+
+Apple Silicon 下载文件名含 `macos-arm64.dmg` 的安装镜像;Intel 下载含 `macos-x86_64.dmg` 的安装镜像。在「关于本机」中查看芯片或处理器。打开镜像,将 Peach 拖入「应用程序」,再打开应用完成首次设置。
+
+应用内置 Python,可独立运行;单机使用不依赖 Windows。测试包使用 ad-hoc 签名,尚未完成 Developer ID 签名与 Apple 公证。媒体工具需另行准备,macOS 暂无在线更新安装器。系统版本下限以包内 `LSMinimumSystemVersion` 为准。
+
+安装、来源挂载与双机复制见 [macOS 使用说明](https://github.com/peach-mitao/peach/blob/master/docs/OPERATIONS.md#macos-独立测试包)。各架构的原生构建、镜像挂载与独立运行通过后,两个 DMG 才会随同一 Release 上传;哈希包含在 `SHA256SUMS.txt`。
diff --git a/scripts/build_macos_standalone.py b/scripts/build_macos_standalone.py
index a75aa319b..7f78d8ec8 100644
--- a/scripts/build_macos_standalone.py
+++ b/scripts/build_macos_standalone.py
@@ -43,19 +43,30 @@ def minimum_system_version(app: Path) -> str:
def package_dmg(app: Path, destination: Path) -> Path:
- """镜像只携带应用、Applications 快捷入口与许可证。"""
+ """以固定拖放布局分发应用,许可证随应用资源保留。"""
if not (app / "Contents" / "MacOS" / "Peach").is_file():
raise FileNotFoundError(f"找不到应用可执行文件:{app}")
destination.parent.mkdir(parents=True, exist_ok=True)
+ from dmgbuild import build_dmg
+ from resvg_py import svg_to_bytes
+
with tempfile.TemporaryDirectory(prefix="peach-dmg-") as directory:
staging = Path(directory)
- shutil.copytree(app, staging / "Peach.app", symlinks=True)
- (staging / "Applications").symlink_to("/Applications", target_is_directory=True)
- shutil.copy2(ROOT / "LICENSE", staging / "LICENSE.txt")
- subprocess.run([
- "hdiutil", "create", "-volname", "Peach", "-srcfolder", str(staging),
- "-format", "UDZO", "-ov", str(destination),
- ], check=True)
+ source = str(ROOT / "resources" / "dmg-background.svg")
+ background = staging / "background.png"
+ for scale in (1, 2):
+ path = background if scale == 1 else staging / "[email protected]"
+ path.write_bytes(svg_to_bytes(svg_path=source, zoom=scale))
+ build_dmg(str(destination), "Peach", settings={
+ "format": "UDZO", "files": [str(app)],
+ "symlinks": {"Applications": "/Applications"},
+ "background": str(background), "window_rect": ((160, 160), (640, 420)),
+ "icon_locations": {"Peach.app": (174, 220), "Applications": (466, 220)},
+ "icon_size": 128, "text_size": 13, "hide_extensions": ["Peach.app"],
+ "default_view": "icon-view", "arrange_by": None,
+ "show_toolbar": False, "show_sidebar": False, "show_status_bar": False,
+ "show_tab_view": False, "show_pathbar": False,
+ })
return destination
diff --git a/scripts/peach_macos.spec b/scripts/peach_macos.spec
index d4e6a6a7d..971f86a95 100644
--- a/scripts/peach_macos.spec
+++ b/scripts/peach_macos.spec
@@ -15,6 +15,7 @@ identity = Path(os.environ["PEACH_MACOS_BUILD_INFO"])
version = json.loads(identity.read_text(encoding="utf-8"))["version"]
datas = [(str(root / name), name) for name in ("web", "migrations", "resources")]
datas += [(str(identity), "."), (str(root / "scripts" / "standalone.txt"), ".")]
+datas += [(str(root / "LICENSE"), ".")]
datas += copy_metadata("sentry-sdk")
binaries = []
hiddenimports = [
diff --git a/tests/test_dependency_policy.py b/tests/test_dependency_policy.py
index d44978f18..ad48e0896 100644
--- a/tests/test_dependency_policy.py
+++ b/tests/test_dependency_policy.py
@@ -103,6 +103,7 @@ class DependencyPolicyTests(unittest.TestCase):
"bs4": "beautifulsoup4",
"curl_cffi": "curl_cffi",
"cv2": "opencv-python-headless",
+ "dmgbuild": "dmgbuild",
"fastapi": "fastapi",
"filelock": "filelock",
"google": "protobuf",
diff --git a/tests/test_macos_standalone.py b/tests/test_macos_standalone.py
index 7a105142b..fffe17d1a 100644
--- a/tests/test_macos_standalone.py
+++ b/tests/test_macos_standalone.py
@@ -34,16 +34,27 @@ class MacStandaloneDistributionTests(TestCase):
(resource / "runtime").symlink_to("../MacOS/Peach")
destination = self.root / "release" / "Peach.dmg"
- def create_image(command, *, check):
- staging = Path(command[command.index("-srcfolder") + 1])
- self.assertEqual((staging / "Applications").readlink(), Path("/Applications"))
- copied = staging / "Peach.app" / "Contents" / "Resources" / "runtime"
- self.assertEqual(copied.read_bytes(), b"native executable")
- self.assertTrue(copied.is_symlink())
- self.assertTrue((staging / "LICENSE.txt").is_file())
+ def create_image(filename, volume_name, *, settings):
+ from PIL import Image
+
+ self.assertEqual(filename, str(destination))
+ self.assertEqual(volume_name, "Peach")
+ self.assertEqual(settings["files"], [str(app)])
+ self.assertEqual(settings["symlinks"], {"Applications": "/Applications"})
+ self.assertTrue((resource / "runtime").is_symlink())
+ self.assertEqual((resource / "runtime").read_bytes(), b"native executable")
+ self.assertEqual(settings["icon_locations"],
+ {"Peach.app": (174, 220), "Applications": (466, 220)})
+ background = Path(settings["background"])
+ for path, dimensions in ((background, (640, 420)),
+ (background.with_name("[email protected]"), (1280, 840))):
+ with Image.open(path) as image:
+ self.assertEqual(image.size, dimensions)
+ self.assertFalse(settings["show_toolbar"])
+ self.assertFalse(settings["show_sidebar"])
destination.write_bytes(b"disk image")
- with mock.patch.object(self.builder.subprocess, "run", side_effect=create_image):
+ with mock.patch.dict(sys.modules, {"dmgbuild": SimpleNamespace(build_dmg=create_image)}):
result = self.builder.package_dmg(app, destination)
self.assertEqual(result.read_bytes(), b"disk image")
self.assertTrue((resource / "runtime").is_symlink())
diff --git a/uv.lock b/uv.lock
index d64144c70..145a228c2 100644
--- a/uv.lock
+++ b/uv.lock
@@ -414,6 +414,31 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/18/8f/9354e5552982d38abd3ce2db859f049fee6bff0eee4e25aacaaa2b29f0b4/curl_cffi-0.16.3-cp314-cp314t-win_arm64.whl", hash = "sha256:b450fad876aa9f9ed3edfb6e3a48a8c28eafa66aae634eff17800a8b5006568d", size = 1782234, upload-time = "2026-09-02T11:58:21.629Z" },
]
+[[package]]
+name = "dmgbuild"
+version = "1.6.7"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "ds-store" },
+ { name = "mac-alias" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/a7/a5/f4dbd63c96902de8f2427a82518aaeedac0006587409294e55a14e45f367/dmgbuild-1.6.7.tar.gz", hash = "sha256:676b17acd448899f6d4a83b2184e0657480444ecb6ac9c4922889efad9e5dbfb", size = 36938, upload-time = "2026-01-15T23:13:43.779Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/6c/4a/8812638bba991a55a4b670806ab9cf60207077401893bb308eb1b04f288c/dmgbuild-1.6.7-py3-none-any.whl", hash = "sha256:37ee5771c377beb3203d9164aae8046ffed8531c06edf9227f5788b3c599b1bf", size = 34853, upload-time = "2026-01-15T23:13:41.854Z" },
+]
+
+[[package]]
+name = "ds-store"
+version = "1.3.3"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "mac-alias" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/65/88/6b56e5648599959735be58281b15e6955c735b759e475a72236f85e28ffe/ds_store-1.3.3.tar.gz", hash = "sha256:a7380896ea1e880f7ba07c5cdc24bd1530fb86836cad0be531f3e80e2d721ac5", size = 27503, upload-time = "2026-06-23T00:17:51.642Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/66/c0/718a4132306ff8ff052f2c40595f45595993b480409400d55b07f3842d45/ds_store-1.3.3-py3-none-any.whl", hash = "sha256:b92a371efbf1b4ccce2a04d1ed13fceacc4736c81ba09cf5aefb74c088160a35", size = 16292, upload-time = "2026-06-23T00:17:50.202Z" },
+]
+
[[package]]
name = "ed2k"
version = "0.0.2.2"
@@ -699,6 +724,15 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/f8/31/50f3c38b38ff28635ff9c4a4afefddccc5f1b57457b539bdbdf75ce18669/m3u8-6.0.0-py3-none-any.whl", hash = "sha256:566d0748739c552dad10f8c87150078de6a0ec25071fa48e6968e96fc6dcba5d", size = 24133, upload-time = "2024-08-07T11:20:03.96Z" },
]
+[[package]]
+name = "mac-alias"
+version = "2.2.3"
+source = { registry = "https://pypi.org/simple" }
+sdist = { url = "https://files.pythonhosted.org/packages/fb/c9/2c28b2ea968a6bbc4327c0360b746fda3757cb11cf287d00078cf81a27e2/mac_alias-2.2.3.tar.gz", hash = "sha256:1c7fa367687d66979f2ce4d1a8b2716cf1c9fb811741cab3cf3ca356555c2beb", size = 33860, upload-time = "2025-12-04T00:58:13.679Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/13/20/103f4e4a6e8a524ea92eee7d938c6133d0b129aa999a50f8648ad126c728/mac_alias-2.2.3-py3-none-any.whl", hash = "sha256:7362b521d2132ef92f606a37abfed5fcd849ceb2f28b6f9743e014b02af92f0d", size = 21127, upload-time = "2025-12-04T00:58:11.931Z" },
+]
+
[[package]]
name = "macholib"
version = "1.16.4"
@@ -1067,6 +1101,7 @@ dependencies = [
[package.optional-dependencies]
build = [
+ { name = "dmgbuild", marker = "sys_platform == 'darwin'" },
{ name = "pyinstaller" },
]
dev = [
@@ -1097,6 +1132,7 @@ requires-dist = [
{ name = "bencode2", specifier = "==0.3.38" },
{ name = "browserexport", specifier = "==0.4.4" },
{ name = "curl-cffi", specifier = "==0.16.3" },
+ { name = "dmgbuild", marker = "sys_platform == 'darwin' and extra == 'build'", specifier = "==1.6.7" },
{ name = "fastapi", specifier = "==0.143.2" },
{ name = "filelock", specifier = "==4.2.0" },
{ name = "filelock", marker = "extra == 'dev'", specifier = "==4.2.0" },