OzonConsultant / setup_checks.py
teslatony's picture
Create setup_checks.py
96695f3 verified
# FILE: setup_checks.py
import sys
import subprocess
import importlib
import os
print("=== Setup Checks ===")
# Python version
if sys.version_info < (3, 10):
print(f"[ERROR] Python >= 3.10 required, found {sys.version}")
sys.exit(1)
print(f"[OK] Python version: {sys.version}")
# Check installed packages
with open("requirements.txt") as f:
for line in f:
pkg = line.strip().split("==")[0]
try:
importlib.import_module(pkg)
print(f"[OK] Package '{pkg}' installed")
except ImportError:
print(f"[ERROR] Package '{pkg}' missing. Run: pip install -r requirements.txt")
sys.exit(1)
# Static analysis (flake8 optional)
try:
subprocess.run(["flake8", "app.py"], check=False)
except Exception:
print("[WARNING] flake8 not installed, skipping static analysis.")
# Smoke test
try:
import app
state = app.reset_state()
chat_history, state, _ = app.on_user_message("Привет!", state)
if not chat_history or not isinstance(chat_history, list):
print("[ERROR] Smoke test failed: chat_history empty or invalid")
sys.exit(1)
print("[OK] Smoke test passed")
except Exception as e:
print(f"[ERROR] Smoke test failed: {e}")
sys.exit(1)
print("=== Setup Checks Completed ===")