Files
agent-aide/aide-program/aide/env/modules/uv.py

53 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""uv 包管理器检测模块。"""
from __future__ import annotations
import subprocess
from pathlib import Path
from typing import Any
from aide.env.modules.base import BaseModule, CheckResult, ModuleInfo
class UvModule(BaseModule):
"""uv 包管理器检测模块类型A无需配置"""
@property
def info(self) -> ModuleInfo:
return ModuleInfo(
name="uv",
description="uv 包管理器",
capabilities=["check"],
requires_config=False,
)
def check(self, config: dict[str, Any], root: Path) -> CheckResult:
"""检测 uv 是否可用。"""
try:
result = subprocess.run(
["uv", "--version"],
check=True,
capture_output=True,
text=True,
)
version = result.stdout.strip()
return CheckResult(
success=True,
version=version,
)
except FileNotFoundError:
return CheckResult(
success=False,
message="未安装,请先安装 uv",
can_ensure=False,
)
except subprocess.CalledProcessError as exc:
return CheckResult(
success=False,
message=f"执行失败: {exc}",
can_ensure=False,
)
module = UvModule()