def install_workspace(self, profile, workspace, remote_name, build_modes, update): loader = self.get_loader(profile) references = [ ConanFileReference(v, "root", "project", "develop") for v in workspace.root ] conanfile = loader.load_virtual(references) remote_proxy = self.get_proxy(remote_name=remote_name) graph_builder = self._get_graph_builder(loader, remote_proxy) graph_builder._workspace = workspace deps_graph = graph_builder.load_graph(conanfile, False, update) output = ScopedOutput(str("Workspace"), self._user_io.out) output.highlight("Installing...") print_graph(deps_graph, self._user_io.out) 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) installer._workspace = workspace installer.install(deps_graph, profile.build_requires, keep_build=False, update=update) build_mode.report_matches() workspace.generate()
def build(self, conanfile_path, source_folder, build_folder, package_folder, install_folder, test=False): """ Call to build() method saved on the conanfile.py param conanfile_path: path to a conanfile.py """ logger.debug("Building in %s" % build_folder) logger.debug("Conanfile in %s" % conanfile_path) try: # Append env_vars to execution environment and clear when block code ends output = ScopedOutput( ("%s test package" % test) if test else "Project", self._user_io.out) conan_file = self.load_consumer_conanfile(conanfile_path, install_folder, output, deps_info_required=True) except NotFoundException: # TODO: Auto generate conanfile from requirements file raise ConanException("'%s' file is needed for build.\n" "Create a '%s' and move manually the " "requirements and generators from '%s' file" % (CONANFILE, CONANFILE, CONANFILE_TXT)) if test: try: conan_file.requires.add(test) except ConanException: pass try: mkdir(build_folder) os.chdir(build_folder) conan_file.conanfile_directory = source_folder conan_file.build_folder = build_folder conan_file.source_folder = source_folder conan_file.package_folder = package_folder conan_file.install_folder = install_folder with environment_append(conan_file.env): output.highlight("Running build()") with conanfile_exception_formatter(str(conan_file), "build"): conan_file.build() if test: output.highlight("Running test()") with conanfile_exception_formatter(str(conan_file), "test"): conan_file.test() except ConanException: raise # Raise but not let to reach the Exception except (not print traceback) except Exception: import traceback trace = traceback.format_exc().split('\n') raise ConanException("Unable to build it successfully\n%s" % '\n'.join(trace[3:]))
def build(self, conanfile_path, source_folder, build_folder, package_folder, install_folder, test=False, should_configure=True, should_build=True, should_install=True): """ Call to build() method saved on the conanfile.py param conanfile_path: path to a conanfile.py """ logger.debug("Building in %s" % build_folder) logger.debug("Conanfile in %s" % conanfile_path) try: # Append env_vars to execution environment and clear when block code ends output = ScopedOutput(("%s (test package)" % test) if test else "Project", self._user_io.out) conan_file = self._load_consumer_conanfile(conanfile_path, install_folder, output, deps_info_required=True) except NotFoundException: # TODO: Auto generate conanfile from requirements file raise ConanException("'%s' file is needed for build.\n" "Create a '%s' and move manually the " "requirements and generators from '%s' file" % (CONANFILE, CONANFILE, CONANFILE_TXT)) if test: try: conan_file.requires.add(test) except ConanException: pass conan_file.should_configure = should_configure conan_file.should_build = should_build conan_file.should_install = should_install try: mkdir(build_folder) os.chdir(build_folder) conan_file.build_folder = build_folder conan_file.source_folder = source_folder conan_file.package_folder = package_folder conan_file.install_folder = install_folder with get_env_context_manager(conan_file): output.highlight("Running build()") with conanfile_exception_formatter(str(conan_file), "build"): conan_file.build() if test: output.highlight("Running test()") with conanfile_exception_formatter(str(conan_file), "test"): conan_file.test() except ConanException: raise # Raise but not let to reach the Exception except (not print traceback) except Exception: import traceback trace = traceback.format_exc().split('\n') raise ConanException("Unable to build it successfully\n%s" % '\n'.join(trace[3:]))
def install_workspace(self, profile, workspace, remote_name, build_modes, update): references = [ConanFileReference(v, "root", "project", "develop") for v in workspace.root] deps_graph, _, _ = self._graph_manager.load_graph(references, None, profile, build_modes, False, update, remote_name, self._recorder, workspace) output = ScopedOutput(str("Workspace"), self._user_io.out) output.highlight("Installing...") print_graph(deps_graph, self._user_io.out) installer = ConanInstaller(self._client_cache, output, self._remote_manager, self._registry, recorder=self._recorder, workspace=workspace, hook_manager=self._hook_manager) installer.install(deps_graph, keep_build=False) workspace.generate()
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, 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 create(self, conanfile_path, name=None, version=None, user=None, channel=None, profile_name=None, settings=None, options=None, env=None, test_folder=None, not_export=False, build_modes=None, keep_source=False, keep_build=False, verify=None, manifests=None, manifests_interactive=None, remote=None, update=False, cwd=None, test_build_folder=None): """ API method to create a conan package :param test_folder: default None - looks for default 'test' or 'test_package' folder), string - test_folder path False - disabling tests """ settings = settings or [] options = options or [] env = env or [] cwd = cwd or os.getcwd() conanfile_path = _get_conanfile_path(conanfile_path, cwd, py=True) if not name or not version: conanfile = load_conanfile_class(conanfile_path) name, version = conanfile.name, conanfile.version if not name or not version: raise ConanException("conanfile.py doesn't declare package name or version") reference = ConanFileReference(name, version, user, channel) scoped_output = ScopedOutput(str(reference), self._user_io.out) # Make sure keep_source is set for keep_build if keep_build: keep_source = True # Forcing an export! if not not_export: scoped_output.highlight("Exporting package recipe") self._manager.export(conanfile_path, name, version, user, channel, keep_source) if build_modes is None: # Not specified, force build the tested library build_modes = [name] manifests = _parse_manifests_arguments(verify, manifests, manifests_interactive, cwd) manifest_folder, manifest_interactive, manifest_verify = manifests profile = profile_from_args(profile_name, settings, options, env, cwd, self._client_cache) def get_test_conanfile_path(tf): """Searches in the declared test_folder or in the standard locations""" if tf is False: # Look up for testing conanfile can be disabled if tf (test folder) is False return None test_folders = [tf] if tf else ["test_package", "test"] base_folder = os.path.dirname(conanfile_path) for test_folder_name in test_folders: test_folder = os.path.join(base_folder, test_folder_name) test_conanfile_path = os.path.join(test_folder, "conanfile.py") if os.path.exists(test_conanfile_path): return test_conanfile_path else: if tf: raise ConanException("test folder '%s' not available, " "or it doesn't have a conanfile.py" % tf) test_conanfile_path = get_test_conanfile_path(test_folder) if test_conanfile_path: pt = PackageTester(self._manager, self._user_io) pt.install_build_and_test(test_conanfile_path, reference, profile, remote, update, build_modes=build_modes, manifest_folder=manifest_folder, manifest_verify=manifest_verify, manifest_interactive=manifest_interactive, keep_build=keep_build, test_build_folder=test_build_folder) else: self._manager.install(reference=reference, install_folder=None, # Not output anything manifest_folder=manifest_folder, manifest_verify=manifest_verify, manifest_interactive=manifest_interactive, remote=remote, profile=profile, build_modes=build_modes, update=update, keep_build=keep_build)
def build(graph_manager, hook_manager, conanfile_path, output, source_folder, build_folder, package_folder, install_folder, test=False, should_configure=True, should_build=True, should_install=True, should_test=True): """ Call to build() method saved on the conanfile.py param conanfile_path: path to a conanfile.py """ logger.debug("BUILD: folder '%s'" % build_folder) logger.debug("BUILD: Conanfile at '%s'" % conanfile_path) try: # Append env_vars to execution environment and clear when block code ends output = ScopedOutput( ("%s (test package)" % test) if test else "Project", output) conan_file = graph_manager.load_consumer_conanfile( conanfile_path, install_folder, output, deps_info_required=True) except NotFoundException: # TODO: Auto generate conanfile from requirements file raise ConanException("'%s' file is needed for build.\n" "Create a '%s' and move manually the " "requirements and generators from '%s' file" % (CONANFILE, CONANFILE, CONANFILE_TXT)) if test: try: conan_file.requires.add(test) except ConanException: pass conan_file.should_configure = should_configure conan_file.should_build = should_build conan_file.should_install = should_install conan_file.should_test = should_test try: mkdir(build_folder) os.chdir(build_folder) conan_file.build_folder = build_folder conan_file.source_folder = source_folder conan_file.package_folder = package_folder conan_file.install_folder = install_folder hook_manager.execute("pre_build", conanfile=conan_file, conanfile_path=conanfile_path) with get_env_context_manager(conan_file): output.highlight("Running build()") with conanfile_exception_formatter(str(conan_file), "build"): conan_file.build() hook_manager.execute("post_build", conanfile=conan_file, conanfile_path=conanfile_path) if test: output.highlight("Running test()") with conanfile_exception_formatter(str(conan_file), "test"): conan_file.test() except ConanException: raise # Raise but not let to reach the Exception except (not print traceback) except Exception: import traceback trace = traceback.format_exc().split('\n') raise ConanException("Unable to build it successfully\n%s" % '\n'.join(trace[3:]))
def create(self, conanfile_path, name=None, version=None, user=None, channel=None, profile_name=None, settings=None, options=None, env=None, test_folder=None, not_export=False, build_modes=None, keep_source=False, keep_build=False, verify=None, manifests=None, manifests_interactive=None, remote=None, update=False, cwd=None, test_build_folder=None): """ API method to create a conan package :param test_folder: default None - looks for default 'test' or 'test_package' folder), string - test_folder path False - disabling tests """ settings = settings or [] options = options or [] env = env or [] try: cwd = cwd or os.getcwd() recorder = ActionRecorder() conanfile_path = _get_conanfile_path(conanfile_path, cwd, py=True) if not name or not version: conanfile = load_conanfile_class(conanfile_path) name, version = conanfile.name, conanfile.version if not name or not version: raise ConanException( "conanfile.py doesn't declare package name or version") reference = ConanFileReference(name, version, user, channel) scoped_output = ScopedOutput(str(reference), self._user_io.out) # Make sure keep_source is set for keep_build if keep_build: keep_source = True # Forcing an export! if not not_export: scoped_output.highlight("Exporting package recipe") cmd_export(conanfile_path, name, version, user, channel, keep_source, self._user_io.out, self._client_cache) if build_modes is None: # Not specified, force build the tested library build_modes = [name] manifests = _parse_manifests_arguments(verify, manifests, manifests_interactive, cwd) manifest_folder, manifest_interactive, manifest_verify = manifests profile = profile_from_args(profile_name, settings, options, env, cwd, self._client_cache) manager = self._init_manager(recorder) recorder.add_recipe_being_developed(reference) create(reference, manager, self._user_io, profile, remote, update, build_modes, manifest_folder, manifest_verify, manifest_interactive, keep_build, test_build_folder, test_folder, conanfile_path) return recorder.get_info() except ConanException as exc: recorder.error = True exc.info = recorder.get_info() raise
def install(self, reference, install_folder, graph_info, remote_name=None, build_modes=None, update=False, manifest_folder=None, manifest_verify=False, manifest_interactive=False, generators=None, no_imports=False, create_reference=None, 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 self._user_io.out.info("Configuration:") self._user_io.out.writeln(graph_info.profile.dumps()) result = self._graph_manager.load_graph(reference, create_reference, graph_info, build_modes, False, update, remote_name, self._recorder, None) deps_graph, conanfile, cache_settings = result if not isinstance(reference, ConanFileReference): output = ScopedOutput( ("%s (test package)" % str(create_reference)) if create_reference else "PROJECT", self._user_io.out) output.highlight("Installing %s" % reference) else: output = ScopedOutput(str(reference), self._user_io.out) output.highlight("Installing package") print_graph(deps_graph, self._user_io.out) try: if cross_building(cache_settings): b_os, b_arch, h_os, h_arch = get_cross_building_settings( cache_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 installer = ConanInstaller(self._client_cache, output, self._remote_manager, recorder=self._recorder, workspace=None, hook_manager=self._hook_manager) installer.install(deps_graph, keep_build) if manifest_folder: manifest_manager = ManifestManager(manifest_folder, user_io=self._user_io, client_cache=self._client_cache) for node in deps_graph.nodes: if not node.conan_ref: continue complete_recipe_sources(self._remote_manager, self._client_cache, node.conanfile, node.conan_ref) manifest_manager.check_graph(deps_graph, verify=manifest_verify, interactive=manifest_interactive) manifest_manager.print_log() 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) graph_info.save(install_folder) output.info("Generated graphinfo") if not no_imports: run_imports(conanfile, install_folder, output) call_system_requirements(conanfile, output) if not create_reference and isinstance(reference, ConanFileReference): # The conanfile loaded is a virtual one. The one w deploy is the first level one neighbours = deps_graph.root.neighbors() deploy_conanfile = neighbours[0].conanfile if hasattr(deploy_conanfile, "deploy") and callable( deploy_conanfile.deploy): run_deploy(deploy_conanfile, install_folder, output)
def create(self, profile_name=None, settings=None, options=None, env=None, scope=None, test_folder=None, not_export=False, build=None, keep_source=False, verify=default_manifest_folder, manifests=default_manifest_folder, manifests_interactive=default_manifest_folder, remote=None, update=False, cwd=None, user=None, channel=None, name=None, version=None): settings = settings or [] options = options or [] env = env or [] cwd = prepare_cwd(cwd) if not name or not version: conanfile_path = os.path.join(cwd, "conanfile.py") conanfile = load_conanfile_class(conanfile_path) name, version = conanfile.name, conanfile.version if not name or not version: raise ConanException("conanfile.py doesn't declare package name or version") reference = ConanFileReference(name, version, user, channel) scoped_output = ScopedOutput(str(reference), self._user_io.out) # Forcing an export! if not not_export: scoped_output.highlight("Exporting package recipe") self._manager.export(user, channel, cwd, keep_source=keep_source, name=name, version=version) if build is None: # Not specified, force build the tested library build = [name] manifests = _parse_manifests_arguments(verify, manifests, manifests_interactive, cwd) manifest_folder, manifest_interactive, manifest_verify = manifests profile = profile_from_args(profile_name, settings, options, env, scope, cwd, self._client_cache.profiles_path) self._manager.install(reference=reference, current_path=cwd, manifest_folder=manifest_folder, manifest_verify=manifest_verify, manifest_interactive=manifest_interactive, remote=remote, profile=profile, build_modes=build, update=update ) test_folders = [test_folder] if test_folder else ["test_package", "test"] for test_folder_name in test_folders: test_folder = os.path.join(cwd, test_folder_name) test_conanfile_path = os.path.join(test_folder, "conanfile.py") if os.path.exists(test_conanfile_path): break else: self._user_io.out.warn("test package folder not available, or it doesn't have " "a conanfile.py\nIt is recommended to set a 'test_package' " "while creating packages") return scoped_output.highlight("Testing with 'test_package'") sha = hashlib.sha1("".join(options + settings).encode()).hexdigest() build_folder = os.path.join(test_folder, "build", sha) rmdir(build_folder) test_conanfile = os.path.join(test_folder, CONANFILE) self._manager.install(inject_require=reference, reference=test_folder, current_path=build_folder, manifest_folder=manifest_folder, manifest_verify=manifest_verify, manifest_interactive=manifest_interactive, remote=remote, profile=profile, update=update, generators=["txt"] ) self._manager.build(test_conanfile, test_folder, build_folder, package_folder=None, test=str(reference))
def create(self, profile_name=None, settings=None, options=None, env=None, scope=None, test_folder=None, not_export=False, build_modes=None, keep_source=False, verify=None, manifests=None, manifests_interactive=None, remote=None, update=False, conan_file_path=None, filename=None, user=None, channel=None, name=None, version=None, werror=False): settings = settings or [] options = options or [] env = env or [] self._user_io.out.werror_active = werror cwd = os.getcwd() conanfile_folder = self._abs_relative_to(conan_file_path, cwd, default=cwd) if not name or not version: conanfile_abs_path = self._get_conanfile_path( conanfile_folder, filename or CONANFILE) conanfile = load_conanfile_class(conanfile_abs_path) name, version = conanfile.name, conanfile.version if not name or not version: raise ConanException( "conanfile.py doesn't declare package name or version") reference = ConanFileReference(name, version, user, channel) scoped_output = ScopedOutput(str(reference), self._user_io.out) # Forcing an export! if not not_export: scoped_output.highlight("Exporting package recipe") self._manager.export(user, channel, conanfile_folder, keep_source=keep_source, name=name, version=version, filename=filename) if build_modes is None: # Not specified, force build the tested library build_modes = [name] manifests = _parse_manifests_arguments(verify, manifests, manifests_interactive, cwd) manifest_folder, manifest_interactive, manifest_verify = manifests profile = profile_from_args(profile_name, settings, options, env, scope, cwd, self._client_cache) self._manager.install( reference=reference, install_folder=None, # Not output anything manifest_folder=manifest_folder, manifest_verify=manifest_verify, manifest_interactive=manifest_interactive, remote=remote, profile=profile, build_modes=build_modes, update=update, filename=filename) base_folder = self._abs_relative_to(conan_file_path, cwd, default=cwd) def get_test_conanfile_path(tf): """Searchs in the declared test_folder or in the standard locations""" test_folders = [tf] if tf else ["test_package", "test"] for test_folder_name in test_folders: test_folder = os.path.join(base_folder, test_folder_name) test_conanfile_path = os.path.join(test_folder, "conanfile.py") if os.path.exists(test_conanfile_path): return test_conanfile_path else: if tf: raise ConanException("test folder '%s' not available, " "or it doesn't have a conanfile.py" % tf) test_conanfile_path = get_test_conanfile_path(test_folder) if test_conanfile_path: pt = PackageTester(self._manager, self._user_io) scoped_output.highlight("Testing with 'test_package'") pt.install_build_and_test(test_conanfile_path, profile, name, version, user, channel, remote, update)