Install packages into virtual envs as to satisfy app requirements.

        Exact version numbers could be given as in PIP: somedep==1.5

        :param list names:
555156
def op_install_package(self, names):
        
        venvs = self.get_venvs()
        for venv in venvs:
            for name in names:
                self.venv_install(name, self._get_venv_path(venv))
561658
def install(args):
    "  "

    # Deactivate virtualenv
    if 'VIRTUAL_ENV' in environ:
        LOGGER.warning('Virtualenv enabled: %s' % environ['VIRTUAL_ENV'])

    # Install from base modules
    if args.module:
        args.src = op.join(settings.MOD_DIR, args.module)
        assert op.exists(args.src), "Not found module: %s" % args.module

    # Fix project name
    args.PROJECT = args.PROJECT.replace('-', '_')

    args.home = op.abspath(args.path)

    # Create engine
    engine = Installer(args)
    args.deploy_dir = engine.target_dir

    # Check dir exists
    assert args.info or args.repeat or args.update or not op.exists(
        engine.target_dir), "Path %s exists. Stop deploy." % args.deploy_dir

    try:
        if args.repeat:
            site = Site(engine.target_dir)
            site.run_install()
            return site

        site = engine.clone_source()
        if not site:
            return True

        engine.build(args.update)
        site.run_install()
        return site

    except (CalledProcessError, AssertionError):
        LOGGER.error("Installation failed")
        LOGGER.error("Fix errors and repeat installation with (-r) or run 'makesite uninstall %s' for cancel." % args.deploy_dir)
        raise
369784
def _install_requirements(self):
        '''
        
        '''
        if not hasattr(self, '_pkg_venv'):
            err = 'Must call build_new_virtualenv before install_requirements'
            raise Exception(err)

        cmd = None
        if self._requirements:
            LOG.debug("Installing requirements found %s in config"
                      % self._requirements)
            cmd = [os.path.join(self._pkg_venv, self._venv_pip),
                   'install'] + self._requirements

        elif _isfile(self._requirements_file):
            # Pip install
            LOG.debug("Installing requirements from requirements.txt file")
            cmd = [os.path.join(self._pkg_venv, self._venv_pip),
                   "install", "-r",
                   self._requirements_file]

        if cmd is not None:
            prc = Popen(cmd, stdout=PIPE, stderr=PIPE)
            stdout, stderr = prc.communicate()
            LOG.debug("Pip stdout: %s" % stdout)
            LOG.debug("Pip stderr: %s" % stderr)

            if prc.returncode is not 0:
                raise Exception('pip returned unsuccessfully')
901387
def ensure_virtualenv(three=None, python=None, site_packages=False, pypi_mirror=None):
    """"""
    from .environments import PIPENV_USE_SYSTEM

    def abort():
        sys.exit(1)

    global USING_DEFAULT_PYTHON
    if not project.virtualenv_exists:
        try:
            # Ensure environment variables are set properly.
            ensure_environment()
            # Ensure Python is available.
            python = ensure_python(three=three, python=python)
            if python is not None and not isinstance(python, six.string_types):
                python = python.path.as_posix()
            # Create the virtualenv.
            # Abort if --system (or running in a virtualenv).
            if PIPENV_USE_SYSTEM:
                click.echo(
                    crayons.red(
                        "You are attempting to re–create a virtualenv that "
                        "Pipenv did not create. Aborting."
                    )
                )
                sys.exit(1)
            do_create_virtualenv(
                python=python, site_packages=site_packages, pypi_mirror=pypi_mirror
            )
        except KeyboardInterrupt:
            # If interrupted, cleanup the virtualenv.
            cleanup_virtualenv(bare=False)
            sys.exit(1)
    # If --three, --two, or --python were passed…
    elif (python) or (three is not None) or (site_packages is not False):
        USING_DEFAULT_PYTHON = False
        # Ensure python is installed before deleting existing virtual env
        python = ensure_python(three=three, python=python)
        if python is not None and not isinstance(python, six.string_types):
            python = python.path.as_posix()

        click.echo(crayons.red("Virtualenv already exists!"), err=True)
        # If VIRTUAL_ENV is set, there is a possibility that we are
        # going to remove the active virtualenv that the user cares
        # about, so confirm first.
        if "VIRTUAL_ENV" in os.environ:
            if not (
                PIPENV_YES or click.confirm("Remove existing virtualenv?", default=True)
            ):
                abort()
        click.echo(
            crayons.normal(fix_utf8("Removing existing virtualenv…"), bold=True), err=True
        )
        # Remove the virtualenv.
        cleanup_virtualenv(bare=True)
        # Call this function again.
        ensure_virtualenv(
            three=three,
            python=python,
            site_packages=site_packages,
            pypi_mirror=pypi_mirror,
        )
153917
def _resolve_deps(name, pkgs, **kwargs):
    '''
    
    '''
    missing_deps = []
    for pkg_file in pkgs:
        deb = apt.debfile.DebPackage(filename=pkg_file, cache=apt.Cache())
        if deb.check():
            missing_deps.extend(deb.missing_deps)

    if missing_deps:
        cmd = ['apt-get', '-q', '-y']
        cmd = cmd + ['-o', 'DPkg::Options::=--force-confold']
        cmd = cmd + ['-o', 'DPkg::Options::=--force-confdef']
        cmd.append('install')
        cmd.extend(missing_deps)

        ret = __salt__['cmd.retcode'](
            cmd,
            env=kwargs.get('env'),
            python_shell=False
        )

        if ret != 0:
            raise CommandExecutionError(
                'Error: unable to resolve dependencies for: {0}'.format(name)
            )
        else:
            try:
                cmd = ['apt-mark', 'auto'] + missing_deps
                __salt__['cmd.run'](
                    cmd,
                    env=kwargs.get('env'),
                    python_shell=False
                )
            except MinionError as exc:
                raise CommandExecutionError(exc)
    return
441319
def upgrade_available(pkg,
                      bin_env=None,
                      user=None,
                      cwd=None):
    '''
    
    '''
    return pkg in list_upgrades(bin_env=bin_env, user=user, cwd=cwd)
775112
def pipinstall(packages):
    

    if isinstance(packages, str):
        if hasattr(pip, 'main'):
            pip.main(['install', packages])
        else:
            pip._internal.main(['install', packages])
    elif isinstance(packages, list):
        for i in enumerate(packages):
            if hasattr(pip, 'main'):
                pip.main(['install', i[1]])
            else:
                pip._internal.main(['install', i[1]])
    else:
        raise TypeError("Nor a string or a list was provided.")
997510
def install_virtualenv(parser_args):
    
    python_version = '.'.join(str(v) for v in sys.version_info[:2])
    sys.stdout.write('Installing Python {0} virtualenv into {1} \n'.format(python_version, VE_ROOT))
    if sys.version_info < (3, 3):
        install_virtualenv_p2(VE_ROOT, python_version)
    else:
        install_virtualenv_p3(VE_ROOT, python_version)
1014247
def install(self, update=False):
        
        offline = self.offline or update
        self.create_env(offline)
        self.install_pkgs(offline)
        self.install_pip(offline)
        return tuple()
734448
def create_virtualenv(venv=VENV):
    
    print 'Creating venv...',
    run_command(['virtualenv', '-q', '--no-site-packages', VENV])
    print 'done.'
    print 'Installing pip in virtualenv...',
    if not run_command([WITH_VENV, 'easy_install', 'pip']).strip():
        die("Failed to install pip.")
    print 'done.'
    print 'Installing distribute in virtualenv...'
    pip_install('distribute>=0.6.24')
    print 'done.'
455738
def create_venv(local='y', test='y', general='y'):
    """"""
    if not path.isdir(project_paths.venv):
        execute('virtualenv', '--distribute', '--no-site-packages', project_paths.venv)
        project.execute_python('-m', 'easy_install', 'pip')
    if local.lower() == 'y' and project_paths.local_requirements:
        project.execute_pip('install', '--upgrade', '-r', project_paths.local_requirements)
    if test.lower() == 'y' and project_paths.test_requirements:
        project.execute_pip('install', '--upgrade', '-r', project_paths.test_requirements)
    if general.lower() == 'y' and project_paths.requirements_txt:
        project.execute_pip('install', '--upgrade', '-r', project_paths.requirements_txt)
1327883
def create_virtualenv(pkg, repo_dest, python):
    """"""
    workon_home = os.environ.get('WORKON_HOME')
    venv_cmd = find_executable('virtualenv')
    python_bin = find_executable(python)
    if not python_bin:
        raise EnvironmentError('%s is not installed or not '
                               'available on your $PATH' % python)
    if workon_home:
        # Can't use mkvirtualenv directly here because relies too much on
        # shell tricks. Simulate it:
        venv = os.path.join(workon_home, pkg)
    else:
        venv = os.path.join(repo_dest, '.virtualenv')
    if venv_cmd:
        if not verbose:
            log.info('Creating virtual environment in %r' % venv)
        args = ['--python', python_bin, venv]
        if not verbose:
            args.insert(0, '-q')
        subprocess.check_call([venv_cmd] + args)
    else:
        raise EnvironmentError('Could not locate the virtualenv. Install with '
                               'pip install virtualenv.')
    return venv
991207
def pkg_list(self):
        
        options = [
            "-l",
            "--list"
        ]
        flag = ["--index", "--installed", "--name"]
        name = INDEX = installed = False
        for arg in self.args[2:]:
            if flag[0] == arg:
                INDEX = True
            if flag[1] in arg:
                installed = True
            if flag[2] == arg:
                name = True
            if arg not in flag:
                usage("")
                raise SystemExit()
        if (len(self.args) > 1 and len(self.args) <= 5 and
                self.args[0] in options):
            if self.args[1] in self.meta.repositories:
                PackageManager(binary=None).package_list(self.args[1],
                                                         name,
                                                         INDEX,
                                                         installed)
            else:
                usage(self.args[1])
        else:
            usage("")
745729
def build(args) -> None:
    """"""
    venv_exe = shutil.which('virtualenv')
    pyexe = shutil.which(args.pyexe)
    if not venv_exe:
        logging.warn("virtualenv wasn't found in path, it's recommended to install virtualenv to manage python environments")
    if not pyexe:
        logging.warn("Python executable %s not found in path", args.pyexe)
    if args.cmake_options:
        cmake = CMake(args.cmake_options)
    else:
        cmake = CMake()
    cmake()
    create_virtualenv(venv_exe, pyexe, args.venv)
1048939
def install_program(self, extra_args):
        """"""
        pip = Command(path.join(self.env, 'bin', 'pip'))
        args = ['install', self.raw_name,
                '--install-option', '--install-scripts={}'
                .format(self.env_bin)] + list(extra_args)
        print_pretty("<BOLD>pip {}<END>\n".format(' '.join(args)))
        pip(args, _out=sys.stdout, _err=sys.stderr)
        print('')
670591
def install(self, pip_args=None):
        """"""
        if path.isdir(self.env):
            print_pretty("<FG_RED>This seems to already be installed.<END>")
        else:
            print_pretty("<FG_BLUE>Creating environment {}...<END>\n".format(self.env))
            self.create_env()
            self.install_program(pip_args)
            self.create_links()
639081
def common_install_python_env(self):
        
        sudo('apt-get install python3 python3-pip -y')
        sudo('pip3 install virtualenv')

        run('virtualenv {0}'.format(self.python_env_dir))

        print(green(' * Installed Python3 virtual environment in the system.'))
        print(green(' * Done'))
        print()