#!/usr/bin/env python3 """ Run `uv pip sync` with a `requirements.txt` file in the current folder. This will pick which file to use. """ import os from pathlib import Path import shlex import subprocess import sys if __name__ == "__main__": # If we're on an external disk, disable the warning about being # unable to clone files. In particular: # # warning: Failed to clone files; falling back to full copy. # This may lead to degraded performance. If the cache and target # directories are on different filesystems, reflinking may not # be supported. # # If this is intentional, set `export UV_LINK_MODE=copy` or use # `--link-mode=copy` to suppress this warning. # # On macOS, this means "are you in a path that starts with /Volumes". if os.getcwd().startswith("/Volumes/"): os.environ.update({"UV_LINK_MODE": "copy"}) # If a dev_requirements.txt file is available, use that, otherwise use # the standard `requirements.txt`. if Path("dev_requirements.txt").exists(): chosen_file = "dev_requirements.txt" else: chosen_file = "requirements.txt" # Build the command to run. cmd = ["uv", "pip", "sync", chosen_file] if "--no-cache" in sys.argv: cmd.append("--no-cache") # Actually run the command, and print a debug entry for it. subprocess.check_call( [str(Path.home() / "repos/scripts/debug/print_info"), f"-> {shlex.join(cmd)}"] ) subprocess.check_call(cmd, stdout=subprocess.DEVNULL)