Example #1
0
    def _load_root_consumer(self, path, graph_lock, profile, ref):
        """ load a CONSUMER node from a user space conanfile.py or conanfile.txt
        install|info|create|graph <path>
        :path full path to a conanfile
        :graph_lock: might be None, information of lockfiles
        :profile: data to inject to the consumer node: settings, options
        :ref: previous reference of a previous command. Can be used for finding itself in
              the lockfile, or to initialize
        """
        if path.endswith(".py"):
            lock_python_requires = None
            if graph_lock:
                if ref.name is None:
                    # If the graph_info information is not there, better get what we can from
                    # the conanfile
                    # Using load_named() to run set_name() set_version() and get them
                    # so it can be found by name in the lockfile
                    conanfile = self._loader.load_named(
                        path, None, None, None, None)
                    ref = ConanFileReference(ref.name or conanfile.name,
                                             ref.version or conanfile.version,
                                             ref.user,
                                             ref.channel,
                                             validate=False)
                node_id = graph_lock.get_consumer(ref)
                lock_python_requires = graph_lock.python_requires(node_id)

            conanfile = self._loader.load_consumer(
                path,
                profile,
                name=ref.name,
                version=ref.version,
                user=ref.user,
                channel=ref.channel,
                lock_python_requires=lock_python_requires)

            ref = ConanFileReference(conanfile.name,
                                     conanfile.version,
                                     ref.user,
                                     ref.channel,
                                     validate=False)
            root_node = Node(ref,
                             conanfile,
                             context=CONTEXT_HOST,
                             recipe=RECIPE_CONSUMER,
                             path=path)
        else:
            conanfile = self._loader.load_conanfile_txt(path, profile, ref=ref)
            root_node = Node(None,
                             conanfile,
                             context=CONTEXT_HOST,
                             recipe=RECIPE_CONSUMER,
                             path=path)

        if graph_lock:  # Find the Node ID in the lock of current root
            node_id = graph_lock.get_consumer(root_node.ref)
            root_node.id = node_id

        return root_node
Example #2
0
    def _create_new_node(self, current_node, dep_graph, requirement,
                         check_updates, update, remotes, profile_host,
                         profile_build, graph_lock, context_switch,
                         populate_settings_target):
        # If there is a context_switch, it is because it is a BR-build
        if context_switch:
            profile = profile_build
            context = CONTEXT_BUILD
        else:
            profile = profile_host if current_node.context == CONTEXT_HOST else profile_build
            context = current_node.context

        result = self._resolve_recipe(current_node, dep_graph, requirement,
                                      check_updates, update, remotes, profile,
                                      graph_lock)
        new_ref, dep_conanfile, recipe_status, remote, locked_id = result

        # Assign the profiles depending on the context
        if profile_build:  # Keep existing behavior (and conanfile members) if no profile_build
            dep_conanfile.settings_build = profile_build.processed_settings.copy(
            )
            if not context_switch:
                if populate_settings_target:
                    dep_conanfile.settings_target = current_node.conanfile.settings_target
                else:
                    dep_conanfile.settings_target = None
            else:
                if current_node.context == CONTEXT_HOST:
                    dep_conanfile.settings_target = profile_host.processed_settings.copy(
                    )
                else:
                    dep_conanfile.settings_target = profile_build.processed_settings.copy(
                    )

        logger.debug("GRAPH: new_node: %s" % str(new_ref))
        new_node = Node(new_ref, dep_conanfile, context=context)
        new_node.revision_pinned = requirement.ref.revision is not None
        new_node.recipe = recipe_status
        new_node.remote = remote
        # Ancestors are a copy of the parent, plus the parent itself
        new_node.ancestors.assign(current_node.ancestors)
        new_node.ancestors.add(current_node)

        if locked_id is not None:
            new_node.id = locked_id

        dep_graph.add_node(new_node)
        dep_graph.add_edge(current_node, new_node, requirement)
        return new_node
Example #3
0
    def _create_new_node(self, current_node, dep_graph, requirement,
                         check_updates, update, remotes, profile, graph_lock):

        result = self._resolve_recipe(current_node, dep_graph, requirement,
                                      check_updates, update, remotes, profile,
                                      graph_lock)
        new_ref, dep_conanfile, recipe_status, remote, locked_id = result

        logger.debug("GRAPH: new_node: %s" % str(new_ref))
        new_node = Node(new_ref, dep_conanfile)
        new_node.revision_pinned = requirement.ref.revision is not None
        new_node.recipe = recipe_status
        new_node.remote = remote
        # Ancestors are a copy of the parent, plus the parent itself
        new_node.ancestors = current_node.ancestors.copy()
        new_node.ancestors.add(current_node.name)

        if locked_id is not None:
            new_node.id = locked_id

        dep_graph.add_node(new_node)
        dep_graph.add_edge(current_node, new_node, requirement)
        return new_node
Example #4
0
    def _create_new_node(self,
                         current_node,
                         dep_graph,
                         requirement,
                         name_req,
                         check_updates,
                         update,
                         remotes,
                         processed_profile,
                         graph_lock,
                         alias_ref=None):
        """ creates and adds a new node to the dependency graph
        """

        try:
            result = self._proxy.get_recipe(requirement.ref, check_updates,
                                            update, remotes, self._recorder)
        except ConanException as e:
            if current_node.ref:
                self._output.error(
                    "Failed requirement '%s' from '%s'" %
                    (requirement.ref, current_node.conanfile.display_name))
            raise e
        conanfile_path, recipe_status, remote, new_ref = result

        locked_id = requirement.locked_id
        lock_python_requires = graph_lock.python_requires(
            locked_id) if locked_id else None
        dep_conanfile = self._loader.load_conanfile(
            conanfile_path,
            processed_profile,
            ref=requirement.ref,
            lock_python_requires=lock_python_requires)
        if recipe_status == RECIPE_EDITABLE:
            dep_conanfile.in_local_cache = False
            dep_conanfile.develop = True

        if getattr(dep_conanfile, "alias", None):
            alias_ref = alias_ref or new_ref.copy_clear_rev()
            requirement.ref = ConanFileReference.loads(dep_conanfile.alias)
            dep_graph.aliased[alias_ref] = requirement.ref
            return self._create_new_node(current_node,
                                         dep_graph,
                                         requirement,
                                         name_req,
                                         check_updates,
                                         update,
                                         remotes,
                                         processed_profile,
                                         graph_lock,
                                         alias_ref=alias_ref)

        logger.debug("GRAPH: new_node: %s" % str(new_ref))
        new_node = Node(new_ref, dep_conanfile)
        new_node.revision_pinned = requirement.ref.revision is not None
        new_node.recipe = recipe_status
        new_node.remote = remote
        # Ancestors are a copy of the parent, plus the parent itself
        new_node.ancestors = current_node.ancestors.copy()
        new_node.ancestors.add(current_node.name)

        if locked_id:
            new_node.id = locked_id

        # build-requires and private affect transitively. If "node" is already
        # a build_require or a private one, its requirements will inherit that property
        # Or if the require specify that property, then it will get it too
        new_node.build_require = current_node.build_require or requirement.build_require
        new_node.private = current_node.private or requirement.private

        dep_graph.add_node(new_node)
        dep_graph.add_edge(current_node, new_node, requirement)
        return new_node