mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 06:21:40 +00:00
cache_dependencies.py - fix tarfile deprecation warnings in 3.12-3.13
This commit is contained in:
@@ -11,6 +11,7 @@ Usage: python cache_dependencies.py [pack|unpack]
|
|||||||
import tarfile
|
import tarfile
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import Literal
|
||||||
|
|
||||||
|
|
||||||
CACHE_PREFIX = "cache-"
|
CACHE_PREFIX = "cache-"
|
||||||
@@ -38,9 +39,14 @@ def pack_dependencies(install_dir: Path) -> None:
|
|||||||
|
|
||||||
|
|
||||||
def unpack_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"):
|
for tar_path in install_dir.glob(f"{CACHE_PREFIX}*.tar.gz"):
|
||||||
with tarfile.open(tar_path, "r:gz") as tar:
|
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}'.")
|
print(f"Extracted cache: '{tar_path.name}'.")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user