Fix mirror script to handle newer metadata format. (#10050)

## Summary

The architecture details in `crates/uv-python/download-metadata.json` is
now a dictionary with family and variant data, whereas it used to be a
string. This patches the architecture filter in
`scripts/create-python-mirror.py` to support both scenarios.

## Test Plan

Tested manually using `uv run ./scripts/create-python-mirror.py --name
cpython --arch x86_64 --os linux --from-all-history`
This commit is contained in:
bw513 2024-12-20 13:37:51 +00:00 committed by GitHub
parent ae659c8bfe
commit 6af14bddca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -89,6 +89,15 @@ def collect_metadata_from_git_history() -> List[Dict]:
return metadata
def check_arch(entry, arch):
"""Checks whether arch entry in metadata matches the provided filter."""
if isinstance(entry, str):
return entry == arch
elif isinstance(entry, dict) and "family" in entry:
return entry["family"] == arch
return False
def filter_metadata(
metadata: List[Dict], name: Optional[str], arch: Optional[str], os: Optional[str]
) -> List[Dict]:
@ -97,7 +106,7 @@ def filter_metadata(
entry
for entry in metadata
if (not name or entry["name"] == name)
and (not arch or entry["arch"] == arch)
and (not arch or check_arch(entry["arch"], arch))
and (not os or entry["os"] == os)
]
# Use a set to ensure unique URLs