Skip to content

Commit 5971cc8

Browse files
authored
Merge pull request #86 from ljzloser/master
修改插件管理器的逻辑,通用性更强,且支持vs code 断点调试
2 parents cb7e18c + 3820caf commit 5971cc8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+4379
-1493
lines changed

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,4 @@ old/
169169
src/plugins/*/*.json
170170
src/plugins/*/*.db
171171
.vscode/
172-
src/history.db
173-
history_show_fields.json
174-
src/out.json
172+
data/*

build.bat

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
@echo off
2+
chcp 65001 >nul 2>&1
3+
4+
set OUT=dist\app
5+
set DEST=%OUT%\metaminsweeper
6+
7+
echo [Clean] Removing old builds...
8+
if exist "%OUT%\metaminsweeper" rmdir /s /q "%OUT%\metaminsweeper"
9+
if exist "%OUT%\plugin_manager" rmdir /s /q "%OUT%\plugin_manager"
10+
11+
echo.
12+
echo [1/3] metaminsweeper.exe
13+
pyinstaller --noconfirm --name metaminsweeper --windowed --distpath %OUT% src\main.py
14+
15+
echo.
16+
echo [2/3] plugin_manager.exe
17+
pyinstaller --noconfirm --name plugin_manager --windowed --hidden-import code --hidden-import xmlrpc --hidden-import xmlrpc.server --hidden-import xmlrpc.client --hidden-import http.server --hidden-import socketserver --hidden-import email --hidden-import email.utils --distpath %OUT% src\plugin_manager\_run.py
18+
19+
echo.
20+
echo [3/3] Copy resources to metaminsweeper\
21+
copy /y "%OUT%\plugin_manager\plugin_manager.exe" "%DEST%\"
22+
xcopy /e /y /i "%OUT%\plugin_manager\_internal" "%DEST%\_internal" >nul
23+
xcopy /e /y /i "src\plugin_manager" "%DEST%\plugin_manager" >nul
24+
xcopy /e /y /i "src\plugins" "%DEST%\plugins" >nul
25+
xcopy /e /y /i "src\shared_types" "%DEST%\shared_types" >nul
26+
if exist "%DEST%\plugin_manager\_run.py" del /f /q "%DEST%\plugin_manager\_run.py"
27+
28+
echo [4/4] Copy debugpy from venv to _internal\
29+
set SP=.venv\Lib\site-packages
30+
xcopy /e /y /i "%SP%\debugpy" "%DEST%\_internal\debugpy" >nul
31+
xcopy /e /y /i "%SP%\msgspec" "%DEST%\_internal\msgspec" >nul 2>nul
32+
xcopy /e /y /i "%SP%\setuptools" "%DEST%\_internal\setuptools" >nul 2>nul
33+
34+
echo.
35+
echo Done! Both in: %OUT%\
36+
pause

hook-debugpy-pyinstaller.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""
2+
PyInstaller runtime hook for debugpy compatibility.
3+
在 import debugpy 之前修复路径问题,确保 _vendored 目录可被找到。
4+
"""
5+
import os
6+
import sys
7+
8+
# PyInstaller 打包后 __file__ 指向临时目录或 zip 内,
9+
# debugpy/_vendored/__init__.py 用 os.path.abspath(__file__) 定位资源会失败。
10+
# 此 hook 在任何代码执行前将 debugpy 的真实解压路径注入 sys._MEIPASS 搜索逻辑。
11+
12+
def _fix_debugpy_paths():
13+
# PyInstaller 运行时,已解压的文件在 sys._MEIPASS 下
14+
meipass = getattr(sys, "_MEIPASS", None)
15+
if not meipass:
16+
return # 非打包环境,不需要处理
17+
18+
debugpy_dir = os.path.join(meipass, "debugpy")
19+
vendored_dir = os.path.join(debugpy_dir, "_vendored")
20+
21+
if os.path.isdir(debugpy_dir):
22+
# 确保 debugpy 在 sys.path 中靠前(PyInstaller 已处理,但保险起见)
23+
if debugpy_dir not in sys.path:
24+
sys.path.insert(0, debugpy_dir)
25+
26+
_fix_debugpy_paths()

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ setuptools==80.9.0
44
msgspec>=0.20.0
55
zmq>=0.0.0
66
pywin32
7-
7+
loguru

src/lib_zmq_plugins/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from lib_zmq_plugins.shared.base import BaseCommand, BaseEvent, CommandResponse, SyncCommand
2+
from lib_zmq_plugins.log import LogHandler, NullHandler
3+
4+
__all__ = [
5+
"BaseEvent", "BaseCommand", "CommandResponse", "SyncCommand",
6+
"LogHandler", "NullHandler",
7+
]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from lib_zmq_plugins.client.zmq_client import ZMQClient
2+
3+
__all__ = ["ZMQClient"]

0 commit comments

Comments
 (0)