添加项目源代码
This commit is contained in:
120
tingquan_assistant.spec
Normal file
120
tingquan_assistant.spec
Normal file
@@ -0,0 +1,120 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
import os
|
||||
import sys
|
||||
from PyInstaller.utils.hooks import collect_data_files, collect_submodules
|
||||
|
||||
# 读取版本号
|
||||
with open('version.txt', 'r') as f:
|
||||
VERSION = f.read().strip()
|
||||
|
||||
# 收集所有Python文件
|
||||
python_files = []
|
||||
for root, dirs, files in os.walk('.'):
|
||||
if '__pycache__' in root or '.git' in root or 'venv' in root:
|
||||
continue
|
||||
for file in files:
|
||||
if file.endswith('.py') and not file.startswith('test_'):
|
||||
rel_path = os.path.relpath(os.path.join(root, file))
|
||||
python_files.append(rel_path)
|
||||
|
||||
# 收集数据文件
|
||||
datas = [
|
||||
('version.txt', '.'),
|
||||
('two.ico', '.'),
|
||||
('file_version_info.txt', '.'),
|
||||
('utils', 'utils'),
|
||||
('services', 'services'),
|
||||
('gui', 'gui'),
|
||||
]
|
||||
|
||||
# 添加其他资源文件
|
||||
if os.path.exists('requirements.txt'):
|
||||
datas.append(('requirements.txt', '.'))
|
||||
|
||||
a = Analysis(
|
||||
['tingquan_assistant.py'] + python_files,
|
||||
pathex=[],
|
||||
binaries=[],
|
||||
datas=datas,
|
||||
hiddenimports=[
|
||||
'PyQt5',
|
||||
'PyQt5.QtCore',
|
||||
'PyQt5.QtGui',
|
||||
'PyQt5.QtWidgets',
|
||||
'requests',
|
||||
'json',
|
||||
'logging',
|
||||
'win32api',
|
||||
'win32con',
|
||||
'win32gui',
|
||||
],
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=[
|
||||
'_tkinter',
|
||||
'tkinter',
|
||||
'PIL.ImageTk',
|
||||
'PIL.ImageWin',
|
||||
'numpy',
|
||||
'pandas',
|
||||
'matplotlib',
|
||||
'scipy',
|
||||
'PyQt5.QtWebEngineWidgets',
|
||||
'PyQt5.QtWebEngine',
|
||||
],
|
||||
win_no_prefer_redirects=False,
|
||||
win_private_assemblies=False,
|
||||
cipher=None,
|
||||
noarchive=False,
|
||||
)
|
||||
|
||||
# 过滤掉不需要的二进制文件
|
||||
def remove_from_list(source, patterns):
|
||||
for file in source[:]:
|
||||
for pattern in patterns:
|
||||
if pattern in file[0]:
|
||||
source.remove(file)
|
||||
break
|
||||
|
||||
remove_from_list(a.binaries, [
|
||||
'Qt5WebEngine',
|
||||
'Qt5WebEngineCore',
|
||||
'Qt5WebEngineWidgets',
|
||||
'Qt5Designer',
|
||||
'Qt5Qml',
|
||||
])
|
||||
|
||||
pyz = PYZ(a.pure, a.zipped_data, cipher=None)
|
||||
|
||||
exe = EXE(
|
||||
pyz,
|
||||
a.scripts,
|
||||
[],
|
||||
exclude_binaries=True,
|
||||
name=f'听泉助手v{VERSION}',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
runtime_tmpdir=None,
|
||||
console=False,
|
||||
disable_windowed_traceback=False,
|
||||
argv_emulation=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
icon=['two.ico'],
|
||||
version='file_version_info.txt',
|
||||
)
|
||||
|
||||
coll = COLLECT(
|
||||
exe,
|
||||
a.binaries,
|
||||
a.datas,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
name=f'听泉助手v{VERSION}',
|
||||
)
|
||||
Reference in New Issue
Block a user