From 75135fe45d83c85999af423ffd226690b7bc5eb7 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 24 Oct 2025 12:33:44 +0500 Subject: [PATCH] cache_dependencies.py - fix tarfile deprecation warnings in 3.12-3.13 --- pyodide/cache_dependencies.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pyodide/cache_dependencies.py b/pyodide/cache_dependencies.py index b7cabcb73f..3a88587a26 100644 --- a/pyodide/cache_dependencies.py +++ b/pyodide/cache_dependencies.py @@ -11,6 +11,7 @@ Usage: python cache_dependencies.py [pack|unpack] import tarfile import sys from pathlib import Path +from typing import Literal CACHE_PREFIX = "cache-" @@ -38,9 +39,14 @@ def pack_dependencies(install_dir: Path) -> None: def unpack_dependencies(install_dir: Path) -> None: + # `filter` argument was fully introduced in 3.12 + # and results in deprecation warnings in 3.12-3.13, if not provided. + tar_filter: "dict[Literal['filter'], Literal['data']]" = ( + {"filter": "data"} if bool(sys.version_info >= (3, 12)) else {} + ) for tar_path in install_dir.glob(f"{CACHE_PREFIX}*.tar.gz"): with tarfile.open(tar_path, "r:gz") as tar: - tar.extractall(path=install_dir) + tar.extractall(path=install_dir, **tar_filter) print(f"Extracted cache: '{tar_path.name}'.")