def load_consumer_conanfile(self, conanfile_path, info_folder, deps_info_required=False, test=False): """loads a conanfile for local flow: source, imports, package, build """ try: graph_info = GraphInfo.load(info_folder) graph_lock_file = GraphLockFile.load( info_folder, self._cache.config.revisions_enabled) graph_lock = graph_lock_file.graph_lock self._output.info( "Using lockfile: '{}/conan.lock'".format(info_folder)) profile_host = graph_lock_file.profile_host self._output.info("Using cached profile from lockfile") except IOError: # Only if file is missing graph_lock = None # This is very dirty, should be removed for Conan 2.0 (source() method only) profile_host = self._cache.default_profile profile_host.process_settings(self._cache) name, version, user, channel = None, None, None, None else: name, version, user, channel, _ = graph_info.root profile_host.process_settings(self._cache, preprocess=False) # This is the hack of recovering the options from the graph_info profile_host.options.update(graph_info.options) if conanfile_path.endswith(".py"): lock_python_requires = None if graph_lock and not test: # Only lock python requires if it is not test_package node_id = graph_lock.get_node(graph_info.root) lock_python_requires = graph_lock.python_requires(node_id) conanfile = self._loader.load_consumer( conanfile_path, profile_host=profile_host, name=name, version=version, user=user, channel=channel, lock_python_requires=lock_python_requires) if test: conanfile.display_name = "%s (test package)" % str(test) conanfile.output.scope = conanfile.display_name run_configure_method(conanfile, down_options=None, down_ref=None, ref=None) else: conanfile = self._loader.load_conanfile_txt( conanfile_path, profile_host) load_deps_info(info_folder, conanfile, required=deps_info_required) return conanfile
def _config_node(node, down_ref, down_options): """ update settings and option in the current ConanFile, computing actual requirement values, cause they can be overridden by downstream requires param settings: dict of settings values => {"os": "windows"} """ conanfile, ref = node.conanfile, node.ref try: run_configure_method(conanfile, down_options, down_ref, ref) with get_env_context_manager(conanfile, without_python=True): # Update requirements (overwrites), computing new upstream if hasattr(conanfile, "requirements"): # If re-evaluating the recipe, in a diamond graph, with different options, # it could happen that one execution path of requirements() defines a package # and another one a different package raising Duplicate dependency error # Or the two consecutive calls, adding 2 different dependencies for the 2 paths # So it is necessary to save the "requires" state and restore it before a second # execution of requirements(). It is a shallow copy, if first iteration is # RequireResolve'd or overridden, the inner requirements are modified if not hasattr(conanfile, "_conan_original_requires"): conanfile._conan_original_requires = conanfile.requires.copy( ) else: conanfile.requires = conanfile._conan_original_requires.copy( ) with conanfile_exception_formatter(str(conanfile), "requirements"): conanfile.requirements() new_options = conanfile.options.deps_package_values except ConanExceptionInUserConanfileMethod: raise except ConanException as e: raise ConanException("%s: %s" % (ref or "Conanfile", str(e))) except Exception as e: raise ConanException(e) return new_options