def _extract_local_archive(working_dir, cleanup_functions, env_name, local_archive):
    """Helper internal function for extracting a zipfile and ensure that a cleanup is queued.

    Parameters
    ----------
    working_dir : str
    cleanup_functions : List[() -> NoneType]
    env_name : str
    local_archive : str
    """
    with zipfile.ZipFile(local_archive) as z:
        z.extractall(working_dir)
        archive_filenames = z.namelist()

    root_elements = {m.split(posixpath.sep, 1)[0] for m in archive_filenames}
    abs_archive_filenames = [os.path.abspath(os.path.join(working_dir, f)) for f in root_elements]

    def cleanup():
        for fn in abs_archive_filenames:
            if os.path.isdir(fn):
                shutil.rmtree(fn)
            else:
                os.unlink(fn)

    cleanup_functions.append(cleanup)
    env_dir = os.path.join(working_dir, env_name)
    # Because of a python deficiency (Issue15795), the execute bits aren't
    # preserved when the zip file is unzipped. Need to add them back here.
    _fix_permissions(env_dir)
    return env_dir
Helper internal function for extracting a zipfile and ensure that a cleanup is queued.

    Parameters
    ----------
    working_dir : str
    cleanup_functions : List[() -> NoneType]
    env_name : str
    local_archive : str