-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
111 lines (102 loc) · 3.8 KB
/
Copy pathbuild.sh
File metadata and controls
111 lines (102 loc) · 3.8 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
set -e
echo "========================================"
echo " NotebookLM 切分工具 - 打包程式"
echo "========================================"
echo
# 檢測作業系統
if [[ "$OSTYPE" == "darwin"* ]]; then
OS="macOS"
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
OS="Linux"
else
OS="Unknown"
fi
echo "[1/3] 安裝 / 更新依賴與 PyInstaller..."
python -m pip install --quiet -r requirements.txt
python -m pip install --quiet --upgrade pyinstaller
echo "[2/3] 清除舊的打包結果..."
rm -rf dist build "NotebookLM切分工具.spec" 2>/dev/null || true
# 自動下載 FFmpeg 二進位(若尚未存在)
mkdir -p assets/ffmpeg
if [[ "$OSTYPE" == "darwin"* ]]; then
if [[ ! -f "assets/ffmpeg/ffmpeg" ]]; then
FFMPEG_BIN=$(command -v ffmpeg || true)
FFPROBE_BIN=$(command -v ffprobe || true)
if [[ -n "$FFMPEG_BIN" && -n "$FFPROBE_BIN" ]]; then
echo "複製系統 FFmpeg 至 assets/ffmpeg/..."
cp "$FFMPEG_BIN" assets/ffmpeg/ffmpeg
cp "$FFPROBE_BIN" assets/ffmpeg/ffprobe
else
echo "下載 FFmpeg (macOS)..."
brew install ffmpeg 2>/dev/null || {
echo "警告:無法自動安裝 FFmpeg,請手動安裝後再試。"
}
FFMPEG_BIN=$(command -v ffmpeg || true)
FFPROBE_BIN=$(command -v ffprobe || true)
[[ -n "$FFMPEG_BIN" ]] && cp "$FFMPEG_BIN" assets/ffmpeg/ffmpeg
[[ -n "$FFPROBE_BIN" ]] && cp "$FFPROBE_BIN" assets/ffmpeg/ffprobe
fi
fi
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
if ! command -v ffmpeg &>/dev/null && [[ ! -f "assets/ffmpeg/ffmpeg" ]]; then
echo "下載 FFmpeg (Linux)..."
sudo apt-get install -y ffmpeg 2>/dev/null || \
sudo dnf install -y ffmpeg 2>/dev/null || {
echo "警告:無法自動安裝 FFmpeg,請手動安裝後再試。"
}
fi
else
# Windows (Git Bash / MSYS2)
if [[ ! -f "assets/ffmpeg/ffmpeg.exe" ]]; then
echo "下載 FFmpeg (Windows)..."
FFMPEG_URL="https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip"
curl -L --progress-bar "$FFMPEG_URL" -o _ffmpeg_tmp.zip
unzip -q _ffmpeg_tmp.zip "*/bin/ffmpeg.exe" "*/bin/ffprobe.exe" -d _ffmpeg_extract
find _ffmpeg_extract -name "ffmpeg.exe" -exec cp {} assets/ffmpeg/ \;
find _ffmpeg_extract -name "ffprobe.exe" -exec cp {} assets/ffmpeg/ \;
rm -rf _ffmpeg_tmp.zip _ffmpeg_extract
echo "FFmpeg 已下載至 assets/ffmpeg/"
fi
fi
echo "[3/3] 開始打包..."
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS: 打包成 .app 應用程式包
echo "偵測到 macOS,打包成 .app..."
python -m PyInstaller --windowed --onedir \
--name "NotebookLM切分工具" \
--add-data "assets:assets" \
--collect-all tkinterdnd2 \
--collect-all customtkinter \
main.py
OUTPUT_PATH="dist/NotebookLM切分工具.app"
else
# Linux / Windows: 打包成獨立執行檔
echo "打包成獨立執行檔..."
python -m PyInstaller --onefile --windowed \
--name "NotebookLM切分工具" \
--add-data "assets:assets" \
--collect-all tkinterdnd2 \
--collect-all customtkinter \
main.py
OUTPUT_PATH="dist/NotebookLM切分工具"
fi
if [ $? -eq 0 ]; then
echo
echo "========================================"
echo " 打包完成!($OS)"
echo " 執行檔位置:$OUTPUT_PATH"
echo "========================================"
# 跨平台打開 dist 文件夾
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
explorer dist
elif [[ "$OSTYPE" == "darwin"* ]]; then
open dist
else
xdg-open dist 2>/dev/null || true
fi
else
echo
echo "錯誤:打包失敗,請查看上方錯誤訊息"
exit 1
fi