| 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}") | |