Skip to content

Commit 75135fe

Browse files
committed
cache_dependencies.py - fix tarfile deprecation warnings in 3.12-3.13
1 parent de89ab3 commit 75135fe

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pyodide/cache_dependencies.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import tarfile
1212
import sys
1313
from pathlib import Path
14+
from typing import Literal
1415

1516

1617
CACHE_PREFIX = "cache-"
@@ -38,9 +39,14 @@ def pack_dependencies(install_dir: Path) -> None:
3839

3940

4041
def unpack_dependencies(install_dir: Path) -> None:
42+
# `filter` argument was fully introduced in 3.12
43+
# and results in deprecation warnings in 3.12-3.13, if not provided.
44+
tar_filter: "dict[Literal['filter'], Literal['data']]" = (
45+
{"filter": "data"} if bool(sys.version_info >= (3, 12)) else {}
46+
)
4147
for tar_path in install_dir.glob(f"{CACHE_PREFIX}*.tar.gz"):
4248
with tarfile.open(tar_path, "r:gz") as tar:
43-
tar.extractall(path=install_dir)
49+
tar.extractall(path=install_dir, **tar_filter)
4450
print(f"Extracted cache: '{tar_path.name}'.")
4551

4652

0 commit comments

Comments
 (0)