2.7 KiB
2.7 KiB
开发说明(开发 / 打包 / 安装 / 更新)
运行环境
- 系统:Windows 10/11
- Python:建议与当前项目一致的版本(你本机是 3.14)
- 依赖:见
requirements.txt
安装依赖:
python -m pip install -r requirements.txt
python -m pip install pyinstaller
本地运行
python main.py
版本号
- 版本号来源:
app_info.py里的__VERSION__ - 安装包 AppVersion:由
installer/build_installer.py自动从app_info.py注入到installer/niumasoftware.generated.iss
数据库存储与结构升级(SQLite Migration)
- 数据文件位置:默认在
%APPDATA%\CleanDesktopOrganizer\data.db(不在安装目录,不会被覆盖更新影响) - 结构升级:在
db/database.py内通过schema_version做版本化迁移- 新增表/字段/索引:新增一个迁移版本并提升
LATEST_SCHEMA_VERSION - 启动时
init_db()自动从旧版本迁移到最新
- 新增表/字段/索引:新增一个迁移版本并提升
一键打包(推荐)
项目根目录直接运行:
.\build_installer.bat
它会自动完成:
- 清理
build/、dist/ - PyInstaller 打包主程序(onedir)到
dist\niumasoftware\ - PyInstaller 打包更新助手(onefile)到
dist\niumasoftware\update_helper.exe - 生成
installer\niumasoftware.generated.iss - 若检测到 Inno Setup 的
ISCC.exe,则自动编译安装包
手动打包(PyInstaller)
主程序(onedir):
python -m PyInstaller --noconfirm --onedir --name niumasoftware --windowed `
--icon "logo.ico" `
--add-data "assets;assets" `
--add-data "logo.png;." `
main.py
更新助手(onefile,统一输出到 dist\niumasoftware):
python -m PyInstaller --noconfirm --onefile --name update_helper --console --distpath dist\niumasoftware `
--icon "logo.ico" `
update_helper.py
产物约定(用于安装包脚本):
dist\niumasoftware\niumasoftware.exedist\niumasoftware\update_helper.exe
生成安装包(Inno Setup)
- 生成带版本号的最终脚本:
python installer/build_installer.py
- 用 Inno Setup Compiler 编译:
installer/niumasoftware.generated.iss
全局安装后的静默覆盖更新(计划任务)
由于安装目录通常在 Program Files,普通权限无法覆盖 exe。
实现方式(已内置):
- 主程序下载更新到:
{commonappdata}\CleanDesktopOrganizer\updates\_update_new.exe - 写入请求:
{commonappdata}\CleanDesktopOrganizer\update_request.json - 触发计划任务:
schtasks /Run /TN CleanDesktopOrganizer\Update - 计划任务以 SYSTEM 执行
{app}\update_helper.exe覆盖并重启