def extract_archive(fname, targetdir=None, verbose=False):
    if targetdir is None:
        targetdir = _create_temp_dir()
    if osp.splitext(fname)[1] in ('.zip', '.exe'):
        obj = zipfile.ZipFile(fname, mode="r")
    elif fname.endswith('.tar.gz'):
        obj = tarfile.open(fname, mode='r:gz')
    else:
        raise RuntimeError("Unsupported archive filename %s" % fname)
    obj.extractall(path=targetdir)
    return targetdir
Extract .zip, .exe (considered to be a zip archive) or .tar.gz archive
dataset/ETHPy150Open winpython/winpython/winpython/utils.py/extract_archive