From 8e01ec56d4c3f8ef128b48b65c8fa331e2c3b5e0 Mon Sep 17 00:00:00 2001 From: xaoyaoo Date: Thu, 4 Jan 2024 14:57:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=93=E5=8C=85=EF=BC=8C?= =?UTF-8?q?=E6=9C=AA=E5=B0=86=E8=B5=84=E6=BA=90=E6=89=93=E5=8C=85=E8=BF=9B?= =?UTF-8?q?=E5=8E=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/build_exe.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/build_exe.py b/tests/build_exe.py index 1b957b9..041e995 100644 --- a/tests/build_exe.py +++ b/tests/build_exe.py @@ -39,8 +39,7 @@ a = Analysis(['tmp.py'], datas=[(r'{root_path}\\version_list.json', 'pywxdump'), (r'{root_path}/ui/templates/chat.html', 'pywxdump/ui/templates'), (r'{root_path}/ui/templates/index.html', 'pywxdump/ui/templates'), - *[(f, 'pywxdump/ui/web/assets/') for f in glob.glob(r'{root_path}/ui/web/assets/*')], - *[(f, 'pywxdump/ui/web/') for f in glob.glob(r'{root_path}/ui/web/*')], + {datas_741258} ], hiddenimports={hidden_imports}, hookspath=[], @@ -104,9 +103,15 @@ if package_path: hidden_imports = [i for i in hidden_imports if i not in ["setuptools", "wheel"]] # 去掉setuptools、wheel root_path = os.path.join(package_path, 'pywxdump') - + datas_741258 = [] + for root, dirs, files in os.walk(root_path): + for file in files: + file_path = os.path.join(root, file) + datas_741258.append(f'''(r'{file_path}', r'{os.path.dirname(root_path.replace(package_path, ""))}' )''') + datas_741258 = ",\n".join(datas_741258) + print(datas_741258) # 生成 spec 文件 - spec_content = spec_content.format(root_path=root_path, hidden_imports=hidden_imports) + spec_content = spec_content.format(root_path=root_path, hidden_imports=hidden_imports, datas_741258=datas_741258) spec_file = os.path.join("dist", "pywxdump.spec") with open(spec_file, 'w', encoding="utf-8") as f: f.write(spec_content.strip())