"""Locate the official SimpleX binaries — never built/modified here, only invoked. Resolution order: $SIMPLEX_BIN dir, then ./bin/, then PATH. Place prebuilt binaries (simplex-chat, simplex-directory-service, simplex-broadcast-bot) in ./bin/ or install via the upstream install script. We never compile or alter them. """ import os import shutil from pathlib import Path BIN_DIR = Path(os.environ.get("SIMPLEX_BIN", Path(__file__).resolve().parent.parent / "bin")) KNOWN = ("simplex-chat", "simplex-directory-service", "simplex-broadcast-bot") def binary_path(name: str) -> str: local = BIN_DIR / name if local.exists(): return str(local) found = shutil.which(name) if found: return found raise FileNotFoundError(f"{name!r} not found in {BIN_DIR} or PATH")