def extract_archive(fname, targetdir=None, verbose=False):
    """Extract .zip, .exe or .tar.gz archive to a temporary directory.
    Return the temporary directory path"""
    targetdir = targetdir or create_temp_dir()
    Path(targetdir).mkdir(parents=True, exist_ok=True)
    if Path(fname).suffix in ('.zip', '.exe'):
        obj = zipfile.ZipFile(fname, mode="r")
    elif fname.endswith('.tar.gz'):
        obj = tarfile.open(fname, mode='r:gz')
    else:
        raise RuntimeError(f"Unsupported archive filename {fname}")
    obj.extractall(path=targetdir)
    return targetdir
Extract .zip, .exe or .tar.gz archive to a temporary directory.
    Return the temporary directory path
winpython/utils.py