File size: 985 Bytes
c57274b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43199e3
d1c3651
4ad81fd
 
 
 
 
 
c57274b
d1c3651
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
import shutil


def find_stockfish_path():
    # Try to find stockfish in PATH
    path = shutil.which("stockfish")
    if path:
        return path

    # Try common locations if not in PATH
    common_paths = [
        "/usr/bin/stockfish",
        "/usr/games/stockfish",
        "/usr/local/bin/stockfish",
        "/opt/homebrew/bin/stockfish",  # macOS with Homebrew
        "C:\\stockfish\\stockfish.exe",  # Windows
    ]

    for path in common_paths:
        if os.path.exists(path):
            return path

    return None


def check_dependencies():
    chess_engine_path = os.getenv("CHESS_ENGINE_PATH")
    if chess_engine_path is None:
        stockfish_path = find_stockfish_path()
        if stockfish_path:
            print(f"Found Stockfish at: {stockfish_path}")
            os.environ["CHESS_ENGINE_PATH"] = stockfish_path
        else:
            print("Stockfish not found!")
    else:
        print(f"Stockfish already set to {chess_engine_path}")