36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
|
import PyInstaller.__main__
|
||
|
import os
|
||
|
import shutil
|
||
|
|
||
|
# 清理旧的构建文件
|
||
|
if os.path.exists('build'):
|
||
|
shutil.rmtree('build')
|
||
|
if os.path.exists('dist'):
|
||
|
shutil.rmtree('dist')
|
||
|
|
||
|
# 打包配置
|
||
|
PyInstaller.__main__.run([
|
||
|
'notification_client.py', # 主程序
|
||
|
'--name=NotifyWin', # 生成的exe名称
|
||
|
'--noconsole', # 不显示控制台
|
||
|
'--onefile', # 打包成单个文件
|
||
|
'--icon=icons/notify.ico', # 图标文件
|
||
|
'--add-data=config.yml;.', # 添加配置文件
|
||
|
'--hidden-import=websockets',
|
||
|
'--hidden-import=winotify',
|
||
|
'--hidden-import=yaml',
|
||
|
'--hidden-import=PIL',
|
||
|
'--hidden-import=pystray',
|
||
|
'--hidden-import=typing_extensions',
|
||
|
'--hidden-import=asyncio',
|
||
|
'--hidden-import=logging',
|
||
|
'--hidden-import=logging.handlers',
|
||
|
'--hidden-import=pyperclip',
|
||
|
])
|
||
|
|
||
|
# 复制必要的文件到dist目录
|
||
|
shutil.copy('config.yml', 'dist/config.yml')
|
||
|
if os.path.exists('icons'):
|
||
|
shutil.copytree('icons', 'dist/icons')
|
||
|
if os.path.exists('sounds'):
|
||
|
shutil.copytree('sounds', 'dist/sounds')
|