- 重构 AdminManager 和 PermissionManager 以 Redis 为主要数据源 - 为所有事件模型添加 slots=True 提升性能 - 更新文档说明 Mypyc 编译注意事项 - 清理测试和调试文件 - 移动静态资源到 web_static 目录
66 lines
2.0 KiB
Python
66 lines
2.0 KiB
Python
#!/usr/bin/env python3
|
||
"""
|
||
编译模块脚本
|
||
|
||
这个脚本会单独编译每个Python模块,确保每个模块都在正确位置生成独立的.pyd文件。
|
||
"""
|
||
import os
|
||
import sys
|
||
import glob
|
||
from mypyc.build import mypycify
|
||
from distutils.core import setup
|
||
|
||
def compile_module(module_path):
|
||
"""
|
||
编译单个模块
|
||
|
||
Args:
|
||
module_path: 要编译的Python模块路径
|
||
"""
|
||
print(f"\nCompiling {module_path}...")
|
||
try:
|
||
ext_modules = mypycify([module_path])
|
||
setup(name=f'compiled_{os.path.basename(module_path).replace(".py", "")}',
|
||
ext_modules=ext_modules)
|
||
return True
|
||
except Exception as e:
|
||
print(f"Error compiling {module_path}: {e}")
|
||
return False
|
||
|
||
def main():
|
||
"""
|
||
主函数
|
||
"""
|
||
# 要编译的模块列表
|
||
modules = [
|
||
'core/utils/json_utils.py', # JSON 处理
|
||
'core/utils/executor.py', # 代码执行引擎
|
||
'core/managers/command_manager.py', # 指令匹配和分发
|
||
'core/managers/admin_manager.py', # 管理员管理
|
||
'core/managers/permission_manager.py', # 权限管理
|
||
'core/ws.py', # WebSocket 核心
|
||
'core/managers/plugin_manager.py', # 插件管理器
|
||
'core/bot.py', # Bot 核心抽象
|
||
'core/config_loader.py', # 配置加载
|
||
]
|
||
|
||
# 自动添加 events 模型
|
||
event_models = glob.glob('models/events/*.py')
|
||
event_models = [m for m in event_models if not m.endswith('__init__.py')]
|
||
modules.extend(event_models)
|
||
|
||
print(f"Found {len(modules)} modules to compile.")
|
||
|
||
success_count = 0
|
||
for module in modules:
|
||
if compile_module(module):
|
||
success_count += 1
|
||
|
||
print(f"\n--- Compilation Summary ---")
|
||
print(f"Total modules: {len(modules)}")
|
||
print(f"Successfully compiled: {success_count}")
|
||
print(f"Failed: {len(modules) - success_count}")
|
||
|
||
if __name__ == '__main__':
|
||
main()
|