From 6af14bddcacfa1aab5880f3fecc13d1b2bf3c4ba Mon Sep 17 00:00:00 2001 From: bw513 <192128226+bw513@users.noreply.github.com> Date: Fri, 20 Dec 2024 13:37:51 +0000 Subject: [PATCH] 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` --- scripts/create-python-mirror.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/create-python-mirror.py b/scripts/create-python-mirror.py index 3532e22b6..97d2b1bab 100644 --- a/scripts/create-python-mirror.py +++ b/scripts/create-python-mirror.py @@ -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