modern-calculator/build.py

26 lines
519 B
Python
Raw Normal View History

2025-01-08 21:25:32 +08:00
import os
import sys
import PyInstaller.__main__
# 获取当前操作系统
current_os = sys.platform
# 设置图标文件名
icon_file = "calculator.ico" if current_os == "win32" else "calculator.icns"
# PyInstaller参数
args = [
"calculator.py",
"--name=现代计算器",
2025-01-08 22:18:54 +08:00
"--onedir",
2025-01-08 21:25:32 +08:00
"--noconsole",
"--clean",
f"--icon={icon_file}" if os.path.exists(icon_file) else None,
]
# 过滤掉None值
args = [arg for arg in args if arg is not None]
# 执行打包
PyInstaller.__main__.run(args)