bootstrap: fix DeprecationWarning

DeprecationWarning: Python 3.14 will, by default, filter extracted tar archives and reject files or modify their metadata. Use the filter argument to control this behavior.

See:
https://docs.python.org/3.12/library/tarfile.html#tarfile-extraction-filter
pull/324/head
Guðni Már Gilbert 2024-07-27 22:17:22 +00:00 committed by 3d-gussner
parent ca1d09ad15
commit 32d5f3b4be
1 changed files with 6 additions and 1 deletions

View File

@ -19,6 +19,7 @@ import tarfile
import zipfile import zipfile
from argparse import ArgumentParser from argparse import ArgumentParser
from pathlib import Path from pathlib import Path
from tarfile import TarFile
from urllib.request import urlretrieve from urllib.request import urlretrieve
project_root_dir = Path(__file__).resolve().parent.parent project_root_dir = Path(__file__).resolve().parent.parent
dependencies_dir = project_root_dir / '.dependencies' dependencies_dir = project_root_dir / '.dependencies'
@ -99,7 +100,11 @@ def download_and_unzip(url: str, directory: Path):
obj = tarfile.open(f) obj = tarfile.open(f)
else: else:
obj = zipfile.ZipFile(f, 'r') obj = zipfile.ZipFile(f, 'r')
obj.extractall(path=str(extract_dir))
if isinstance(obj, TarFile):
obj.extractall(path=str(extract_dir), filter='data')
else: # Zip file
obj.extractall(path=str(extract_dir))
subdir = find_single_subdir(extract_dir) subdir = find_single_subdir(extract_dir)
shutil.move(str(subdir), str(directory)) shutil.move(str(subdir), str(directory))