feat: 添加性能优化和架构文档,更新依赖和核心模块
refactor(browser_manager): 实现页面池机制以提升性能 refactor(image_manager): 添加模板缓存并集成页面池 refactor(bili_parser): 迁移到异步HTTP请求并实现会话复用 docs: 新增性能优化、架构设计和最佳实践文档 chore: 更新requirements.txt添加新依赖
This commit is contained in:
42
setup_mypyc.py
Normal file
42
setup_mypyc.py
Normal file
@@ -0,0 +1,42 @@
|
||||
"""
|
||||
Mypyc 编译脚本
|
||||
|
||||
用于将核心 Python 模块编译为 C 扩展,以提升性能。
|
||||
使用方法:
|
||||
python setup_mypyc.py build_ext --inplace
|
||||
|
||||
注意:
|
||||
1. 需要安装 C 编译器 (Windows 上需要 Visual Studio Build Tools, Linux 上需要 GCC)。
|
||||
2. 编译后的文件 (.pyd 或 .so) 是平台相关的,不能跨平台复制。
|
||||
3. 建议在部署的目标环境 (Linux) 上运行此脚本。
|
||||
"""
|
||||
from distutils.core import setup
|
||||
from mypyc.build import mypycify
|
||||
import os
|
||||
import sys
|
||||
|
||||
# 待编译的模块列表
|
||||
# 注意:Mypyc 对动态特性支持有限,只选择计算密集或类型明确的模块
|
||||
modules = [
|
||||
'core/utils/json_utils.py', # JSON 处理
|
||||
'core/managers/command_manager.py', # 指令匹配和分发
|
||||
'core/ws.py', # WebSocket 核心
|
||||
'core/managers/plugin_manager.py', # 插件管理器
|
||||
]
|
||||
|
||||
# 确保文件存在
|
||||
valid_modules = []
|
||||
for m in modules:
|
||||
if os.path.exists(m):
|
||||
valid_modules.append(m)
|
||||
else:
|
||||
print(f"Warning: Module {m} not found, skipping.")
|
||||
|
||||
if not valid_modules:
|
||||
print("No valid modules found to compile.")
|
||||
sys.exit(1)
|
||||
|
||||
setup(
|
||||
name='neobot_core_compiled',
|
||||
ext_modules=mypycify(valid_modules),
|
||||
)
|
||||
Reference in New Issue
Block a user