fix build exe error

This commit is contained in:
xaoyaoo 2024-08-17 13:51:44 +08:00
parent 33da8c4b78
commit 0c727dc34f
12 changed files with 56 additions and 43 deletions

11
__init__.py Normal file
View File

@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-#
# -------------------------------------------------------------------------------
# Name: __init__.py.py
# Description:
# Author: xaoyaoo
# Date: 2024/08/17
# -------------------------------------------------------------------------------
if __name__ == '__main__':
pass

View File

@ -22,7 +22,6 @@ from .wx_core import merge_db, decrypt_merge, merge_real_time_db, all_merge_real
from .db import DBHandler, MsgHandler, MicroHandler, MediaHandler, OpenIMContactHandler, FavoriteHandler, \
PublicMsgHandler
from .api import start_server, app
from .analyzer import DBPool
# PYWXDUMP_ROOT_PATH = os.path.dirname(__file__)
# db_init = DBPool("DBPOOL_INIT")
@ -30,5 +29,6 @@ from .analyzer import DBPool
__all__ = ["BiasAddr", "get_wx_info", "get_wx_db", "batch_decrypt", "decrypt", "get_core_db",
"merge_db", "decrypt_merge", "merge_real_time_db", "all_merge_real_time_db",
"MsgHandler", "MicroHandler", "MediaHandler", "OpenIMContactHandler", "FavoriteHandler", "PublicMsgHandler",
"DBHandler", "start_server", "WX_OFFS", "WX_OFFS_PATH", "__version__", "app"]
"DBHandler", "MsgHandler", "MicroHandler", "MediaHandler", "OpenIMContactHandler", "FavoriteHandler",
"PublicMsgHandler",
"start_server", "WX_OFFS", "WX_OFFS_PATH", "__version__", "app"]

View File

@ -8,7 +8,7 @@
import csv
import json
import os
from ..__init__ import DBHandler
from pywxdump.db import DBHandler
def export_csv(wxid, outpath, db_config, my_wxid="", page_size=5000):

View File

@ -7,7 +7,7 @@
# -------------------------------------------------------------------------------
import json
import os
from ..__init__ import DBHandler
from pywxdump.db import DBHandler
def export_html(wxid, outpath, db_config, my_wxid=""):

View File

@ -7,7 +7,7 @@
# -------------------------------------------------------------------------------
import json
import os
from ..__init__ import DBHandler
from pywxdump.db import DBHandler
def export_json(wxid, outpath, db_config, my_wxid="", indent=4):

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-#
# -------------------------------------------------------------------------------
# Name: chat_api.py
# Name: remote_server.py
# Description:
# Author: xaoyaoo
# Date: 2024/01/02
@ -18,9 +18,10 @@ from starlette.responses import StreamingResponse, FileResponse
import pywxdump
from pywxdump import decrypt_merge,get_core_db
from pywxdump.db import DBHandler, download_file, dat2img
from pywxdump.db.export import export_csv, export_json, export_html
from pywxdump.db import DBHandler
from pywxdump.db.utils import download_file, dat2img
from .export import export_csv, export_json, export_html
from .rjson import ReJson, RqJson
from .utils import error9999, gc, asyncError9999

View File

@ -1,12 +1,10 @@
# -*- coding: utf-8 -*-#
# -------------------------------------------------------------------------------
# Name: __init__.py.py
# Description:
# Name: __init__.py
# Description: db
# Author: xaoyaoo
# Date: 2024/04/15
# -------------------------------------------------------------------------------
# import pandas as pd
from .utils import download_file, dat2img
from .dbFavorite import FavoriteHandler
@ -82,3 +80,7 @@ class DBHandler(MicroHandler, MediaHandler, OpenIMContactHandler, PublicMsgHandl
count = {k: chat_count.get(k, 0) + chat_count1.get(k, 0) for k in
list(set(list(chat_count.keys()) + list(chat_count1.keys())))}
return count
__all__ = ["DBHandler", "FavoriteHandler", "MsgHandler", "MicroHandler", "MediaHandler",
"OpenIMContactHandler", "PublicMsgHandler", "OpenIMMediaHandler", "SnsHandler"]

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-#
# -------------------------------------------------------------------------------
# Name: __init__.py.py
# Description:
# Description: db.utils
# Author: xaoyaoo
# Date: 2024/07/23
# -------------------------------------------------------------------------------
@ -10,4 +10,4 @@ from .common_utils import timestamp2str, xml2dict, silk2audio, bytes2str, get_md
type_converter, match_BytesExtra, db_error, download_file, dat2img
__all__ = ["db_loger", "timestamp2str", "xml2dict", "silk2audio", "bytes2str", "get_md5", "name2typeid", "typeid2name",
"type_converter", "match_BytesExtra", "db_error", "download_file", "dat2img"]
"type_converter", "match_BytesExtra", "db_error", "download_file", "dat2img"]

View File

@ -4,17 +4,16 @@ pycryptodomex
pywin32
silk-python
pyaudio
pymem
psutil
requests
pillow
pyahocorasick
blackboxprotobuf
lz4
blackboxprotobuf
lxml
pandas
dbutils
psutil
pymem
fastapi
uvicorn
python-dotenv
email-validator
python-dotenv

View File

@ -20,10 +20,7 @@ install_requires = [
"silk-python",
"pyaudio",
"requests",
"pillow",
"pyahocorasick",
# "flask",
# "flask_cors",
"lz4",
"blackboxprotobuf",
"lxml",
@ -33,7 +30,8 @@ install_requires = [
"fastapi",
"uvicorn",
"python-dotenv",
"email-validator"
# "pillow",
]
setup(
@ -48,21 +46,20 @@ setup(
license='MIT',
packages=['pywxdump', 'pywxdump.ui', 'pywxdump.wx_core', 'pywxdump.wx_core.utils', 'pywxdump.analyzer',
'pywxdump.api', 'pywxdump.db', 'pywxdump.db.utils', 'pywxdump.db.export'],
'pywxdump.api', 'pywxdump.api.export', 'pywxdump.db', 'pywxdump.db.utils'],
package_dir={'pywxdump': 'pywxdump',
'pywxdump.wx_core': 'pywxdump/wx_core',
'pywxdump.wx_core.utils': 'pywxdump/wx_core/utils',
'pywxdump.analyzer': 'pywxdump/analyzer',
'pywxdump.ui': 'pywxdump/ui',
'pywxdump.api': 'pywxdump/api',
'pywxdump.api.export': 'pywxdump/api/export',
'pywxdump.db': 'pywxdump/db',
'pywxdump.db.utils': 'pywxdump/db/utils',
'pywxdump.db.export': 'pywxdump/db/export'
'pywxdump.db.utils': 'pywxdump/db/utils'
},
package_data={
'pywxdump': ['WX_OFFS.json', 'ui/web/*', 'ui/web/assets/*', 'wx_core/tools/*',
"ui/export/*", "ui/export/assets/*", "ui/export/assets/css/*", "ui/export/assets/js/*",
]
},
classifiers=[

View File

@ -16,6 +16,7 @@ ma_version = __version__.split(".")[0]
mi_version = __version__.split(".")[1]
pa_version = __version__.split(".")[2]
def image_to_base64(image_path):
with open(image_path, "rb") as image_file:
encoded_string = base64.b64encode(image_file.read())
@ -38,7 +39,7 @@ spec_content = '''
block_cipher = None
a = Analysis(['tmp.py'],
a = Analysis(['wxdump.py'],
pathex=[],
binaries=[],
datas=[(r'{root_path}\\WX_OFFS.json', 'pywxdump'),
@ -129,11 +130,10 @@ VSVersionInfo(
)
"""
# 创建文件夹
os.makedirs("dist", exist_ok=True)
# 将代码写入文件
with open("dist/tmp.py", "w", encoding="utf-8") as f:
with open("dist/wxdump.py", "w", encoding="utf-8") as f:
f.write(code.strip())
current_path = os.path.dirname(os.path.abspath(__file__))
@ -142,7 +142,6 @@ shutil.copy(os.path.join(current_path, "favicon.ico"), "dist/icon.ico") # 复
with open("dist/wxdump_version_info.txt", "w", encoding="utf-8") as f:
f.write(wxdump_version_info.strip())
# 获取安装包的路径
package_path = site.getsitepackages()
if package_path:
@ -152,27 +151,31 @@ if package_path:
require_path = os.path.join(os.path.dirname(current_path), "requirements.txt") # requirements.txt 路径
with open(require_path, "r", encoding="utf-8") as f:
hidden_imports = f.read().splitlines()
hidden_imports = [i.replace('-','_') for i in hidden_imports if i not in ["setuptools", "wheel"]] # 去掉setuptools、wheel
hidden_imports = [i.replace('-', '_') for i in hidden_imports if
i and i not in ["setuptools", "wheel"]] # 去掉setuptools、wheel
hidden_imports += ["pywxdump", "pywxdump.db","pywxdump.db.__init__.utils"]
# 获取 ui 文件夹下的所有文件 用于打包
root_path = os.path.join(package_path, 'pywxdump')
datas_741258 = []
for root, dirs, files in os.walk(os.path.join(root_path, "ui")):
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(file_path.replace(package_path, "")[1:])}' )''')
if "__pycache__" in file_path:
continue
datas_741258.append(f'''(r'{file_path}', r'{os.path.dirname(file_path.replace(package_path, "")[1:])}')''')
datas_741258 = ",\n".join(datas_741258)
# 获取 wx_core/tools 文件夹下的所有文件 用于打包
for root, dirs, files in os.walk(os.path.join(root_path, "wx_core", "tools")):
for file in files:
file_path = os.path.join(root, file)
datas_741258 += f''',\n(r'{file_path}', r'{os.path.dirname(file_path.replace(package_path, "")[1:])}' )'''
# # 获取 wx_core/tools 文件夹下的所有文件 用于打包
# for root, dirs, files in os.walk(os.path.join(root_path, "wx_core", "tools")):
# for file in files:
# file_path = os.path.join(root, file)
# datas_741258 += f''',\n(r'{file_path}', r'{os.path.dirname(file_path.replace(package_path, "")[1:])}' )'''
# print(datas_741258)
# 生成 spec 文件
spec_content = spec_content.format(root_path=root_path, hidden_imports=hidden_imports, datas_741258=datas_741258, version=__version__)
spec_content = spec_content.format(root_path=root_path, hidden_imports=hidden_imports, datas_741258=datas_741258,
version=__version__)
spec_file = os.path.join("dist", "pywxdump.spec")
with open(spec_file, 'w', encoding="utf-8") as f:
f.write(spec_content.strip())