"""Print pip constraints (name==version) for every package in a uv.lock. Used at image build time to install a Python tool's release wheel (ghidra-mcp, unblob) with the exact dependency versions its upstream lock file was tested with. The locked project itself (source "editable"/"virtual" at ".") is skipped; it is installed from the wheel. A package that uv resolved differently per Python version appears more than once; those entries carry their resolution markers, so pip applies only the one that matches the interpreter. """ import sys import tomllib with open(sys.argv[1], "rb") as f: lock = tomllib.load(f) for package in lock["package"]: source = package.get("source", {}) if source.get("editable") == "." or source.get("virtual") == ".": continue line = f'{package["name"]}=={package["version"]}' markers = package.get("resolution-markers") if markers: line += " ; " + " or ".join(f"({m})" for m in markers) print(line)