def METHOD_NAME(project_root: Path | None) -> Path | None:
    if project_root is not None:
        venv = get_venv(project_root)
        if venv is not None:
            log.info(f"Using python from venv: {venv}")
            if sys.platform == "win32":
                return venv / "Scripts" / "python.exe"
            else:
                return venv / "bin" / "python"
    if sys.platform == "win32":
        log.info("No venv found, using py")
        result = shutil.which("py")
    else:
        log.info("No venv found, using python3")
        result = shutil.which("python3")
    if result is None:
        log.warning("no Python found")
        return None
    return Path(result)