Skip to content

Commit

Permalink
change packing to onefolder
Browse files Browse the repository at this point in the history
  • Loading branch information
ok-oldking committed May 14, 2024
1 parent 881bd72 commit df2da7e
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 16 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@ jobs:
python -m pip install --upgrade pip
pip install pyinstaller # Add other dependencies if needed
pip install -r requirements.txt
pip uninstall -y numpy
pip install -i https://pypi.anaconda.org/intel/simple numpy
- name: Build Executable
run: |
echo ${{ github.sha }} > Release.txt
pyinstaller main.spec
mv dist ok-baijing
mv dist/bundle ok-baijing
7z a -t7z -r "ok-baijing.7z" "ok-baijing"
rm -r dist
pyinstaller main_debug.spec
mv dist ok-baijing-debug
mv dist/bundle ok-baijing-debug
7z a -t7z -r "ok-baijing-debug.7z" "ok-baijing-debug"
- name: Create Release
Expand Down
48 changes: 42 additions & 6 deletions main.spec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ block_cipher = None
package_name = 'rapidocr_openvino'
install_dir = Path(rapidocr_openvino.__file__).resolve().parent

onnx_paths = list(install_dir.rglob('*.onnx'))
onnx_paths = list(install_dir.rglob('*.onnx')) + list(install_dir.rglob('*.txt'))
yaml_paths = list(install_dir.rglob('*.yaml'))

onnx_add_data = [(str(v.parent), f'{package_name}/{v.parent.name}')
Expand All @@ -22,9 +22,24 @@ for v in yaml_paths:
yaml_add_data.append(
(str(v.parent / '*.yaml'), f'{package_name}/{v.parent.name}'))

add_data = list(set(yaml_add_data + onnx_add_data))
import openvino

excludes = ['FixTk', 'tcl', 'tk', '_tkinter', 'tkinter', 'Tkinter', 'resources', 'matplotlib']
block_cipher = None

package_name = 'openvino'
install_dir = Path(openvino.__file__).resolve().parent

openvino_dll_path = list(install_dir.rglob('openvino_intel_cpu_plugin.dll')) + list(install_dir.rglob('openvino_onnx_frontend.dll'))


# Modified list comprehension with a condition check
openvino_add_data = [(str(v), f'{package_name}/{v.parent.name}')
for v in openvino_dll_path]

print(f'openvino_add_data {openvino_add_data}')
add_data = list(set(yaml_add_data + onnx_add_data + openvino_add_data))

excludes = ['FixTk', 'tcl', 'tk', '_tkinter', 'tkinter', 'Tkinter', 'resources', 'matplotlib','numpy.lib']
add_data.append(('icon.ico', '.'))
print(f"add_data {add_data}")

Expand All @@ -42,24 +57,45 @@ a = Analysis(
noarchive=False,
)


# List of patterns to exclude
exclude_patterns = ['opencv_videoio_ffmpeg', 'opengl32sw.dll', 'Qt6Quick.dll','Qt6Pdf.dll','Qt6Qml.dll','Qt6OpenGL.dll','Qt6Network.dll','Qt6QmlModels.dll','Qt6VirtualKeyboard.dll','QtNetwork.pyd','libcrypto-3.dll'
,'mfc140u.dll','openvino_pytorch_frontend.dll','openvino_tensorflow_frontend.dll','py_tensorflow_frontend.cp311-win_amd64.pyd','py_pytorch_frontend.cp311-win_amd64.pyd',
'MSVCP140.dll']

# Optimized list comprehension using any() with a generator expression
a.binaries = [x for x in a.binaries if not any(pattern in x[0] for pattern in exclude_patterns)]

print(f'a.binaries {a.binaries}')

pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
exclude_binaries=True,
name='ok-baijing',
icon='icon.ico',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=False,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)

coll = COLLECT(
exe,
a.binaries,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='bundle',
)

10 changes: 5 additions & 5 deletions main_debug.spec
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ a = Analysis(
noarchive=False,
)

import fnmatch

# List of patterns to exclude
exclude_patterns = ['opencv_videoio_ffmpeg', 'opengl32sw.dll']
exclude_patterns = ['opencv_videoio_ffmpeg', 'opengl32sw.dll', 'Qt6Quick.dll','Qt6Pdf.dll','Qt6Qml.dll','Qt6OpenGL.dll','Qt6Network.dll','Qt6QmlModels.dll','Qt6VirtualKeyboard.dll','QtNetwork.pyd','libcrypto-3.dll'
,'mfc140u.dll','openvino_pytorch_frontend.dll','openvino_tensorflow_frontend.dll','py_tensorflow_frontend.cp311-win_amd64.pyd','py_pytorch_frontend.cp311-win_amd64.pyd',
'MSVCP140.dll']

# Optimized list comprehension using any() with a generator expression
a.binaries = [x for x in a.binaries if not any(pattern in x[0] for pattern in exclude_patterns)]
Expand All @@ -72,9 +73,8 @@ pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
exclude_binaries=True,
name='ok-baijing-debug',
icon='icon.ico',
debug=False,
Expand All @@ -96,6 +96,6 @@ coll = COLLECT(
strip=False,
upx=True,
upx_exclude=[],
name='test',
name='bundle',
)

1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ pywin32
typing-extensions
opencv-python
PySide6
PySide6-Fluent-Widgets

rapidocr_openvino
9 changes: 6 additions & 3 deletions task/ManXunTask.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import queue
import re
import threading

Expand Down Expand Up @@ -30,6 +29,7 @@ class ManXunTask(BJTask):

def __init__(self):
super().__init__()
self.update_stats_queue = None
self.name = "执行一次自动漫巡"
self.description = """自动漫巡, 必须进入漫巡后开始, 并开启追踪
"""
Expand Down Expand Up @@ -62,7 +62,6 @@ def __init__(self):
self.pause_combat_message = "未开启自动战斗, 无法继续漫巡, 暂停中, 请手动完成战斗或开启自动跳过后继续"
self.stats_seq = ["体质", "防御", "攻击", "专精", "终端"]
self.update_stats_thread = None
self.update_stats_queue = queue.Queue()
self.ocr_target_height = 700 # 缩小图片提升ocr速度

def end(self, message, result=False):
Expand Down Expand Up @@ -95,6 +94,7 @@ def filter_gaowei_number_zone(self, boxes):
@override
def run(self):
if self.update_stats_thread is None:
self.update_stats_queue = self.new_queue()
self.update_stats_thread = threading.Thread(target=self.do_update_current_stats, name="update_stats")
self.update_stats_thread.start()
if not self.check_is_manxun_ui():
Expand Down Expand Up @@ -186,8 +186,11 @@ def do_update_current_stats(self):

# Set the priority of the thread to lowest
win32process.SetThreadPriority(thread, win32process.THREAD_PRIORITY_LOWEST)
while True and not self.exit_is_set():
while not self.exit_is_set():
frame = self.update_stats_queue.get()
if frame is None:
self.log_info("No frame in queue, destroyed")
return
boxes = self.ocr(self.stats_zone, match=re.compile(r'^[1-9]\d*$'), frame=frame)
if len(boxes) != 5:
self.log_error(f"无法找到5个属性, {boxes}")
Expand Down

0 comments on commit df2da7e

Please sign in to comment.