refactor(pyinstaller): 优化打包配置和日志处理

重构打包配置,使用新的spec文件生成单个exe文件
修复日志处理中可能存在的None值问题
添加clean.py脚本用于清理打包残留文件
更新SKILL.md文档说明打包流程
This commit is contained in:
2026-01-15 15:32:23 +08:00
parent 2a560108df
commit 597172acdb
7 changed files with 49 additions and 7 deletions

View File

@@ -0,0 +1,17 @@
---
name: pyinstaller-one
description: 当执行pyinstaller打包的时候执行这个技能。
---
## 元数据
name: pyinstaller个性化打包
description: 打包的时候要求生成为一个exe文件使用ico等等
## 概述
此 Skill 用于给有GUI界面的python代码打包的时候生成一个统一的要求生成一个exe文件去掉控制台窗口使用本目录下的ico文件作为程序的图标。打包时如果之前有打包过的文件dist/build 文件夹),自动覆盖旧文件,不用手动确认,一键打包到底。
## 打包命令示例
pyinstaller --onefile --noconsole --icon=图标文件名.ico --distpath=. --hidden-import=PySide6.Qt6Compat python程序名.py
## 清除多余文件
在windows环境下执行clean.py

View File

@@ -0,0 +1,17 @@
import os
import shutil
import glob
import subprocess
# 2. 清理打包残留文件 等价rd /s /q build + del /f *.spec
print("开始清理打包残留文件...")
# 删除build文件夹
if os.path.exists("build") and os.path.isdir("build"):
shutil.rmtree("build")
# 删除所有.spec文件
spec_files = glob.glob("*.spec")
for spec_file in spec_files:
if os.path.exists(spec_file):
os.remove(spec_file)
print("✅ 打包完成 + 残留文件清理完毕exe文件已生成在当前目录")