import subprocess import os import sys import shutil def find_lambda_dir(): for root, dirs, files in os.walk("."): if "pyproject.toml" in files: return root return None def run_uv_compile(lambda_dir): try: print("Compiling uv.lock with latest dependency versions...") subprocess.run( ["uv", "lock"], cwd=lambda_dir, check=True, ) print("uv.lock generated.") except subprocess.CalledProcessError as e: print(f"Failed to generate uv.lock: {e}") sys.exit(1) if __name__ == "__main__": if shutil.which("uv") is None: print("'uv' is not installed. Please run 'uv lock' manually.") sys.exit(0) lambda_dir = find_lambda_dir() if lambda_dir: run_uv_compile(lambda_dir) else: print("Skipping uv.lock generation: pyproject.toml not found.")