def parse_pylock_toml(path: Path) -> Dict[str, Dict[str, str | List[str]]]:
    """Parse a pylock.toml file and extract package information."""
    with open(path, "rb") as f:
        data = tomllib.load(f)

    # This dictionary maps package names to (version, [hashes])
    package_hashes = defaultdict(lambda: {"version": "", "hashes": []})

    for entry in data.get("packages", []):
        name = entry["name"]
        version = entry["version"]
        all_hashes = []

        # Handle wheels
        for wheel in entry.get("wheels", []):
            sha256 = wheel.get("hashes", {}).get("sha256")
            if sha256:
                all_hashes.append(sha256)

        # Handle sdist (if present)
        sdist = entry.get("sdist")
        if sdist and "hashes" in sdist:
            sha256 = sdist["hashes"].get("sha256")
            if sha256:
                all_hashes.append(sha256)

        package_hashes[name]["version"] = version
        package_hashes[name]["hashes"].extend(all_hashes)

    return package_hashes
Parse a pylock.toml file and extract package information.
winpython/wheelhouse.py