Todo: 修改因exe_token错误导致的不断重连问题
Todo: 修改打包中.bat打包文件与测试打包脚本不一致问题 New: 新增installer安装包环境搭建数据
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
import os
|
||||
import subprocess
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def clean_build():
|
||||
@@ -96,17 +97,31 @@ def build_with_command():
|
||||
print("✅ 打包成功!")
|
||||
print("📁 打包结果: dist/main/")
|
||||
|
||||
# 重命名目录
|
||||
# 重命名目录为统一的输出路径
|
||||
if os.path.exists('dist/main'):
|
||||
try:
|
||||
# 如果目标目录已存在,先删除
|
||||
if os.path.exists('dist/MultiPlatformGUI'):
|
||||
print("🗑️ 删除旧的 MultiPlatformGUI 目录...")
|
||||
shutil.rmtree('dist/MultiPlatformGUI')
|
||||
|
||||
# 重命名
|
||||
os.rename('dist/main', 'dist/MultiPlatformGUI')
|
||||
print("✅ 已重命名为: dist/MultiPlatformGUI/")
|
||||
|
||||
# 验证重命名结果
|
||||
if os.path.exists('dist/MultiPlatformGUI/main.exe'):
|
||||
exe_size = os.path.getsize('dist/MultiPlatformGUI/main.exe') / 1024 / 1024
|
||||
print(f"✅ 主程序验证通过: main.exe ({exe_size:.1f} MB)")
|
||||
else:
|
||||
print("⚠️ 重命名后主程序文件验证失败")
|
||||
|
||||
except Exception as e:
|
||||
print(f"⚠️ 重命名失败: {e}")
|
||||
print("💡 可以手动重命名: dist/main -> dist/MultiPlatformGUI")
|
||||
print("📁 当前可用路径: dist/main/")
|
||||
else:
|
||||
print("⚠️ 未找到 dist/main 目录,重命名跳过")
|
||||
|
||||
# 创建使用说明
|
||||
try:
|
||||
@@ -221,31 +236,62 @@ def verify_result():
|
||||
"""验证打包结果"""
|
||||
print("\n🔍 验证打包结果...")
|
||||
|
||||
# 先检查MultiPlatformGUI,再检查main目录
|
||||
base_dirs = ["dist/MultiPlatformGUI", "dist/main"]
|
||||
# 优先检查MultiPlatformGUI(标准输出目录)
|
||||
target_dir = "dist/MultiPlatformGUI"
|
||||
fallback_dir = "dist/main"
|
||||
|
||||
for base_dir in base_dirs:
|
||||
if os.path.exists(base_dir):
|
||||
exe_path = f"{base_dir}/main.exe"
|
||||
dll_path = f"{base_dir}/_internal/Utils/PythonNew32/SaiNiuApi.dll"
|
||||
if os.path.exists(target_dir):
|
||||
return _verify_directory(target_dir)
|
||||
elif os.path.exists(fallback_dir):
|
||||
print(f"⚠️ 发现备用目录: {fallback_dir}")
|
||||
print("💡 建议重命名为: dist/MultiPlatformGUI")
|
||||
return _verify_directory(fallback_dir)
|
||||
else:
|
||||
print("❌ 未找到任何打包输出目录")
|
||||
return False
|
||||
|
||||
if os.path.exists(exe_path):
|
||||
size = os.path.getsize(exe_path)
|
||||
print(f"✅ 主程序: {exe_path} ({size:,} bytes)")
|
||||
def _verify_directory(base_dir):
|
||||
"""验证指定目录的打包结果"""
|
||||
exe_path = f"{base_dir}/main.exe"
|
||||
internal_dir = f"{base_dir}/_internal"
|
||||
dll_path = f"{base_dir}/_internal/Utils/PythonNew32/SaiNiuApi.dll"
|
||||
static_dir = f"{base_dir}/_internal/static"
|
||||
|
||||
if os.path.exists(dll_path):
|
||||
dll_size = os.path.getsize(dll_path)
|
||||
print(f"✅ 千牛DLL: SaiNiuApi.dll ({dll_size:,} bytes)")
|
||||
print(f"📁 有效路径: {base_dir}/")
|
||||
print("✅ 验证通过")
|
||||
return True
|
||||
else:
|
||||
print("❌ 千牛DLL不存在")
|
||||
else:
|
||||
print(f"❌ {exe_path} 不存在")
|
||||
print(f"📁 验证目录: {base_dir}")
|
||||
|
||||
# 检查主程序
|
||||
if os.path.exists(exe_path):
|
||||
size = os.path.getsize(exe_path) / 1024 / 1024 # MB
|
||||
print(f"✅ 主程序: main.exe ({size:.1f} MB)")
|
||||
else:
|
||||
print("❌ 主程序 main.exe 不存在")
|
||||
return False
|
||||
|
||||
print("❌ 未找到有效的打包结果")
|
||||
return False
|
||||
# 检查_internal目录
|
||||
if os.path.exists(internal_dir):
|
||||
file_count = len([f for f in os.listdir(internal_dir) if os.path.isfile(os.path.join(internal_dir, f))])
|
||||
dir_count = len([d for d in os.listdir(internal_dir) if os.path.isdir(os.path.join(internal_dir, d))])
|
||||
print(f"✅ 依赖目录: _internal/ ({file_count} 个文件, {dir_count} 个子目录)")
|
||||
else:
|
||||
print("❌ _internal 目录不存在")
|
||||
return False
|
||||
|
||||
# 检查关键DLL(可选)
|
||||
if os.path.exists(dll_path):
|
||||
dll_size = os.path.getsize(dll_path) / 1024 # KB
|
||||
print(f"✅ 千牛DLL: SaiNiuApi.dll ({dll_size:.1f} KB)")
|
||||
else:
|
||||
print("⚠️ 千牛DLL不存在(可能正常)")
|
||||
|
||||
# 检查静态资源
|
||||
if os.path.exists(static_dir):
|
||||
icon_files = list(Path(static_dir).glob("*.png"))
|
||||
print(f"✅ 静态资源: static/ ({len(icon_files)} 个图标文件)")
|
||||
else:
|
||||
print("⚠️ static 目录不存在")
|
||||
|
||||
print(f"✅ 目录 {base_dir} 验证通过")
|
||||
return True
|
||||
|
||||
|
||||
def main():
|
||||
@@ -296,10 +342,11 @@ def main():
|
||||
if os.path.exists("dist/MultiPlatformGUI"):
|
||||
print("📁 打包结果: dist/MultiPlatformGUI/")
|
||||
print("🚀 运行方式: cd dist/MultiPlatformGUI && .\\main.exe")
|
||||
print("📦 安装包构建: python installer/build_installer.py")
|
||||
elif os.path.exists("dist/main"):
|
||||
print("<EFBFBD><EFBFBD> 打包结果: dist/main/")
|
||||
print("📁 打包结果: dist/main/")
|
||||
print("🚀 运行方式: cd dist/main && .\\main.exe")
|
||||
print("💡 提示: 可手动重命名为 MultiPlatformGUI")
|
||||
print("⚠️ 建议重命名: dist/main -> dist/MultiPlatformGUI")
|
||||
|
||||
print("=" * 60)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user