Skip to content

Commit

Permalink
修复打包,未将资源打包进去
Browse files Browse the repository at this point in the history
  • Loading branch information
xaoyaoo committed Jan 4, 2024
1 parent 7939fd8 commit 8e01ec5
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tests/build_exe.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ def base64_to_image(base64_string, image_path):
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=[],
Expand Down Expand Up @@ -104,9 +103,15 @@ def base64_to_image(base64_string, image_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())
Expand Down

0 comments on commit 8e01ec5

Please sign in to comment.