mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 07:27:15 +08:00
fix(plugin): filter declared uv dependency exclusions (#6437)
This commit is contained in:
@@ -6,6 +6,9 @@ import tomllib
|
||||
from collections.abc import Iterable
|
||||
from pathlib import Path
|
||||
|
||||
from packaging.requirements import InvalidRequirement, Requirement
|
||||
from packaging.utils import canonicalize_name
|
||||
|
||||
from app.foundation.environment import is_free_threaded_runtime
|
||||
|
||||
|
||||
@@ -52,5 +55,33 @@ def iter_runtime_profile_requirement_strings(project_file: Path) -> Iterable[str
|
||||
yield requirement
|
||||
|
||||
|
||||
def runtime_excluded_dependency_pairs(project_file: Path) -> set[tuple[str, str]]:
|
||||
"""返回项目明确排除的“依赖包 -> 传递依赖”规范化名称对。"""
|
||||
with project_file.open("rb") as file:
|
||||
document = tomllib.load(file)
|
||||
|
||||
exclusions = (
|
||||
((document.get("tool") or {}).get("uv") or {}).get("exclude-dependencies")
|
||||
or ()
|
||||
)
|
||||
pairs: set[tuple[str, str]] = set()
|
||||
for exclusion in exclusions:
|
||||
if not isinstance(exclusion, dict):
|
||||
continue
|
||||
package = exclusion.get("package") or {}
|
||||
package_name = package.get("name") if isinstance(package, dict) else None
|
||||
if not isinstance(package_name, str) or not package_name.strip():
|
||||
continue
|
||||
for dependency in exclusion.get("dependencies") or ():
|
||||
if not isinstance(dependency, str):
|
||||
continue
|
||||
try:
|
||||
dependency_name = Requirement(dependency).name
|
||||
except InvalidRequirement:
|
||||
continue
|
||||
pairs.add((canonicalize_name(package_name), canonicalize_name(dependency_name)))
|
||||
return pairs
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(runtime_dependency_group())
|
||||
|
||||
Reference in New Issue
Block a user