Files
cbb-refresh-verify-795/packaging/CbbRefreshVerify.spec

45 lines
3.8 KiB
RPMSpec

from pathlib import Path
import os
import struct
project_root = Path(SPECPATH).parent
assets_root = project_root / 'src' / 'cbb_refresh_verify' / 'assets'
bridge_path = project_root / 'tools' / 'status_bridge' / 'bin' / 'CbbStatusBridge32.exe'
verify_probe_path = project_root / 'tools' / 'status_bridge' / 'bin' / 'VerifyProbe32.exe'
# App-local x86 runtime belongs beside the x86 bridge, separate from Qt/Python.
bridge_runtime = []
if bridge_path.is_file():
runtime_root = Path(os.environ.get('WINDIR', r'C:\Windows')) / 'SysWOW64'
for name in ('mfc140.dll', 'msvcp140.dll', 'vcruntime140.dll', 'concrt140.dll'):
runtime = runtime_root / name
if not runtime.is_file():
raise RuntimeError(f'Install the Microsoft VC++ 2015-2022 x86 runtime before packaging: {runtime}')
data = runtime.read_bytes()
pe_offset = struct.unpack_from('<I', data, 0x3c)[0]
if data[pe_offset:pe_offset+4] != b'PE\x00\x00' or struct.unpack_from('<H', data, pe_offset+4)[0] != 0x14c:
raise RuntimeError(f'Expected an x86 bridge runtime: {runtime}')
bridge_runtime.append((str(runtime), 'tools/status_bridge/bin'))
a = Analysis(
[str(project_root / 'src' / 'cbb_refresh_verify' / '__main__.py')],
pathex=[str(project_root / 'src'), r'F:\Sync Tool Skyworth\Work Maps\dxdesigner-part-replacement\src'],
binaries=(
[(str(bridge_path), 'tools/status_bridge/bin')] if bridge_path.is_file() else []
) + (
[(str(verify_probe_path), 'tools/status_bridge/bin')]
if verify_probe_path.is_file() else []
),
datas=bridge_runtime + [(str(project_root / 'src' / 'cbb_refresh_verify' / 'save_verified_block.vbs'), 'cbb_refresh_verify'),
(str(project_root / 'src' / 'cbb_refresh_verify' / 'close_failed_block.vbs'), 'cbb_refresh_verify'),
(str(assets_root / 'cbb_refresh_verify.ico'), 'cbb_refresh_verify/assets'),
(str(assets_root / 'cbb_refresh_verify.png'), 'cbb_refresh_verify/assets'),
(str(assets_root / 'cbb_refresh_verify.svg'), 'cbb_refresh_verify/assets'),
(str(assets_root / 'dialog_rules.v1.json'), 'cbb_refresh_verify/assets')],
hiddenimports=['win32com.client','win32com.client.dynamic','pythoncom','pywintypes','win32timezone','win32job','pywinauto','pywinauto.uia_defines','pywinauto.controls.uiawrapper','pywinauto.win32_element_info','cbb_refresh_verify.dialog_agent','cbb_refresh_verify.dialog_probe','cbb_refresh_verify.dialog_rules','cbb_refresh_verify.ui.main_window','cbb_refresh_verify.ui.management_dialog','cbb_refresh_verify.management','cbb_refresh_verify.native_management','cbb_refresh_verify.library_lock','cbb_refresh_verify.content_check','cbb_refresh_verify.failed_session','cbb_refresh_verify.icdb_ownership','cbb_refresh_verify.native_repair','cbb_refresh_verify.native_repair_ui','dx_productivity.trial_task_center.logging_setup','dx_productivity.trial_task_center.errors','dx_productivity.trial_task_center.retention'],
excludes=['PySide6.QtDesigner','PySide6.QtMultimedia','PySide6.QtMultimediaWidgets','PySide6.QtOpenGL','PySide6.QtOpenGLWidgets','PySide6.QtPdf','PySide6.QtPdfWidgets','PySide6.QtQml','PySide6.QtQuick','PySide6.QtQuickWidgets','PySide6.QtWebChannel','PySide6.QtWebEngineCore','PySide6.QtWebEngineWidgets'],
)
excluded_qt_binaries = {'icudt78.dll','icuuc.dll','qpdf.dll','qt6pdf.dll','qt6qml.dll','qt6qmlmeta.dll','qt6qmlmodels.dll','qt6qmlworkerscript.dll','qt6quick.dll','qt6quickwidgets.dll'}
a.binaries = [entry for entry in a.binaries if Path(entry[0]).name.casefold() not in excluded_qt_binaries]
pyz = PYZ(a.pure)
exe = EXE(pyz, a.scripts, [], exclude_binaries=True, name='CbbRefreshVerify', console=False,
icon=str(assets_root / 'cbb_refresh_verify.ico'))
coll = COLLECT(exe, a.binaries, a.zipfiles, a.datas, name='CbbRefreshVerify-Background')