import subprocess import tempfile import shutil from pathlib import Path def fetch_file(repo_url: str, file_path: str, dest: Path): tmp = tempfile.mkdtemp() subprocess.check_call(["git", "clone", "--depth", "1", repo_url, tmp]) src = Path(tmp) / file_path if not src.exists(): raise FileNotFoundError(file_path) shutil.copy2(src, dest / src.name)