'Create the buffer-independent list of libs.'

def _buf_indep_libs_from_env(self, env):

    cache_key = 'perl-libs'
    if (cache_key not in env.cache):
        env.add_pref_observer('perl', self._invalidate_cache)
        env.add_pref_observer('perlExtraPaths', self._invalidate_cache_and_rescan_extra_dirs)
        env.add_pref_observer('codeintel_selected_catalogs', self._invalidate_cache)
        db = self.mgr.db
        perl = None
        if env.has_pref('perl'):
            perl = (env.get_pref('perl').strip() or None)
        if ((not perl) or (not exists(perl))):
            perl = self._perl_from_env(env)
        if (not perl):
            log.warn('no    Perl    was    found    from    which    to    determine    the    import    path')
            (perl_ver, config_dirs, import_path) = (None, {}, [])
        else:
            (perl_ver, config_dirs, import_path) = self._perl_info_from_perl(perl, env)
        libs = []
        extra_dirs = self._extra_dirs_from_env(env)
        if extra_dirs:
            log.debug('Perl    extra    lib    dirs:    %r', extra_dirs)
            libs.append(db.get_lang_lib('Perl', 'extradirslib', extra_dirs))
        paths_from_libname = {'sitelib': [], 'envlib': [], 'stdlib': []}
        for dir in import_path:
            dir = normpath(dir)
            if (dir == '.'):
                continue
            if islink(dir):
                link_value = os.readlink(dir)
                if isabs(link_value):
                    dir = link_value
                else:
                    dir = normpath(join(dirname(dir), link_value))
            if (not isdir(dir)):
                log.debug("perl    @INC    value    '%s'    is    not    a    dir:    dropping    it", dir)
                continue
            for config_dir_name in ('archlib', 'privlib', 'vendorarch', 'vendorlib'):
                if (config_dirs[config_dir_name] and dir.startswith(config_dirs[config_dir_name])):
                    paths_from_libname['stdlib'].append(dir)
                    break
            else:
                if (config_dirs['siteprefix'] and dir.startswith(config_dirs['siteprefix'])):
                    paths_from_libname['sitelib'].append(dir)
                else:
                    paths_from_libname['envlib'].append(dir)
        log.debug('Perl    %s    paths    for    each    lib:\n%s', perl_ver, indent(pformat(paths_from_libname)))
        if paths_from_libname['envlib']:
            libs.append(db.get_lang_lib('Perl', 'envlib', paths_from_libname['envlib']))
        if paths_from_libname['sitelib']:
            libs.append(db.get_lang_lib('Perl', 'sitelib', paths_from_libname['sitelib']))
        catalog_selections = env.get_pref('codeintel_selected_catalogs')
        libs += [db.get_catalog_lib('Perl', catalog_selections), db.get_stdlib('Perl', perl_ver)]
        env.cache[cache_key] = libs
    return env.cache[cache_key]
