#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ MetaCore 快速打包脚本 简化版本,跳过复杂的检查,直接进行打包。 """ import os import sys import shutil import subprocess from pathlib import Path def main(): print("🚀 MetaCore 快速打包") print("="*30) # 检查spec文件 spec_file = 'MetaCore.spec' if not Path(spec_file).exists(): print(f"❌ 找不到 {spec_file} 文件") print("正在使用默认命令...") # 使用基本的PyInstaller命令 cmd = [ sys.executable, '-m', 'PyInstaller', '--onefile', '--windowed', '--name=MetaCore', '--icon=MetaCore/Resources/Icons/app_icon.png', 'MetaCore/main.py' ] else: # 使用spec文件 cmd = [sys.executable, '-m', 'PyInstaller', spec_file, '--clean'] print(f"执行命令: {' '.join(cmd)}") print("开始打包...") try: # 运行打包命令 result = subprocess.run(cmd, check=True) print("✅ 打包完成!") # 检查结果 exe_path = Path('dist/MetaCore.exe') if exe_path.exists(): size_mb = exe_path.stat().st_size / (1024 * 1024) print(f"📦 生成文件: {exe_path}") print(f"📊 文件大小: {size_mb:.1f} MB") else: # 检查是否有main.exe main_exe = Path('dist/main.exe') if main_exe.exists(): size_mb = main_exe.stat().st_size / (1024 * 1024) print(f"📦 生成文件: {main_exe}") print(f"📊 文件大小: {size_mb:.1f} MB") print("\n🎉 打包成功!可以运行生成的exe文件了。") except subprocess.CalledProcessError as e: print(f"❌ 打包失败: {e}") return 1 except FileNotFoundError: print("❌ 找不到 PyInstaller,请安装: pip install pyinstaller") return 1 except Exception as e: print(f"❌ 发生错误: {e}") return 1 return 0 if __name__ == "__main__": sys.exit(main())