Installs conda dependencies.

    :param cfg: configuration dict
175642
def get_deps(cfg=None,deps=[]):
    
    if not cfg is None:
        if not 'deps' in cfg:
            cfg['deps']=deps
        else:
            deps=cfg['deps']
    if not len(deps)==0:
        for dep in deps:
            if not dep in cfg:
                runbashcmd(f'conda install {dep}',test=cfg['test'])
                cfg[dep]=dep
    logging.info(f"{len(deps)} deps installed.")
    return cfg
231648
def _mkdir_for_config(cfg_file=cfg_file):
    
    dirname, filename = os.path.split(cfg_file)
    try:
        os.makedirs(dirname)
    except OSError as exc:
        if exc.errno == errno.EEXIST and os.path.isdir(dirname):
            pass
        else:
            raise
490872
def compile(self):
        
        if self.disabled:
            return
        self._check_configs()
        for _, cfg in self.configs.iteritems():
            cfg.parse()
            if cfg.changes_found() or self.skip_mtime_check:
                self.log.debug("Changes found for " + cfg.path \
                        + " or checks disabled. Compiling...")
                cfg.compile(self)
584004
def install(config):  # pragma: no cover
        """"""
        client = Client()
        client.prepare_connection()
        key_api = API(client)
        key_api.install()
561069
def load_cfg(self, src_dir):
        

        # last files override previous ones
        cfg_files = [os.path.expanduser(USER_CFG_FILE),
                     os.path.abspath(os.path.join(src_dir, '.dirsync'))]

        cfg = ConfigParser()
        cfg.read(cfg_files)

        if not cfg.has_section('defaults'):
            return

        defaults = {}
        for name, val in cfg.items('defaults'):
            try:
                opt = OPTIONS[name][1]
            except KeyError:
                if name == 'action':
                    if val in OPTIONS:
                        defaults['action'] = val
                    else:
                        raise ValueError('Invalid value for "action" option '
                                         'in configuration file: %s' % val)
                continue

            curdef = opt.get('default', '')
            if isinstance(curdef, bool):
                newdef = val not in ('0', 'False', 'false')
            elif isinstance(curdef, string_types):
                newdef = val
            else:
                newdef = val.strip('\n').split('\n')

            defaults[name] = newdef

        self.set_defaults(**defaults)
914398
def configure(options, cfg)
      cfg = super(options, cfg)
      cfg[:offline_queueing] = options[:offline_queueing]
      cfg[:filter_params] = options[:filter_params]
      cfg
    end
296714
def install_pkgs(self, offline=False):
        
        if not offline and self.pkgs:
            self.logger.info("Installing conda packages ...")
            cmd = [join(self.anaconda_home, 'bin', 'conda')]
            cmd.append('install')
            # if offline:
            #     cmd.append('--offline')
            #     self.logger.info("... offline mode ...")
            if not self.newest:
                cmd.append('--no-update-deps')
                self.logger.info("... no update dependencies ...")
            if self.env:
                self.logger.info("... in conda environment %s ...", self.env)
                cmd.extend(['-n', self.env])
            cmd.append('--yes')
            if self.no_pin:
                cmd.append('--no-pin')
                self.logger.info("... no pin ...")
            if self.channel_priority:
                self.logger.info("... channel priority ...")
                cmd.append('--channel-priority')
            if self.channels:
                if self.override_channels:
                    self.logger.info('... override channels ...')
                    cmd.append('--override-channels')
                self.logger.info("... with conda channels: %s ...",
                                 ', '.join(self.channels))
                for channel in self.channels:
                    cmd.append('-c')
                    cmd.append(channel)
            cmd.extend(self.pkgs)
            try:
                self.logger.debug("install_pkgs cmd: %s", cmd)
                check_call(cmd)
            except CalledProcessError as err:
                self.logger.error("Conda exited with errors: %s", err.output)
        return self.pkgs
784757
def load_cfg(path, envvar_prefix='LIBREANT_', debug=False):
    ''''''
    try:
        return load_configs(envvar_prefix, path=path)
    except Exception as e:
        if debug:
            raise
        else:
            die(str(e))
513026
def cfg2dict(cfg):
    
    d = {}
    for section in cfg.sections():
        d[section] = dict(cfg.items(section))
    return d
723353
def install(
        config_file, store,
        overwrite=False, hooks=False, hook_type='pre-commit',
        skip_on_missing_conf=False,
):
    """"""
    if cmd_output('git', 'config', 'core.hooksPath', retcode=None)[1].strip():
        logger.error(
            'Cowardly refusing to install hooks with `core.hooksPath` set.\n'
            'hint: `git config --unset-all core.hooksPath`',
        )
        return 1

    hook_path, legacy_path = _hook_paths(hook_type)

    mkdirp(os.path.dirname(hook_path))

    # If we have an existing hook, move it to pre-commit.legacy
    if os.path.lexists(hook_path) and not is_our_script(hook_path):
        shutil.move(hook_path, legacy_path)

    # If we specify overwrite, we simply delete the legacy file
    if overwrite and os.path.exists(legacy_path):
        os.remove(legacy_path)
    elif os.path.exists(legacy_path):
        output.write_line(
            'Running in migration mode with existing hooks at {}\n'
            'Use -f to use only pre-commit.'.format(legacy_path),
        )

    params = {
        'CONFIG': config_file,
        'HOOK_TYPE': hook_type,
        'INSTALL_PYTHON': sys.executable,
        'SKIP_ON_MISSING_CONFIG': skip_on_missing_conf,
    }

    with io.open(hook_path, 'w') as hook_file:
        contents = resource_text('hook-tmpl')
        before, rest = contents.split(TEMPLATE_START)
        to_template, after = rest.split(TEMPLATE_END)

        before = before.replace('#!/usr/bin/env python3', shebang())

        hook_file.write(before + TEMPLATE_START)
        for line in to_template.splitlines():
            var = line.split()[0]
            hook_file.write('{} = {!r}\n'.format(var, params[var]))
        hook_file.write(TEMPLATE_END + after)
    make_executable(hook_path)

    output.write_line('pre-commit installed at {}'.format(hook_path))

    # If they requested we install all of the hooks, do so.
    if hooks:
        install_hooks(config_file, store)

    return 0
1162569
def cfg_file(self):
        
        default_path = os.path.join(self.relpath, '.git', 'config')
        if os.path.exists(default_path):
            return default_path

        dotgitpath = os.path.join(self.relpath, '.git')
        cfg_path = None
        # with git submodules, .git is a file containing "gitdir: .../../path"
        if os.path.isfile(dotgitpath):
            with codecs.open(dotgitpath, 'r', encoding='utf8') as f:
                for _line in f:
                    l = _line.strip()
                    if l.startswith('gitdir:'):
                        # gitdir: ../.git/modules/modname
                        cfg_path_relative = l.split('gitdir:', 1)[-1].strip()
                        cfg_path_absolute = os.path.abspath(
                            os.path.join(
                                os.path.dirname(dotgitpath),
                                cfg_path_relative,
                                'config'))
                        cfg_path = cfg_path_absolute
                        log.debug(('cfg_path_absolute', cfg_path_absolute))
                        #raise Exception(cfg_path_absolute) #_absolute)
                        break
        return cfg_path
1001008
def install_config(self):
        
        text = templ_config.render(**self.options)
        config = Configuration(self.buildout, 'supervisord.conf', {
            'deployment': self.deployment_name,
            'text': text})
        return [config.install()]
350642
def _check_for_conda_problems():
    
    conda_bin = _get_conda_bin()
    channels = _get_conda_channels(conda_bin)
    lib_dir = os.path.join(os.path.dirname(conda_bin), os.pardir, "lib")
    for l in ["libgomp.so.1", "libquadmath.so"]:
        if not os.path.exists(os.path.join(lib_dir, l)):
            subprocess.check_call([conda_bin, "install", "-f", "--yes"] + channels + ["libgcc-ng"])
108990
def install_deps(pkgpath):
    
    if os.path.exists(os.path.join(pkgpath, "requirements.txt")):
        logger.debug("installing dependencies")
        click.secho("[*] Installing dependencies")
        pipargs = ["install", "--target", os.path.join(pkgpath, defs.DEPS_DIR), "--ignore-installed",
                   "-r", os.path.join(pkgpath, "requirements.txt")]
        logger.debug("running pip %s", pipargs)
        return subprocess.check_call([sys.executable, "-m", "pip"] + pipargs)
    return 0
1105493
def _install_dependencies(self, ui, debug):
        """"""
        for dep_t, dep_l in self.dependencies:
            if not dep_l:
                continue
            pkg_mgr = self.get_package_manager(dep_t)
            pkg_mgr.works()
            to_resolve = []
            for dep in dep_l:
                if not pkg_mgr.is_pkg_installed(dep):
                    to_resolve.append(dep)
            if not to_resolve:
                # nothing to install, let's move on
                continue
            to_install = pkg_mgr.resolve(*to_resolve)
            confirm = self._ask_to_confirm(ui, pkg_mgr, *to_install)
            if not confirm:
                msg = 'List of packages denied by user, exiting.'
                raise exceptions.DependencyException(msg)

            type(self).install_lock = True
            # TODO: we should do this more systematically (send signal to cl/gui?)
            logger.info('Installing dependencies, sit back and relax ...',
                        extra={'event_type': 'dep_installation_start'})
            if ui == 'cli' and not debug:  # TODO: maybe let every manager to decide when to start
                event = threading.Event()
                t = EndlessProgressThread(event)
                t.start()
            installed = pkg_mgr.install(*to_install)
            if ui == 'cli' and not debug:
                event.set()
                t.join()
                if installed:
                    logger.info(' Done.')
                else:
                    logger.error(' Failed.')
            type(self).install_lock = False

            log_extra = {'event_type': 'dep_installation_end'}
            if not installed:
                msg = 'Failed to install dependencies, exiting.'
                logger.error(msg, extra=log_extra)
                raise exceptions.DependencyException(msg)
            else:
                logger.info('Successfully installed dependencies!', extra=log_extra)
333297
def load(self, optional_cfg_files=None):
        
        optional_cfg_files = optional_cfg_files or []

        # Guard against coding errors
        if self._loaded:
            raise RuntimeError("INTERNAL ERROR: Attempt to load configuration twice!")

        try:
            # Load configuration
            namespace = {}
            self._set_defaults(namespace, optional_cfg_files)

            self._load_ini(namespace, os.path.join(self.config_dir, self.CONFIG_INI))

            for cfg_file in optional_cfg_files:
                if not os.path.isabs(cfg_file):
                    cfg_file = os.path.join(self.config_dir, cfg_file)

                if os.path.exists(cfg_file):
                    self._load_ini(namespace, cfg_file)

            self._validate_namespace(namespace)
            self._load_py(namespace, namespace["config_script"])
            self._validate_namespace(namespace)

            for callback in namespace["config_validator_callbacks"]:
                callback()
        except ConfigParser.ParsingError as exc:
            raise error.UserError(exc)

        # Ready to go...
        self._loaded = True
385803
def create_setup_cfg(self, path):  # type: (str) -> None
        
        source = """[metadata]
name = {0}
version=0.0.1 
""".format(
            self.project
        )
        with io.open(path, "w", encoding="utf-8") as outfile:
            outfile.write(source)