diff --git a/astrbot/core/__init__.py b/astrbot/core/__init__.py index c88c39e6e..59e61d73b 100644 --- a/astrbot/core/__init__.py +++ b/astrbot/core/__init__.py @@ -23,7 +23,10 @@ db_helper = SQLiteDatabase(DB_PATH) sp = ( SharedPreferences() ) # 简单的偏好设置存储, 这里后续应该存储到数据库中, 一些部分可以存储到配置中 -pip_installer = PipInstaller(astrbot_config.get("pip_install_arg", "")) +pip_installer = PipInstaller( + astrbot_config.get("pip_install_arg", ""), + astrbot_config.get("pypi_index_url", None), +) web_chat_queue = asyncio.Queue(maxsize=32) web_chat_back_queue = asyncio.Queue(maxsize=32) WEBUI_SK = "Advanced_System_for_Text_Response_and_Bot_Operations_Tool" diff --git a/astrbot/core/config/default.py b/astrbot/core/config/default.py index 3be2acb15..28c075e68 100644 --- a/astrbot/core/config/default.py +++ b/astrbot/core/config/default.py @@ -97,7 +97,7 @@ DEFAULT_CONFIG = { "wake_prefix": ["/"], "log_level": "INFO", "pip_install_arg": "", - "plugin_repo_mirror": "", + "pypi_index_url": "https://mirrors.aliyun.com/pypi/simple/", "knowledge_db": {}, "persona": [], "timezone": "", @@ -1216,16 +1216,10 @@ CONFIG_METADATA_2 = { "type": "string", "hint": "安装插件依赖时,会使用 Python 的 pip 工具。这里可以填写额外的参数,如 `--break-system-package` 等。", }, - "plugin_repo_mirror": { - "description": "插件仓库镜像", + "pypi_index_url": { + "description": "PyPI 软件仓库地址", "type": "string", - "hint": "已废弃,请使用管理面板->设置页的代理地址选择", - "obvious_hint": True, - "options": [ - "default", - "https://ghp.ci/", - "https://github-mirror.us.kg/", - ], + "hint": "安装 Python 依赖时请求的 PyPI 软件仓库地址。默认为 https://mirrors.aliyun.com/pypi/simple/", }, }, }, diff --git a/astrbot/core/core_lifecycle.py b/astrbot/core/core_lifecycle.py index ee40187f5..9dc03d4af 100644 --- a/astrbot/core/core_lifecycle.py +++ b/astrbot/core/core_lifecycle.py @@ -106,7 +106,7 @@ class AstrBotCoreLifecycle: await self.pipeline_scheduler.initialize() # 初始化更新器 - self.astrbot_updator = AstrBotUpdator(self.astrbot_config["plugin_repo_mirror"]) + self.astrbot_updator = AstrBotUpdator() # 初始化事件总线 self.event_bus = EventBus(self.event_queue, self.pipeline_scheduler) diff --git a/astrbot/core/star/star_manager.py b/astrbot/core/star/star_manager.py index 377a53af2..60b0e0c69 100644 --- a/astrbot/core/star/star_manager.py +++ b/astrbot/core/star/star_manager.py @@ -28,7 +28,7 @@ from .filter.permission import PermissionTypeFilter, PermissionType class PluginManager: def __init__(self, context: Context, config: AstrBotConfig): - self.updator = PluginUpdator(config["plugin_repo_mirror"]) + self.updator = PluginUpdator() self.context = context self.context._star_manager = self diff --git a/astrbot/core/utils/pip_installer.py b/astrbot/core/utils/pip_installer.py index 2cbdc9229..0163b11b4 100644 --- a/astrbot/core/utils/pip_installer.py +++ b/astrbot/core/utils/pip_installer.py @@ -5,8 +5,9 @@ logger = logging.getLogger("astrbot") class PipInstaller: - def __init__(self, pip_install_arg: str): + def __init__(self, pip_install_arg: str, pypi_index_url: str = None): self.pip_install_arg = pip_install_arg + self.pypi_index_url = pypi_index_url def install( self, @@ -20,10 +21,9 @@ class PipInstaller: elif requirements_path: args.extend(["-r", requirements_path]) - if not mirror: - mirror = "https://mirrors.aliyun.com/pypi/simple/" + index_url = mirror or self.pypi_index_url or "https://pypi.org/simple" - args.extend(["--trusted-host", "mirrors.aliyun.com", "-i", mirror]) + args.extend(["--trusted-host", "mirrors.aliyun.com", "-i", index_url]) if self.pip_install_arg: args.extend(self.pip_install_arg.split()) diff --git a/astrbot/dashboard/routes/update.py b/astrbot/dashboard/routes/update.py index bd0782088..44adf2591 100644 --- a/astrbot/dashboard/routes/update.py +++ b/astrbot/dashboard/routes/update.py @@ -136,10 +136,11 @@ class UpdateRoute(Route): data = await request.json package = data.get("package", "") + mirror = data.get("mirror", None) if not package: return Response().error("缺少参数 package 或不合法。").__dict__ try: - pip_installer.install(package) + pip_installer.install(package, mirror=mirror) return Response().ok(None, "安装成功。").__dict__ except Exception as e: logger.error(f"/api/update_pip: {traceback.format_exc()}") diff --git a/dashboard/src/views/ConsolePage.vue b/dashboard/src/views/ConsolePage.vue index 2ac9b3a73..83de2bb66 100644 --- a/dashboard/src/views/ConsolePage.vue +++ b/dashboard/src/views/ConsolePage.vue @@ -27,8 +27,8 @@ import axios from 'axios'; - - 如果不填镜像站链接,默认使用阿里云镜像:https://mirrors.aliyun.com/pypi/simple/ + + 强制 PyPI 软件仓库链接 > 配置项 `PyPI 软件仓库地址`
{{ status }}