Esempio n. 1
0
    def add_plugin(self, plugin_def):
        if not self._entry_stack:
            dep_dict = self._entries
        else:
            dep_dict = self._entry_stack[0][2]

        if plugin_def not in dep_dict:
            entry = [plugin_def, None, odict()]
            dep_dict[plugin_def] = entry

            self._mods += 1
Esempio n. 2
0
    def __init__(self, logger):
        self.logger = logger

        self._tasks = odict()
        self._task_dependencies = odict()
        self._dependencies_pending_tasks = {}

        self._actions = odict()
        self._execute_before = odict()
        self._execute_after = odict()

        self._initializers = []
        self._finalizers = []

        self._dependencies_resolved = False
        self._actions_executed = []
        self._tasks_executed = []
        self._current_task = None
        self._current_execution_plan = None

        self._exclude_optional_tasks = []
        self._exclude_tasks = []
        self._exclude_all_optional = False
Esempio n. 3
0
    def traverse(self, _entries=None):
        if _entries is None:
            _entries = self._entries

        for k, entry in odict(_entries).items():
            sub_entries = entry[2]
            if sub_entries:
                for child in self.traverse(_entries=sub_entries):
                    yield child
            self._entry_stack.appendleft(entry)
            try:
                yield entry
            finally:
                self._entry_stack.popleft()
Esempio n. 4
0
def pip_install_batches(packages,
                        python_env,
                        index_url=None,
                        extra_index_url=None,
                        upgrade=False,
                        insecure_installs=None,
                        force_reinstall=False,
                        target_dir=None,
                        verbose=False,
                        trusted_host=None,
                        constraint_file=None,
                        eager_upgrade=False,
                        ignore_installed=False,
                        prefix_dir=None,
                        logger=None,
                        outfile_name=None,
                        error_file_name=None,
                        env=None,
                        cwd=None):
    """install_batches is a list of dependencies in a form of a tuple [package_spec, {build options}}]
    The batches will be assembled in a way that ensures that installation of packages with identical options occurs
    together to cut down on the number of round trips.
    """
    pip_command_line = []
    pip_command_line.extend(python_env.executable + PIP_MODULE_STANZA)
    pip_command_line.append("install")
    pip_command_line.extend(
        build_pip_install_options(
            index_url=index_url,
            extra_index_url=extra_index_url,
            upgrade=upgrade,
            insecure_installs=insecure_installs,
            force_reinstall=force_reinstall,
            target_dir=target_dir,
            verbose=verbose,
            trusted_host=trusted_host,
            constraint_file=constraint_file,
            eager_upgrade=eager_upgrade,
            ignore_installed=ignore_installed,
            prefix_dir=prefix_dir,
        ))
    env_environ = python_env.environ
    if env is not None:
        env_environ.update(env)

    batches = odict()
    for package in packages:
        pkg_spec, opts = package
        opts = tuple(build_pip_install_options(**opts))

        if opts in batches:
            batch_pkgs = batches[opts]
        else:
            batch_pkgs = []
            batches[opts] = batch_pkgs
        batch_pkgs.append(pkg_spec)

    results = []
    for opts, pkgs in batches.items():
        cmd_line = list(pip_command_line)
        cmd_line.extend(opts)
        for pkg in pkgs:
            cmd_line.extend(pkg)

        results.append(
            python_env.execute_command(cmd_line,
                                       outfile_name=outfile_name,
                                       error_file_name=error_file_name,
                                       env=env_environ,
                                       cwd=cwd,
                                       shell=False,
                                       no_path_search=True))

    return results
Esempio n. 5
0
 def __init__(self):
     """A data structure that allows tracking module cross-references and retrieving them in the same order later"""
     self._entries = odict(
     )  # PluginDef -> [PluginDef, Plugin module, odict of children]
     self._entry_stack = deque()
     self._mods = 0