-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuildLibotApp.command
More file actions
executable file
·64 lines (51 loc) · 1.96 KB
/
BuildLibotApp.command
File metadata and controls
executable file
·64 lines (51 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/zsh
set -euo pipefail
# One-click builder for a double-clickable macOS .app via PyInstaller.
SCRIPT_DIR="${0:A:h}"
cd "$SCRIPT_DIR"
if command -v python3 >/dev/null 2>&1; then
PY="python3"
elif command -v python >/dev/null 2>&1; then
PY="python"
else
echo "ERROR: 找不到 python3/python。请先安装 Python 3。"
exit 1
fi
VENV_DIR=".venv"
if [[ ! -x "$VENV_DIR/bin/python" ]]; then
echo "[Libot] 创建虚拟环境:$VENV_DIR"
"$PY" -m venv "$VENV_DIR"
fi
VPY="$VENV_DIR/bin/python"
echo "[Libot] 升级 pip"
"$VPY" -m pip install -U pip >/dev/null
echo "[Libot] 安装/更新依赖(含 GUI):.[gui]"
"$VPY" -m pip install -e ".[gui]"
echo "[Libot] 安装 PyInstaller"
"$VPY" -m pip install -U pyinstaller
echo "[Libot] 开始打包(会生成 dist/Libot.app)"
ADD_DATA_ARGS=()
if [[ -f "libot_bundled.json" ]]; then
echo "[Libot] 打包内置配置:libot_bundled.json"
ADD_DATA_ARGS+=(--add-data "libot_bundled.json:.")
elif [[ -f "libot_bundled.example.json" ]]; then
echo "[Libot] 未找到 libot_bundled.json,将使用空模板 libot_bundled.example.json"
ADD_DATA_ARGS+=(--add-data "libot_bundled.example.json:.")
fi
"$VPY" -m PyInstaller \
-y --clean \
--name Libot \
--windowed \
"${ADD_DATA_ARGS[@]}" \
app_gui.py
echo "[Libot] 打包完成:dist/Libot.app"
INFO_PLIST="dist/Libot.app/Contents/Info.plist"
if [[ -f "$INFO_PLIST" ]]; then
echo "[Libot] 设置为菜单栏应用(隐藏 Dock 图标):LSUIElement=1"
/usr/libexec/PlistBuddy -c "Add :LSUIElement bool true" "$INFO_PLIST" >/dev/null 2>&1 || \
/usr/libexec/PlistBuddy -c "Set :LSUIElement true" "$INFO_PLIST" >/dev/null 2>&1 || true
echo "[Libot] 尝试禁用 App Nap:NSAppSleepDisabled=1"
/usr/libexec/PlistBuddy -c "Add :NSAppSleepDisabled bool true" "$INFO_PLIST" >/dev/null 2>&1 || \
/usr/libexec/PlistBuddy -c "Set :NSAppSleepDisabled true" "$INFO_PLIST" >/dev/null 2>&1 || true
fi
echo "[Libot] 你可以在 Finder 里打开 dist/Libot.app"