@@ -3,19 +3,37 @@ from PyInstaller.utils.hooks import collect_data_files, collect_all, get_package
33import os
44
55# Collect data files dynamically instead of using a hardcoded path
6- py3langid_datas = collect_data_files ('py3langid' )
7- unidic_datas = collect_data_files ('unidic_lite' )
8- manga_ocr_datas = collect_data_files ('manga_ocr' ) # 收集manga_ocr的数据文件(包括example.jpg)
6+ # Use try-except to handle cases where packages might not be found
7+ try :
8+ py3langid_datas = collect_data_files ('py3langid' )
9+ except Exception :
10+ py3langid_datas = []
11+
12+ try :
13+ unidic_datas = collect_data_files ('unidic_lite' )
14+ except Exception :
15+ unidic_datas = []
16+
17+ try :
18+ manga_ocr_datas = collect_data_files ('manga_ocr' )
19+ except Exception :
20+ manga_ocr_datas = []
921
1022# 使用collect_all自动收集onnxruntime的所有内容
11- onnx_datas , onnx_binaries , onnx_hiddenimports = collect_all ('onnxruntime' )
23+ try :
24+ onnx_datas , onnx_binaries , onnx_hiddenimports = collect_all ('onnxruntime' )
25+ except Exception :
26+ onnx_datas , onnx_binaries , onnx_hiddenimports = [], [], []
1227
1328# 同时将onnxruntime的核心DLL也复制到根目录
14- onnxruntime_pkg_base , onnxruntime_pkg_dir = get_package_paths ('onnxruntime' )
15- onnx_binaries .extend ([
16- (os .path .join (onnxruntime_pkg_dir , 'capi' , 'onnxruntime.dll' ), '.' ),
17- (os .path .join (onnxruntime_pkg_dir , 'capi' , 'onnxruntime_providers_shared.dll' ), '.' ),
18- ])
29+ try :
30+ onnxruntime_pkg_base , onnxruntime_pkg_dir = get_package_paths ('onnxruntime' )
31+ onnx_binaries .extend ([
32+ (os .path .join (onnxruntime_pkg_dir , 'capi' , 'onnxruntime.dll' ), '.' ),
33+ (os .path .join (onnxruntime_pkg_dir , 'capi' , 'onnxruntime_providers_shared.dll' ), '.' ),
34+ ])
35+ except Exception :
36+ pass
1937
2038a = Analysis (
2139 ['../desktop_qt_ui/main.py' ], # 相对于packaging目录
0 commit comments