fix(core): use original version constraints instead of locking to installed version (#6445)

* 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 <luominzhi2005@qq.com>
Co-authored-by: LIghtJUNction <lightjunction.me@gmail.com>
Co-authored-by: ccsang <ccsang@users.noreply.github.com>
This commit is contained in:
qingyun
2026-03-17 18:59:24 +08:00
committed by GitHub
parent 25f9effcc9
commit df1e59e01c
+7 -1
View File
@@ -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