File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121import sysconfig
2222import tarfile
2323import urllib .request
24+ import zipfile
2425from ctypes .util import find_library
2526from pathlib import Path
2627
@@ -266,12 +267,15 @@ def _download_and_extract(self, filename: str) -> pathlib.Path:
266267
267268 # nightly have different download name and extracted folder name as it
268269 # uses a redirect
269- # TODO: FIX for zip
270270 if self .is_latest_nightly :
271- tar = tarfile .open (fpath )
272- folder = pathlib .Path (pathlib .Path (tar .getmembers ()[0 ].name ).parts [0 ])
271+ if self .archive_format == "zip" :
272+ zf = zipfile .ZipFile (fpath )
273+ folder = pathlib .Path (pathlib .Path (zf .namelist ()[0 ]).stem )
274+ else :
275+ tf = tarfile .open (fpath )
276+ folder = pathlib .Path (pathlib .Path (tf .getmembers ()[0 ].name ).stem )
273277 else :
274- folder = fpath .with_name (fpath .name . replace ( self . archive_suffix , "" ) )
278+ folder = fpath .with_name (fpath .stem )
275279 # unless for ZIP, extract to current folder (all files inside an in-tar folder)
276280 extract_to = folder if self .archive_format == "zip" else self .base_dir
277281 shutil .unpack_archive (fpath , extract_to , self .archive_format )
You can’t perform that action at this time.
0 commit comments