From df1e59e01c82e8a582f24a304230117deb1bdd65 Mon Sep 17 00:00:00 2001 From: qingyun Date: Tue, 17 Mar 2026 18:59:24 +0800 Subject: [PATCH] fix(core): use original version constraints instead of locking to installed version (#6445) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: Add OpenRouter chat completion provider adapter with custom headers. (#6436) * chore: update astrbot.service configuration * fix(core): use original version constraints instead of locking to installed version Fixes #6420 The core constraints mechanism was using the currently installed version as an exact constraint (e.g., `aiosqlite==0.21.0`), preventing plugins from installing higher versions even when they satisfy the original constraint. Changes: - Preserve original version specifier from pyproject.toml (e.g., `>=0.21.0`) - Allow plugins to require higher versions as long as they satisfy core constraint - Prevent downgrade by using `>=installed` for packages without version constraint Example: - Before: Core constraint `aiosqlite==0.21.0`, plugin requires `>=0.22.1` → BLOCKED - After: Core constraint `aiosqlite>=0.21.0`, plugin requires `>=0.22.1` → ALLOWED This enables better dependency management while still protecting core dependencies from incompatible downgrades. --------- Co-authored-by: Futureppo Co-authored-by: LIghtJUNction Co-authored-by: ccsang --- astrbot/core/utils/core_constraints.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/astrbot/core/utils/core_constraints.py b/astrbot/core/utils/core_constraints.py index b43f00122..3a8b0e0d5 100644 --- a/astrbot/core/utils/core_constraints.py +++ b/astrbot/core/utils/core_constraints.py @@ -80,7 +80,13 @@ def _get_core_constraints(core_dist_name: str | None) -> tuple[str, ...]: continue name = canonicalize_distribution_name(req.name) if name in installed: - constraints.append(f"{name}=={installed[name]}") + # Use the original constraint from pyproject.toml instead of ==installed_version + # This allows plugins to require higher versions as long as they satisfy the core constraint + if req.specifier: + constraints.append(f"{name}{req.specifier}") + else: + # No version constraint in original, use >=installed to prevent downgrade + constraints.append(f"{name}>={installed[name]}") except Exception: continue