#!/usr/bin/env python3
"""
检查当前解释器是否满足 core.system 中的最低 Python 版本。
"""
from __future__ import annotations

import sys
from pathlib import Path

_REPO_ROOT = Path(__file__).resolve().parent.parent.parent.parent
if str(_REPO_ROOT) not in sys.path:
    sys.path.insert(0, str(_REPO_ROOT))

from setup.setup import NewTeaQuantSetup

NewTeaQuantSetup.ensure_venv_for_setup_step(__file__)

from core.system import python_minimum
from core.utils import i


def main() -> None:
    min_ver = python_minimum()
    step_result = 0
    step_icon = i("failed")

    if sys.version_info >= min_ver:
        step_result = 1
        step_icon = i("success")

    print(
        f"Python version: {sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro} - {step_icon}",
        file=sys.stderr,
    )

    if step_result == 0:
        sys.exit(1)


if __name__ == "__main__":
    main()
