[patch] 修改打包固定项缓存复用 提升打包效率
This commit is contained in:
@@ -135,10 +135,6 @@ jobs:
|
||||
- name: Build production executable
|
||||
if: success()
|
||||
shell: powershell
|
||||
# Optional: Set FORCE_FULL_CLEAN=true to force complete rebuild (clears build cache)
|
||||
# Default: Incremental build mode (preserves build cache for faster builds)
|
||||
# env:
|
||||
# FORCE_FULL_CLEAN: "true"
|
||||
run: |
|
||||
Write-Host "==========================================";
|
||||
Write-Host "Step 4.5: Build production executable";
|
||||
|
||||
@@ -9,11 +9,6 @@ import subprocess
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
# Build optimization: Control whether to force full clean
|
||||
# Set environment variable FORCE_FULL_CLEAN=true to clean both dist and build directories
|
||||
# Default: false (incremental build, faster)
|
||||
FORCE_FULL_CLEAN = os.getenv('FORCE_FULL_CLEAN', 'false').lower() == 'true'
|
||||
|
||||
|
||||
def clean_build():
|
||||
"""清理构建目录"""
|
||||
@@ -27,25 +22,7 @@ def clean_build():
|
||||
print("Waiting for file handles to release...")
|
||||
time.sleep(0.5)
|
||||
|
||||
# Build optimization: Preserve build cache for faster incremental builds
|
||||
# The build directory contains PyInstaller analysis cache
|
||||
# Preserving it can reduce build time from ~7min to ~3min
|
||||
if FORCE_FULL_CLEAN:
|
||||
dirs_to_clean = ['dist', 'build']
|
||||
print("FORCE_FULL_CLEAN enabled - cleaning all directories including build cache")
|
||||
else:
|
||||
dirs_to_clean = ['dist']
|
||||
print("Incremental build mode - preserving build cache for faster builds")
|
||||
|
||||
# Always remove spec file to ensure PyInstaller regenerates it from command-line args
|
||||
spec_file = 'MultiPlatformGUI.spec'
|
||||
if os.path.exists(spec_file):
|
||||
try:
|
||||
os.remove(spec_file)
|
||||
print(f"Removed old spec file: {spec_file}")
|
||||
except Exception as e:
|
||||
print(f"WARNING: Failed to remove spec file: {e}")
|
||||
|
||||
for dir_name in dirs_to_clean:
|
||||
print(f"Checking directory: {dir_name}")
|
||||
if os.path.exists(dir_name):
|
||||
@@ -79,9 +56,6 @@ def build_with_command():
|
||||
'--name=MultiPlatformGUI', # 直接使用最终目录名
|
||||
'--onedir', # 相当于 --exclude-binaries
|
||||
'--windowed', # 相当于 -w
|
||||
'--noconfirm', # Build optimization: Skip confirmation prompts
|
||||
'--log-level=WARN', # Build optimization: Reduce log output (only warnings and errors)
|
||||
'--noupx', # Build optimization: Skip UPX compression (saves time, minimal size impact)
|
||||
'--icon=static/ai_assistant_icon_64.png', # 添加主程序图标
|
||||
'--add-data=config.py;.',
|
||||
'--add-data=exe_file_logger.py;.',
|
||||
@@ -124,19 +98,6 @@ def build_with_command():
|
||||
print("Build successful!")
|
||||
print("Build result: dist/MultiPlatformGUI/")
|
||||
|
||||
# Debug: List files in dist directory
|
||||
if os.path.exists('dist/MultiPlatformGUI'):
|
||||
print("DEBUG: Files in dist/MultiPlatformGUI/:")
|
||||
for item in os.listdir('dist/MultiPlatformGUI'):
|
||||
item_path = os.path.join('dist/MultiPlatformGUI', item)
|
||||
if os.path.isfile(item_path):
|
||||
size_mb = os.path.getsize(item_path) / 1024 / 1024
|
||||
print(f" - {item} ({size_mb:.1f} MB)")
|
||||
else:
|
||||
print(f" - {item}/ (directory)")
|
||||
else:
|
||||
print("WARNING: dist/MultiPlatformGUI directory does not exist!")
|
||||
|
||||
# 验证输出目录(不需要重命名了)
|
||||
if os.path.exists('dist/MultiPlatformGUI/MultiPlatformGUI.exe'):
|
||||
# PyInstaller 生成的 exe 名称是 MultiPlatformGUI.exe
|
||||
|
||||
Reference in New Issue
Block a user