def search(self, pattern_or_reference=None, remote=None, ignorecase=True, packages_query=None): """ Print the single information saved in conan.vars about all the packages or the packages which match with a pattern Attributes: pattern = string to match packages remote = search on another origin to get packages info packages_pattern = String query with binary packages properties: "arch=x86 AND os=Windows" """ printer = Printer(self._user_io.out) if remote: remote_proxy = ConanProxy(self._client_cache, self._user_io, self._remote_manager, remote) adapter = remote_proxy else: adapter = self._search_manager if isinstance(pattern_or_reference, ConanFileReference): packages_props = adapter.search_packages(pattern_or_reference, packages_query) ordered_packages = OrderedDict(sorted(packages_props.items())) printer.print_search_packages(ordered_packages, pattern_or_reference, packages_query) else: references = adapter.search(pattern_or_reference, ignorecase) printer.print_search_recipes(references, pattern_or_reference)
def print_search_packages(self, ordered_packages, pattern, recipe_hash, packages_query, table): if table: from conans.client.graph.grapher import html_binary_graph html_binary_graph(pattern, ordered_packages, recipe_hash, table) else: printer = Printer(self.user_io.out) printer.print_search_packages(ordered_packages, pattern, recipe_hash, packages_query)
def print_search_packages(self, search_info, reference, packages_query, table, outdated=False): if table: html_binary_graph(search_info, reference, table) else: printer = Printer(self.user_io.out) printer.print_search_packages(search_info, reference, packages_query, outdated=outdated)
def print_search_packages(self, search_info, reference, packages_query, table, raw, template, outdated=False): if table: html_binary_graph(search_info, reference, table, template) else: printer = Printer(self._output) printer.print_search_packages(search_info, reference, packages_query, raw, outdated=outdated)
def print_search_packages(self, search_info, reference, packages_query, table): if table: from conans.client.graph.grapher import html_binary_graph html_binary_graph(search_info, reference, table) else: printer = Printer(self.user_io.out) printer.print_search_packages(search_info, reference, packages_query)
def info(self, reference, current_path, remote=None, options=None, settings=None, info=None, filename=None, update=False, check_updates=False, scopes=None, build_order=None, build_mode=None, package_settings=None): """ Fetch and build all dependencies for the given reference @param reference: ConanFileReference or path to user space conanfile @param current_path: where the output files will be saved @param remote: install only from that remote @param options: list of tuples: [(optionname, optionvalue), (optionname, optionvalue)...] @param settings: list of tuples: [(settingname, settingvalue), (settingname, value)...] @param package_settings: dict name=> settings: {"zlib": [(settingname, settingvalue), ...]} """ def read_dates(deps_graph): ret = {} for ref, _ in sorted(deps_graph.nodes): if ref: manifest = self._client_cache.load_manifest(ref) ret[ref] = manifest.time_str return ret objects = self._get_graph(reference, current_path, remote, options, settings, filename, update, check_updates, None, scopes, package_settings, None, None) (builder, deps_graph, project_reference, registry, _, remote_proxy, _) = objects if build_order: result = deps_graph.build_order(build_order) self._user_io.out.info(", ".join(str(s) for s in result)) return if build_mode is not False: # sim_install is a policy or list of names (same as install build param) installer = ConanInstaller(self._client_cache, self._user_io, remote_proxy) nodes = installer.nodes_to_build(deps_graph, build_mode) counter = Counter(ref.conan.name for ref, _ in nodes) self._user_io.out.info(", ".join( (str(ref) if counter[ref.conan.name] > 1 else str(ref.conan)) for ref, _ in nodes)) return if check_updates: graph_updates_info = builder.get_graph_updates_info(deps_graph) else: graph_updates_info = {} Printer(self._user_io.out).print_info(deps_graph, project_reference, info, registry, graph_updates_info, remote, read_dates(deps_graph))
def info(self, reference, current_path, remote=None, options=None, settings=None, info=None, filename=None, update=False, check_updates=False, integrity=False, scopes=None, build_order=None): """ Fetch and build all dependencies for the given reference @param reference: ConanFileReference or path to user space conanfile @param current_path: where the output files will be saved @param remote: install only from that remote @param options: list of tuples: [(optionname, optionvalue), (optionname, optionvalue)...] @param settings: list of tuples: [(settingname, settingvalue), (settingname, value)...] """ objects = self._get_graph(reference, current_path, remote, options, settings, filename, update, check_updates, integrity, scopes) (builder, deps_graph, project_reference, registry, _, _, _) = objects if build_order: result = deps_graph.build_order(build_order) self._user_io.out.info(", ".join(str(s) for s in result)) return if check_updates: graph_updates_info = builder.get_graph_updates_info(deps_graph) else: graph_updates_info = {} Printer(self._user_io.out).print_info(deps_graph, project_reference, info, registry, graph_updates_info, remote)
def _install(self, conanfile, reference, build_requires, installer, profile_build_requires, discard=False): if isinstance(reference, ConanFileReference): build_requires.pop(reference.name, None) if not build_requires: return if discard: profile_build_requires = copy.copy(profile_build_requires) profile_build_requires.pop("*", None) profile_build_requires.pop("&!", None) reference = str(reference) self._output.info("Installing build requirements of: %s" % (reference or "PROJECT")) self._output.info("Build requires: [%s]" % ", ".join(str(r) for r in build_requires.values())) # clear root package options, they won't match the build-require conanfile.build_requires_options.clear_unscoped_options() virtual = self._loader.load_virtual(build_requires.values(), scope_options=False, build_requires_options=conanfile.build_requires_options) # compute and print the graph of transitive build-requires deps_graph = self._graph_builder.load(virtual) Printer(self._output).print_graph(deps_graph, self._registry) # install them, recursively installer.install(deps_graph, profile_build_requires) _apply_build_requires(deps_graph, conanfile, build_requires) self._output.info("Installed build requirements of: %s" % (reference or "PROJECT"))
def _install(self, references): self._output.info("Installing build requires: [%s]" % ", ".join(str(r) for r in references)) conanfile = self._loader.load_virtual( references, None, scope_options=False) # No need current path # FIXME: Forced update=True, build_mode, Where to define it? update = False local_search = None if update else self._search_manager resolver = RequireResolver(self._output, local_search, self._remote_proxy) graph_builder = DepsGraphBuilder(self._remote_proxy, self._output, self._loader, resolver) deps_graph = graph_builder.load(conanfile) registry = RemoteRegistry(self._client_cache.registry, self._output) Printer(self._output).print_graph(deps_graph, registry) # Make sure we recursively do not propagate the "*" pattern build_requires = copy.copy(self) build_requires._build_requires = self._build_requires.copy() build_requires._build_requires.pop("*", None) build_requires._build_requires.pop("&!", None) installer = ConanInstaller(self._client_cache, self._output, self._remote_proxy, build_requires) installer.install(deps_graph, self._build_modes, self._current_path) self._output.info("Installed build requires: [%s]" % ", ".join(str(r) for r in references)) return deps_graph
def info(self, deps_graph, graph_updates_info, only, remote, package_filter, show_paths, project_reference): registry = RemoteRegistry(self.client_cache.registry, self.user_io.out) Printer(self.user_io.out).print_info(deps_graph, project_reference, only, registry, graph_updates_info=graph_updates_info, remote=remote, node_times=self._read_dates(deps_graph), path_resolver=self.client_cache, package_filter=package_filter, show_paths=show_paths)
def info(self, deps_graph, only, package_filter, show_paths): data = self._grab_info_data(deps_graph, grab_paths=show_paths) Printer(self._output).print_info( data, only, package_filter=package_filter, show_paths=show_paths, show_revisions=self._cache.config.revisions_enabled)
def search(self, pattern=None, remote=None, ignorecase=True, verbose=False, extra_verbose=False, package_pattern=None): """ Print the single information saved in conan.vars about all the packages or the packages which match with a pattern Attributes: pattern = string to match packages remote = search on another origin to get packages info """ if remote: remote_proxy = ConanProxy(self._paths, self._user_io, self._remote_manager, remote) info = remote_proxy.search(pattern, ignorecase) else: info = self.file_manager.search(pattern, ignorecase) filtered_info = info # Filter packages if package_pattern if package_pattern: try: # Prepare ER to be more user natural if ".*" not in package_pattern: package_pattern = package_pattern.replace("*", ".*") # Compile expression package_pattern = re.compile(package_pattern, re.IGNORECASE) filtered_info = SearchInfo() for conan_ref, packages in sorted(info.items()): filtered_packages = { pid: data for pid, data in packages.items() if package_pattern.match(pid) } if filtered_packages: filtered_info[conan_ref] = filtered_packages except Exception: # Invalid pattern raise ConanException("Invalid package pattern") printer = Printer(self._user_io.out) printer.print_search(filtered_info, pattern, verbose, extra_verbose)
def info(self, deps_graph, only, package_filter, show_paths): registry = self.client_cache.registry Printer(self.user_io.out).print_info( deps_graph, only, registry, node_times=self._read_dates(deps_graph), path_resolver=self.client_cache, package_filter=package_filter, show_paths=show_paths)
def search(self, pattern_or_reference=None, remote=None, ignorecase=True, packages_query=None): """ Print the single information saved in conan.vars about all the packages or the packages which match with a pattern Attributes: pattern = string to match packages remote = search on another origin to get packages info packages_pattern = String query with binary packages properties: "arch=x86 AND os=Windows" """ printer = Printer(self._user_io.out) if remote: remote_proxy = ConanProxy(self._client_cache, self._user_io, self._remote_manager, remote) adapter = remote_proxy else: adapter = self._search_manager if isinstance(pattern_or_reference, ConanFileReference): packages_props = adapter.search_packages(pattern_or_reference, packages_query) ordered_packages = OrderedDict(sorted(packages_props.items())) try: recipe_hash = self._client_cache.load_manifest(pattern_or_reference).summary_hash except IOError: # It could not exist in local recipe_hash = None printer.print_search_packages(ordered_packages, pattern_or_reference, recipe_hash, packages_query) else: references = adapter.search(pattern_or_reference, ignorecase) printer.print_search_recipes(references, pattern_or_reference)
def install(self, reference, current_path, remote=None, options=None, settings=None, build_mode=False, filename=None, update=False, check_updates=False, integrity=False, scopes=None, generators=None): """ Fetch and build all dependencies for the given reference @param reference: ConanFileReference or path to user space conanfile @param current_path: where the output files will be saved @param remote: install only from that remote @param options: list of tuples: [(optionname, optionvalue), (optionname, optionvalue)...] @param settings: list of tuples: [(settingname, settingvalue), (settingname, value)...] """ generators = generators or [] objects = self._get_graph(reference, current_path, remote, options, settings, filename, update, check_updates, integrity, scopes) (_, deps_graph, _, registry, conanfile, remote_proxy, loader) = objects Printer(self._user_io.out).print_graph(deps_graph, registry) # Warn if os doesn't match try: if detected_os() != loader._settings.os: message = '''You are building this package with settings.os='%s' on a '%s' system. If this is your intention, you can ignore this message. If not: - Check the passed settings (-s) - Check your global settings in ~/.conan/conan.conf - Remove conaninfo.txt to avoid bad cached settings ''' % (loader._settings.os, detected_os()) self._user_io.out.warn(message) except ConanException: # Setting os doesn't exist pass installer = ConanInstaller(self._paths, self._user_io, remote_proxy) installer.install(deps_graph, build_mode) scope_prefix = "PROJECT" if not isinstance(reference, ConanFileReference) else str(reference) output = ScopedOutput(scope_prefix, self._user_io.out) # Write generators tmp = list(conanfile.generators) # Add the command line specified generators tmp.extend(generators) conanfile.generators = tmp write_generators(conanfile, current_path, output) if not isinstance(reference, ConanFileReference): content = normalize(conanfile.info.dumps()) save(os.path.join(current_path, CONANINFO), content) output.info("Generated %s" % CONANINFO) local_installer = FileImporter(deps_graph, self._paths, current_path) conanfile.copy = local_installer conanfile.imports() copied_files = local_installer.execute() import_output = ScopedOutput("%s imports()" % output.scope, output) report_copied_files(copied_files, import_output)
def search(self, pattern=None, remote=None, ignorecase=True, verbose=False, extra_verbose=False, package_pattern=None): """ Print the single information saved in conan.vars about all the packages or the packages which match with a pattern Attributes: pattern = string to match packages remote = search on another origin to get packages info """ if remote: remote_proxy = ConanProxy(self._paths, self._user_io, self._remote_manager, remote) info = remote_proxy.search(pattern, ignorecase) else: info = self.file_manager.search(pattern, ignorecase) filtered_info = info # Filter packages if package_pattern if package_pattern: try: # Prepare ER to be more user natural if ".*" not in package_pattern: package_pattern = package_pattern.replace("*", ".*") # Compile expression package_pattern = re.compile(package_pattern, re.IGNORECASE) filtered_info = SearchInfo() for conan_ref, packages in sorted(info.items()): filtered_packages = {pid: data for pid, data in packages.items() if package_pattern.match(pid)} if filtered_packages: filtered_info[conan_ref] = filtered_packages except Exception: # Invalid pattern raise ConanException("Invalid package pattern") printer = Printer(self._user_io.out) printer.print_search(filtered_info, pattern, verbose, extra_verbose)
def profile(self, subcommand, profile=None, cwd=None): cwd = prepare_cwd(cwd) if subcommand == "list": folder = self._client_cache.profiles_path if os.path.exists(folder): profiles = [ name for name in os.listdir(folder) if not os.path.isdir(name) ] for p in sorted(profiles): self._user_io.out.info(p) else: self._user_io.out.info("No profiles defined") elif subcommand == "show": p, _ = read_profile(profile, os.getcwd(), self._client_cache.profiles_path) Printer(self._user_io.out).print_profile(profile, p)
def _install(self, build_requires_references, build_requires_options, installer): # No need current path conanfile = self._loader.load_virtual( build_requires_references, None, scope_options=False, build_requires_options=build_requires_options) # compute and print the graph of transitive build-requires deps_graph = self._graph_builder.load(conanfile) Printer(self._output).print_graph(deps_graph, self._registry) # Make sure we recursively do not propagate the "*" pattern old_build_requires = self._profile_build_requires.copy() self._profile_build_requires.pop("*", None) self._profile_build_requires.pop("&!", None) installer.install(deps_graph) self._profile_build_requires = old_build_requires # Restore original values return deps_graph
def print_search_references(self, references, pattern, raw): printer = Printer(self.user_io.out) printer.print_search_recipes(references, pattern, raw)
def install(self, reference, current_path, remote=None, options=None, settings=None, build_mode=False, info=None, filename=None, update=False, check_updates=False, integrity=False, scopes=None): """ Fetch and build all dependencies for the given reference @param reference: ConanFileReference or path to user space conanfile @param current_path: where the output files will be saved @param remote: install only from that remote @param options: list of tuples: [(optionname, optionvalue), (optionname, optionvalue)...] @param settings: list of tuples: [(settingname, settingvalue), (settingname, value)...] """ reference_given = True if not isinstance(reference, ConanFileReference): conanfile_path = reference reference_given = False reference = None loader = self._loader(current_path, settings, options, scopes) # Not check for updates for info command, it'll be checked when dep graph is built remote_proxy = ConanProxy(self._paths, self._user_io, self._remote_manager, remote, update=update, check_updates=check_updates, check_integrity=integrity) if reference_given: project_reference = None conanfile_path = remote_proxy.get_conanfile(reference) output = ScopedOutput(str(reference), self._user_io.out) conanfile = loader.load_conan(conanfile_path, output, consumer=True) else: project_reference = "PROJECT" output = ScopedOutput(project_reference, self._user_io.out) try: if filename and filename.endswith(".txt"): raise NotFoundException("") conan_file_path = os.path.join(conanfile_path, filename or CONANFILE) conanfile = loader.load_conan(conan_file_path, output, consumer=True) is_txt = False if conanfile.name is not None and conanfile.version is not None: project_reference = "%s/%s@" % (conanfile.name, conanfile.version) project_reference += "PROJECT" except NotFoundException: # Load requirements.txt conan_path = os.path.join(conanfile_path, filename or CONANFILE_TXT) conanfile = loader.load_conan_txt(conan_path, output) is_txt = True # build deps graph and install it builder = DepsBuilder(remote_proxy, self._user_io.out, loader) deps_graph = builder.load(reference, conanfile) registry = RemoteRegistry(self._paths.registry, self._user_io.out) if info: if check_updates: graph_updates_info = builder.get_graph_updates_info(deps_graph) else: graph_updates_info = {} Printer(self._user_io.out).print_info(deps_graph, project_reference, info, registry, graph_updates_info, remote) return Printer(self._user_io.out).print_graph(deps_graph, registry) # Warn if os doesn't match try: if detected_os() != conanfile.settings.os: message = '''You are building this package with settings.os='%s' on a '%s' system. If this is your intention, you can ignore this message. If not: - Check the passed settings (-s) - Check your global settings in ~/.conan/conan.conf - Remove conaninfo.txt to avoid bad cached settings ''' % (conanfile.settings.os, detected_os()) self._user_io.out.warn(message) except ConanException: # Setting os doesn't exist pass installer = ConanInstaller(self._paths, self._user_io, remote_proxy) installer.install(deps_graph, build_mode) if not reference_given: if is_txt: conanfile.info.settings = loader._settings.values # Just in case the current package is header only, we still store the full settings # for reference and compiler checks conanfile.info.full_settings = loader._settings.values conanfile.info.scope = self._current_scopes content = normalize(conanfile.info.dumps()) save(os.path.join(current_path, CONANINFO), content) output.info("Generated %s" % CONANINFO) write_generators(conanfile, current_path, output) local_installer = FileImporter(deps_graph, self._paths, current_path) conanfile.copy = local_installer conanfile.imports() copied_files = local_installer.execute() import_output = ScopedOutput("%s imports()" % output.scope, output) report_copied_files(copied_files, import_output)
def print_profile(self, profile, profile_text): Printer(self.user_io.out).print_profile(profile, profile_text)
def print_search_references(self, search_info, pattern, raw, all_remotes_search): printer = Printer(self._output) printer.print_search_recipes(search_info, pattern, raw, all_remotes_search)
def install(self, reference, current_path, remote=None, options=None, settings=None, build_mode=False, filename=None, update=False, check_updates=False, manifest_folder=None, manifest_verify=False, manifest_interactive=False, scopes=None, generators=None, profile_name=None, package_settings=None, env_values=None, no_imports=False): """ Fetch and build all dependencies for the given reference @param reference: ConanFileReference or path to user space conanfile @param current_path: where the output files will be saved @param remote: install only from that remote @param options: list of tuples: [(optionname, optionvalue), (optionname, optionvalue)...] @param settings: list of tuples: [(settingname, settingvalue), (settingname, value)...] @param package_settings: dict name=> settings: {"zlib": [(settingname, settingvalue), ...]} @param profile: name of the profile to use @param env: list of tuples for environment vars: [(var, value), (var2, value2)...] @param package_env: package dict of list of tuples: {"package_name": [(var, value), (var2, value2)...]} """ generators = generators or [] if manifest_folder: manifest_manager = ManifestManager(manifest_folder, user_io=self._user_io, client_cache=self._client_cache, verify=manifest_verify, interactive=manifest_interactive) else: manifest_manager = None profile = self.read_profile(profile_name, current_path) # Mix Settings, Env vars and scopes between profile and command line settings, package_settings, scopes, env_values = _mix_with_profile(profile, settings, package_settings, scopes, env_values) objects = self._get_graph(reference, current_path, remote, options, settings, filename, update, check_updates, manifest_manager, scopes, package_settings, env_values) (_, deps_graph, _, registry, conanfile, remote_proxy, loader) = objects Printer(self._user_io.out).print_graph(deps_graph, registry) # Warn if os doesn't match try: if detected_os() != loader._settings.os: message = '''You are building this package with settings.os='%s' on a '%s' system. If this is your intention, you can ignore this message. If not: - Check the passed settings (-s) - Check your global settings in ~/.conan/conan.conf - Remove conaninfo.txt to avoid bad cached settings ''' % (loader._settings.os, detected_os()) self._user_io.out.warn(message) except ConanException: # Setting os doesn't exist pass installer = ConanInstaller(self._client_cache, self._user_io, remote_proxy) installer.install(deps_graph, build_mode) prefix = "PROJECT" if not isinstance(reference, ConanFileReference) else str(reference) output = ScopedOutput(prefix, self._user_io.out) # Write generators tmp = list(conanfile.generators) # Add the command line specified generators tmp.extend(generators) conanfile.generators = tmp write_generators(conanfile, current_path, output) if not isinstance(reference, ConanFileReference): content = normalize(conanfile.info.dumps()) save(os.path.join(current_path, CONANINFO), content) output.info("Generated %s" % CONANINFO) if not no_imports: run_imports(conanfile, current_path, output) installer.call_system_requirements(conanfile, output) if manifest_manager: manifest_manager.print_log()
def print_profile(self, profile, profile_text): Printer(self._output).print_profile(profile, profile_text)
def info(self, reference, current_path, profile, remote=None, info=None, filename=None, check_updates=False, build_order=None, build_modes=None, graph_filename=None, package_filter=None, show_paths=False): """ Fetch and build all dependencies for the given reference @param reference: ConanFileReference or path to user space conanfile @param current_path: where the output files will be saved @param remote: install only from that remote @param profile: Profile object with both the -s introduced options and profile readed values @param build_modes: List of build_modes specified @param filename: Optional filename of the conanfile """ remote_proxy = ConanProxy(self._client_cache, self._user_io, self._remote_manager, remote, update=False, check_updates=check_updates) loader = ConanFileLoader(self._runner, self._client_cache.settings, profile) conanfile = self._get_conanfile_object(loader, reference, filename, current_path) graph_builder = self._get_graph_builder(loader, False, remote_proxy) deps_graph = graph_builder.load(conanfile) if build_order: result = deps_graph.build_order(build_order) self._user_io.out.info(", ".join(str(s) for s in result)) return if build_modes is not None: installer = ConanInstaller(self._client_cache, self._user_io.out, remote_proxy, None) build_mode = BuildMode(build_modes, self._user_io.out) nodes = installer.nodes_to_build(deps_graph, build_mode) counter = Counter(ref.conan.name for ref, _ in nodes) self._user_io.out.info(", ".join( (str(ref) if counter[ref.conan.name] > 1 else str(ref.conan)) for ref, _ in nodes)) return if check_updates: graph_updates_info = graph_builder.get_graph_updates_info( deps_graph) else: graph_updates_info = {} def read_dates(deps_graph): ret = {} for ref, _ in sorted(deps_graph.nodes): if ref: manifest = self._client_cache.load_manifest(ref) ret[ref] = manifest.time_str return ret # Get project reference project_reference = None if isinstance(reference, ConanFileReference): project_reference = None else: project_reference = str(conanfile) # Print results if graph_filename: if graph_filename.endswith(".html"): grapher = ConanHTMLGrapher(project_reference, deps_graph) else: grapher = ConanGrapher(project_reference, deps_graph) grapher.graph_file(graph_filename) else: registry = RemoteRegistry(self._client_cache.registry, self._user_io.out) Printer(self._user_io.out).print_info(deps_graph, project_reference, info, registry, graph_updates_info, remote, read_dates(deps_graph), self._client_cache, package_filter, show_paths)
def install(self, reference, current_path, profile, remote=None, build_mode=None, filename=None, update=False, check_updates=False, manifest_folder=None, manifest_verify=False, manifest_interactive=False, generators=None, no_imports=False): """ Fetch and build all dependencies for the given reference @param reference: ConanFileReference or path to user space conanfile @param current_path: where the output files will be saved @param remote: install only from that remote @param options: list of tuples: [(optionname, optionvalue), (optionname, optionvalue)...] @param settings: list of tuples: [(settingname, settingvalue), (settingname, value)...] @param package_settings: dict name=> settings: {"zlib": [(settingname, settingvalue), ...]} @param profile: name of the profile to use @param env: list of tuples for environment vars: [(var, value), (var2, value2)...] @param package_env: package dict of list of tuples: {"package_name": [(var, value), (var2, value2)...]} """ generators = generators or [] if manifest_folder: manifest_manager = ManifestManager( manifest_folder, user_io=self._user_io, client_cache=self._client_cache, verify=manifest_verify, interactive=manifest_interactive) else: manifest_manager = None objects = self._get_graph(reference, current_path, profile, remote, filename, update, check_updates, manifest_manager) (_, deps_graph, _, registry, conanfile, remote_proxy, loader) = objects Printer(self._user_io.out).print_graph(deps_graph, registry) try: if detected_os() != loader._settings.os: message = "Cross-platform from '%s' to '%s'" % ( detected_os(), loader._settings.os) self._user_io.out.writeln(message, Color.BRIGHT_MAGENTA) except ConanException: # Setting os doesn't exist pass installer = ConanInstaller(self._client_cache, self._user_io, remote_proxy) installer.install(deps_graph, build_mode) prefix = "PROJECT" if not isinstance( reference, ConanFileReference) else str(reference) output = ScopedOutput(prefix, self._user_io.out) # Write generators tmp = list( conanfile.generators) # Add the command line specified generators tmp.extend(generators) conanfile.generators = tmp write_generators(conanfile, current_path, output) if not isinstance(reference, ConanFileReference): content = normalize(conanfile.info.dumps()) save(os.path.join(current_path, CONANINFO), content) output.info("Generated %s" % CONANINFO) if not no_imports: run_imports(conanfile, current_path, output) installer.call_system_requirements(conanfile, output) if manifest_manager: manifest_manager.print_log()
def install(self, reference, install_folder, profile, remote_name=None, build_modes=None, update=False, manifest_folder=None, manifest_verify=False, manifest_interactive=False, generators=None, no_imports=False, inject_require=None, install_reference=False, keep_build=False): """ Fetch and build all dependencies for the given reference @param reference: ConanFileReference or path to user space conanfile @param install_folder: where the output files will be saved @param remote: install only from that remote @param profile: Profile object with both the -s introduced options and profile read values @param build_modes: List of build_modes specified @param update: Check for updated in the upstream remotes (and update) @param manifest_folder: Folder to install the manifests @param manifest_verify: Verify dependencies manifests against stored ones @param manifest_interactive: Install deps manifests in folder for later verify, asking user for confirmation @param generators: List of generators from command line. If False, no generator will be written @param no_imports: Install specified packages but avoid running imports @param inject_require: Reference to add as a requirement to the conanfile """ if generators is not False: generators = set(generators) if generators else set() generators.add("txt") # Add txt generator by default manifest_manager = ManifestManager(manifest_folder, user_io=self._user_io, client_cache=self._client_cache, verify=manifest_verify, interactive=manifest_interactive) if manifest_folder else None remote_proxy = self.get_proxy(remote_name=remote_name, manifest_manager=manifest_manager) loader = self.get_loader(profile) if not install_reference: if isinstance(reference, ConanFileReference): # is a create loader.dev_reference = reference elif inject_require: loader.dev_reference = inject_require conanfile = self._load_install_conanfile(loader, reference) if inject_require: self._inject_require(conanfile, inject_require) graph_builder = self._get_graph_builder(loader, remote_proxy) deps_graph = graph_builder.load_graph(conanfile, False, update) if not isinstance(reference, ConanFileReference): output = ScopedOutput(("%s (test package)" % str(inject_require)) if inject_require else "PROJECT", self._user_io.out) output.highlight("Installing %s" % reference) else: output = ScopedOutput(str(reference), self._user_io.out) output.highlight("Installing package") Printer(self._user_io.out).print_graph(deps_graph, self._registry) try: if cross_building(loader._settings): b_os, b_arch, h_os, h_arch = get_cross_building_settings(loader._settings) message = "Cross-build from '%s:%s' to '%s:%s'" % (b_os, b_arch, h_os, h_arch) self._user_io.out.writeln(message, Color.BRIGHT_MAGENTA) except ConanException: # Setting os doesn't exist pass build_mode = BuildMode(build_modes, self._user_io.out) build_requires = BuildRequires(loader, graph_builder, self._registry) installer = ConanInstaller(self._client_cache, output, remote_proxy, build_mode, build_requires, recorder=self._recorder) # Apply build_requires to consumer conanfile if not isinstance(reference, ConanFileReference): build_requires.install("", conanfile, installer, profile.build_requires, output, update) installer.install(deps_graph, profile.build_requires, keep_build, update=update) build_mode.report_matches() if install_folder: # Write generators if generators is not False: tmp = list(conanfile.generators) # Add the command line specified generators tmp.extend([g for g in generators if g not in tmp]) conanfile.generators = tmp write_generators(conanfile, install_folder, output) if not isinstance(reference, ConanFileReference): # Write conaninfo content = normalize(conanfile.info.dumps()) save(os.path.join(install_folder, CONANINFO), content) output.info("Generated %s" % CONANINFO) if not no_imports: run_imports(conanfile, install_folder, output) call_system_requirements(conanfile, output) if install_reference: # The conanfile loaded is really a virtual one. The one with the deploy is the first level one deploy_conanfile = deps_graph.inverse_levels()[1][0].conanfile if hasattr(deploy_conanfile, "deploy") and callable(deploy_conanfile.deploy): run_deploy(deploy_conanfile, install_folder, output) if manifest_manager: manifest_manager.print_log()
def info(self, deps_graph, only, package_filter, show_paths): data = self._grab_info_data(deps_graph, grab_paths=show_paths) Printer(self.user_io.out).print_info(data, only, package_filter=package_filter, show_paths=show_paths)
def print_search_packages(self, ordered_packages, pattern, recipe_hash, packages_query): printer = Printer(self.user_io.out) printer.print_search_packages(ordered_packages, pattern, recipe_hash, packages_query)
def install(self, reference, current_path, profile, remote=None, build_modes=None, filename=None, update=False, manifest_folder=None, manifest_verify=False, manifest_interactive=False, generators=None, no_imports=False, inject_require=None): """ Fetch and build all dependencies for the given reference @param reference: ConanFileReference or path to user space conanfile @param current_path: where the output files will be saved @param remote: install only from that remote @param profile: Profile object with both the -s introduced options and profile readed values @param build_modes: List of build_modes specified @param filename: Optional filename of the conanfile @param update: Check for updated in the upstream remotes (and update) @param manifest_folder: Folder to install the manifests @param manifest_verify: Verify dependencies manifests against stored ones @param manifest_interactive: Install deps manifests in folder for later verify, asking user for confirmation @param generators: List of generators from command line @param no_imports: Install specified packages but avoid running imports """ generators = generators or [] manifest_manager = ManifestManager( manifest_folder, user_io=self._user_io, client_cache=self._client_cache, verify=manifest_verify, interactive=manifest_interactive) if manifest_folder else None remote_proxy = ConanProxy(self._client_cache, self._user_io, self._remote_manager, remote, update=update, check_updates=False, manifest_manager=manifest_manager) loader = ConanFileLoader(self._runner, self._client_cache.settings, self._profile_with_defaults(profile)) conanfile = self._get_conanfile_object(loader, reference, filename, current_path) if inject_require: self._inject_require(conanfile, inject_require) graph_builder = self._get_graph_builder(loader, update, remote_proxy) deps_graph = graph_builder.load(conanfile) # This line is so the conaninfo stores the correct complete info conanfile.info.scope = profile.scopes registry = RemoteRegistry(self._client_cache.registry, self._user_io.out) if inject_require: output = ScopedOutput("%s test package" % str(inject_require), self._user_io.out) output.info("Installing dependencies") elif not isinstance(reference, ConanFileReference): output = ScopedOutput("PROJECT", self._user_io.out) Printer(self._user_io.out).print_graph(deps_graph, registry) else: output = ScopedOutput(str(reference), self._user_io.out) output.highlight("Installing package") try: if loader._settings.os and detected_os() != loader._settings.os: message = "Cross-platform from '%s' to '%s'" % ( detected_os(), loader._settings.os) self._user_io.out.writeln(message, Color.BRIGHT_MAGENTA) except ConanException: # Setting os doesn't exist pass build_mode = BuildMode(build_modes, self._user_io.out) build_requires = BuildRequires(loader, graph_builder, registry, output, profile.build_requires) installer = ConanInstaller(self._client_cache, output, remote_proxy, build_mode, build_requires) # Apply build_requires to consumer conanfile if not isinstance(reference, ConanFileReference): build_requires.install("", conanfile, installer) installer.install(deps_graph, current_path) build_mode.report_matches() # Write generators tmp = list( conanfile.generators) # Add the command line specified generators tmp.extend([g for g in generators if g not in tmp]) conanfile.generators = tmp write_generators(conanfile, current_path, output) if not isinstance(reference, ConanFileReference): content = normalize(conanfile.info.dumps()) save(os.path.join(current_path, CONANINFO), content) output.info("Generated %s" % CONANINFO) if not no_imports: run_imports(conanfile, current_path, output) installer.call_system_requirements(conanfile, output) if manifest_manager: manifest_manager.print_log()
def install(self, reference, current_path, remote=None, options=None, settings=None, build_mode=False, info=None, filename=None, update=False): """ Fetch and build all dependencies for the given reference @param reference: ConanFileReference or path to user space conanfile @param current_path: where the output files will be saved @param remote: install only from that remote @param options: list of tuples: [(optionname, optionvalue), (optionname, optionvalue)...] @param settings: list of tuples: [(settingname, settingvalue), (settingname, settingvalue)...] """ reference_given = True if not isinstance(reference, ConanFileReference): conanfile_path = reference reference_given = False reference = None loader = self._loader(current_path, settings, options) # Not check for updates for info command, it'll be checked when dep graph is built check_updates = not info remote_proxy = ConanProxy(self._paths, self._user_io, self._remote_manager, remote, update, check_updates) if reference_given: project_reference = None conanfile_path = remote_proxy.get_conanfile(reference) output = ScopedOutput(str(reference), self._user_io.out) conanfile = loader.load_conan(conanfile_path, output, consumer=True) else: project_reference = "PROJECT" output = ScopedOutput(project_reference, self._user_io.out) try: if filename and filename.endswith(".txt"): raise NotFoundException() conan_file_path = os.path.join(conanfile_path, filename or CONANFILE) conanfile = loader.load_conan(conan_file_path, output, consumer=True) is_txt = False if conanfile.name is not None and conanfile.version is not None: project_reference = "%s/%s@" % (conanfile.name, conanfile.version) project_reference += "PROJECT" except NotFoundException: # Load requirements.txt conan_path = os.path.join(conanfile_path, filename or CONANFILE_TXT) conanfile = loader.load_conan_txt(conan_path, output) is_txt = True # build deps graph and install it builder = DepsBuilder(remote_proxy, self._user_io.out, loader) deps_graph = builder.load(reference, conanfile) registry = RemoteRegistry(self._paths.registry, self._user_io.out) if info: graph_updates_info = builder.get_graph_updates_info(deps_graph) Printer(self._user_io.out).print_info(deps_graph, project_reference, info, registry, graph_updates_info, remote) return Printer(self._user_io.out).print_graph(deps_graph, registry) installer = ConanInstaller(self._paths, self._user_io, remote_proxy) installer.install(deps_graph, build_mode) if not reference_given: if is_txt: conanfile.info.settings = loader._settings.values # Just in case the current package is header only, we still store the full settings # for reference and compiler checks conanfile.info.full_settings = loader._settings.values content = normalize(conanfile.info.dumps()) save(os.path.join(current_path, CONANINFO), content) output.info("Generated %s" % CONANINFO) write_generators(conanfile, current_path, output) local_installer = FileImporter(deps_graph, self._paths, current_path) conanfile.copy = local_installer conanfile.imports() local_installer.execute()