feat(plugin): Implement robust dependency installation with embedded wheels

- 通过在插件中嵌入轮子来支持安装依赖项
This commit is contained in:
Aqr-K
2025-09-03 14:13:32 +08:00
committed by GitHub
parent eb0e67fc42
commit 9c9ec8adf2

View File

@@ -459,6 +459,17 @@ class PluginHelper(metaclass=WeakSingleton):
:param requirements_file: 依赖的 requirements.txt 文件路径
:return: (是否成功, 错误信息)
"""
wheels_dir = requirements_file.parent / "wheels"
find_links_option = []
if wheels_dir.is_dir():
# 如果目录存在,增加 --find-links 选项
logger.debug(f"[PIP] 发现插件内嵌的 wheels 目录: {wheels_dir},将优先从本地安装。")
find_links_option = ["--find-links", str(wheels_dir)]
else:
# 如果不存在,选项为空列表,对后续命令无影响
logger.debug(f"[PIP] 未发现插件内嵌的 wheels 目录,将仅使用在线源。")
base_cmd = [sys.executable, "-m", "pip", "install", "-r", str(requirements_file)]
strategies = []