优化依赖管理配置,移除不必要的allowed_auto_install选项,更新文档以更清晰地描述自动安装功能的主开关。调整相关代码以简化逻辑,确保自动安装行为通过单一配置控制。
This commit is contained in:
committed by
Windpicker-owo
parent
8ed15c8199
commit
d29a57f1a4
@@ -929,7 +929,7 @@ class DependencyManagementConfig(ConfigBase):
|
||||
"""插件Python依赖管理配置类"""
|
||||
|
||||
auto_install: bool = True
|
||||
"""是否启用自动安装Python依赖包"""
|
||||
"""是否启用自动安装Python依赖包(主开关)"""
|
||||
|
||||
auto_install_timeout: int = 300
|
||||
"""安装超时时间(秒)"""
|
||||
@@ -946,9 +946,6 @@ class DependencyManagementConfig(ConfigBase):
|
||||
])
|
||||
"""pip安装选项"""
|
||||
|
||||
allowed_auto_install: bool = True
|
||||
"""是否允许自动安装(主开关),关闭后所有插件都不会自动安装依赖"""
|
||||
|
||||
prompt_before_install: bool = False
|
||||
"""安装前是否提示用户(暂未实现)"""
|
||||
|
||||
|
||||
@@ -66,13 +66,7 @@ class DependencyConfig:
|
||||
"--disable-pip-version-check"
|
||||
]
|
||||
|
||||
@property
|
||||
def allowed_auto_install(self) -> bool:
|
||||
"""是否允许自动安装"""
|
||||
config = self._get_config()
|
||||
if config and hasattr(config, 'dependency_management'):
|
||||
return config.dependency_management.allowed_auto_install
|
||||
return True
|
||||
|
||||
|
||||
@property
|
||||
def prompt_before_install(self) -> bool:
|
||||
|
||||
@@ -38,7 +38,6 @@ class DependencyManager:
|
||||
self.proxy_url = config.proxy_url if proxy_url is None else proxy_url
|
||||
self.install_timeout = config.install_timeout
|
||||
self.pip_options = config.pip_options.copy()
|
||||
self.allowed_auto_install = config.allowed_auto_install
|
||||
|
||||
except Exception as e:
|
||||
logger.warning(f"无法加载依赖配置,使用默认设置: {e}")
|
||||
@@ -47,7 +46,6 @@ class DependencyManager:
|
||||
self.proxy_url = proxy_url
|
||||
self.install_timeout = 300
|
||||
self.pip_options = ["--no-warn-script-location", "--disable-pip-version-check"]
|
||||
self.allowed_auto_install = True
|
||||
|
||||
def check_dependencies(self, dependencies: Any, plugin_name: str = "") -> Tuple[bool, List[str], List[str]]:
|
||||
"""检查依赖包是否满足要求
|
||||
@@ -98,7 +96,7 @@ class DependencyManager:
|
||||
if not packages:
|
||||
return True, []
|
||||
|
||||
if not self.auto_install or not self.allowed_auto_install:
|
||||
if not self.auto_install:
|
||||
logger.info(f"[Plugin:{plugin_name}] 自动安装已禁用,跳过安装: {packages}")
|
||||
return False, packages
|
||||
|
||||
|
||||
Reference in New Issue
Block a user