Install all packages in dependency list via pip.
775256
def install_dependencies(dependencies, verbose=False):
    """"""
    if not dependencies:
        return

    stdout = stderr = None if verbose else subprocess.DEVNULL
    with tempfile.TemporaryDirectory() as req_dir:
        req_file = Path(req_dir) / "requirements.txt"

        with open(req_file, "w") as f:
            for dependency in dependencies:
                f.write(f"{dependency}\n")

        pip = ["python3", "-m", "pip", "install", "-r", req_file]
        # Unless we are in a virtualenv, we need --user
        if sys.base_prefix == sys.prefix and not hasattr(sys, "real_prefix"):
            pip.append("--user")

        try:
            subprocess.check_call(pip, stdout=stdout, stderr=stderr)
        except subprocess.CalledProcessError:
            raise Error(_("failed to install dependencies"))

        # Reload sys.path, to find recently installed packages
        importlib.reload(site)
1037866
def load_pip_addons(_globals):
    '''
    '''
    for package_name in known_pip_addons:
        _, username = package_username(package_name)
        try:
            load_addon(username, package_name.replace('-', '_'), _globals)
        except ImportError:
            pass
1275791
def install():
    
    import os, shutil
    
    _ROOT = os.getcwd()
    _PACKAGE_NAME = os.path.basename(_ROOT)
    
    print("Installing [%s] to all python version..." % _PACKAGE_NAME)
    # find all Python release installed on this windows computer
    installed_python_version = list()
    for root, folder_list, _ in os.walk(r"C:\\"):
        for folder in folder_list:
            if folder.startswith("Python"):
                if os.path.exists(os.path.join(root, folder, "pythonw.exe")):
                    installed_python_version.append(folder)
        break
    print("\tYou have installed: {0}".format(", ".join(installed_python_version)))
    
    # remove __pycache__ folder and *.pyc file
    print("\tRemoving *.pyc file ...")
    pyc_folder_list = list()
    for root, folder_list, _ in os.walk(_ROOT):
        if os.path.basename(root) == "__pycache__":
            pyc_folder_list.append(root)
    
    for folder in pyc_folder_list:
        shutil.rmtree(folder)
    print("\t\tall *.pyc file has been removed.")
    
    # install this package to all python version
    for py_root in installed_python_version:
        dst = os.path.join(r"C:\\", py_root, r"Lib\site-packages", _PACKAGE_NAME)
        try:
            shutil.rmtree(dst)
        except:
            pass
        print("\tRemoved %s." % dst)
        shutil.copytree(_ROOT, dst)
        print("\tInstalled %s." % dst)
    
    print("Complete!")
1167235
def python_dependencies(context: Context, extras=None):
    
    with mock.patch('setuptools.setup'):
        from setup import install_requires, extras_require

        requirements = install_requires.copy()
        if extras:
            requirements.extend(extras_require[extras])
    return context.pip_command('install', *requirements)
1261536
def needs(self):
        """"""
        result = []
        for dep in self.dependencies:
            module = dep.split(".")[0].lower()
            if module not in result:
                result.append(module)

        return result
637922
def pull_dependencies(collector, image, **kwargs):
    """"""
    for dep in image.commands.dependent_images:
        kwargs["image"] = dep
        pull_arbitrary(collector, **kwargs)
442468
def _pip_list(self, stdout, stderr, prefix=None):
        """"""
        result = stdout  # A dict
        linked = self.linked(prefix)

        pip_only = []

        linked_names = [self.split_canonical_name(l)[0] for l in linked]

        for pkg in result:
            name = self.split_canonical_name(pkg)[0]
            if name not in linked_names:
                pip_only.append(pkg)
            # FIXME: NEED A MORE ROBUST WAY!
#            if '<pip>' in line and '#' not in line:
#                temp = line.split()[:-1] + ['pip']
#                temp = '-'.join(temp)
#                if '-(' in temp:
#                    start = temp.find('-(')
#                    end = temp.find(')')
#                    substring = temp[start:end+1]
#                    temp = temp.replace(substring, '')
#                result.append(temp)

        return pip_only
1004069
def _build_dependencies(self):
        
        for module in list(self.values()):
            module.set_all_dependencies(find_dependencies([module.name], self))
26348
def install(self, name=None, prefix=None, pkgs=None, dep=True,
                channels=None, token=None):
        
        logger.debug(str((prefix, pkgs, channels)))

        # TODO: Fix temporal hack
        if not pkgs or not isinstance(pkgs, (list, tuple, str)):
            raise TypeError('must specify a list of one or more packages to '
                            'install into existing environment')

        cmd_list = ['install', '--yes', '--json', '--force-pscheck']
        if name:
            cmd_list.extend(['--name', name])
        elif prefix:
            cmd_list.extend(['--prefix', prefix])
        else:
            # Just install into the current environment, whatever that is
            pass

        # TODO: Check if correct
        if channels:
            cmd_list.extend(['--override-channels'])

            for channel in channels:
                cmd_list.extend(['--channel'])
                channel = self.parse_token_channel(channel, token)
                cmd_list.extend([channel])

        # TODO: Fix temporal hack
        if isinstance(pkgs, (list, tuple)):
            cmd_list.extend(pkgs)
        elif isinstance(pkgs, str):
            cmd_list.extend(['--file', pkgs])

        if not dep:
            cmd_list.extend(['--no-deps'])

        return self._call_and_parse(cmd_list)
676337
def install_requirements(self, requires):
        
        # Temporarily install dependencies required by setup.py before trying to import them.
        sys.path[0:0] = ['setup-requires']
        pkg_resources.working_set.add_entry('setup-requires')

        to_install = list(self.missing_requirements(requires))
        if to_install:
            cmd = [sys.executable, "-m", "pip", "install",
                "-t", "setup-requires"] + to_install
            subprocess.call(cmd)
821437
def deps(ctx):
    ''''''
    header(deps.__doc__)
    with ctx.cd(ROOT):
        ctx.run('pip install -r requirements/develop.pip -r requirements/doc.pip', pty=True)
950819
def all_packages(self):
        """"""
        p = dict(self.parsed_pipfile.get("dev-packages", {}))
        p.update(self.parsed_pipfile.get("packages", {}))
        return p
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
269760
def install(cmd, packages):
    
    check_cmd(cmd)

    all_pkgs_str = " ".join(all_pkgs)
    print("INSTALLING: " + cmd + " install " + all_pkgs_str)
    subprocess.check_call([cmd, 'install'] + packages)
892825
def _installed_packages(self) -> Generator[str, None, None]:
        """"""
        with (self._build_dir / 'package.json').open('r') as f:
            packages = json.load(f)
        yield from packages['dependencies'].keys()
447724
def dependencies(source):
    """"""
    loader = ClassLoader(source, max_cache=-1)
    all_dependencies = set()
    for klass in loader.classes:
        new_dependencies = loader.dependencies(klass) - all_dependencies
        all_dependencies.update(new_dependencies)
        for new_dep in new_dependencies:
            click.echo(new_dep)
645315
def install_dependencies(feature=None):
    
    import subprocess

    echo(green('\nInstall dependencies:'))
    echo(green('-' * 40))

    req_path = os.path.realpath(os.path.dirname(__file__) + '/../_requirements')

    # list all features if no feature name
    if not feature:
        echo(yellow('Please specify a feature to install. \n'))
        for index, item in enumerate(os.listdir(req_path)):
            item = item.replace('.txt', '')
            echo(green('{}. {}'.format(index + 1, item)))

        echo()
        return

    # install if got feature name
    feature_file = feature.lower() + '.txt'
    feature_reqs = os.path.join(req_path, feature_file)

    # check existence
    if not os.path.isfile(feature_reqs):
        msg = 'Unable to locate feature requirements file [{}]'
        echo(red(msg.format(feature_file)) + '\n')
        return

    msg = 'Now installing dependencies for "{}" feature...'.format(feature)
    echo(yellow(msg))

    subprocess.check_call([
        sys.executable, '-m', 'pip', 'install', '-r', feature_reqs]
    )

    # update requirements file with dependencies
    reqs = os.path.join(os.getcwd(), 'requirements.txt')
    if os.path.exists(reqs):
        with open(reqs) as file:
            existing = [x.strip().split('==')[0] for x in file.readlines() if x]

        lines = ['\n']
        with open(feature_reqs) as file:
            incoming = file.readlines()

            for line in incoming:
                if not(len(line)) or line.startswith('#'):
                    lines.append(line)
                    continue

                package = line.strip().split('==')[0]
                if package not in existing:
                    lines.append(line)

        with open(reqs, 'a') as file:
            file.writelines(lines)

    echo(green('DONE\n'))