54 lines
1.5 KiB
Python
54 lines
1.5 KiB
Python
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
def check_pyinstaller():
|
|
try:
|
|
import PyInstaller
|
|
print("PyInstaller 已安装")
|
|
return True
|
|
except ImportError:
|
|
print("正在安装 PyInstaller...")
|
|
subprocess.check_call([sys.executable, "-m", "pip", "install", "pyinstaller"])
|
|
return True
|
|
|
|
def build_exe():
|
|
print("开始打包...")
|
|
|
|
cmd = [
|
|
sys.executable, "-m", "PyInstaller",
|
|
"--onefile",
|
|
"--windowed",
|
|
"--name=智能客服节点日志查看器",
|
|
"--strip",
|
|
"--noupx",
|
|
"--exclude-module=unittest",
|
|
"--exclude-module=pytest",
|
|
"--exclude-module=numpy",
|
|
"--exclude-module=pandas",
|
|
"--exclude-module=matplotlib",
|
|
"--exclude-module=PIL",
|
|
"--exclude-module=cv2",
|
|
"--exclude-module=scipy",
|
|
"--exclude-module=sklearn",
|
|
"--exclude-module=email",
|
|
"--exclude-module=http.server",
|
|
"--exclude-module=xml",
|
|
"--exclude-module=multiprocessing",
|
|
"--exclude-module=concurrent",
|
|
"--exclude-module=asyncio",
|
|
"--hidden-import=openpyxl.cell._writer",
|
|
"日志查看器.py"
|
|
]
|
|
|
|
print("执行命令:", " ".join(cmd))
|
|
subprocess.check_call(cmd)
|
|
|
|
print("\n打包完成!")
|
|
print("可执行文件位于: dist/智能客服节点日志查看器.exe")
|
|
|
|
if __name__ == "__main__":
|
|
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
|
if check_pyinstaller():
|
|
build_exe()
|