def get_sources_from_exports(): src_folder = conanfile.source_folder if conanfile_folder != src_folder: _run_local_scm(conanfile, conanfile_folder, src_folder, output=conanfile.output) conanfile.output.info("Executing exports to: %s" % src_folder) export_recipe(conanfile, conanfile_folder, src_folder) export_source(conanfile, conanfile_folder, src_folder)
def _get_sources_from_exports(conanfile, src_folder, export_folder, export_source_folder, output, client_cache): # Files from python requires are obtained before the self files from conans.client.cmd.export import export_source for python_require in conanfile.python_requires: src = client_cache.export_sources(python_require.conan_ref) export_source(conanfile, src, src_folder, output) # so self exported files have precedence over python_requires ones merge_directories(export_folder, src_folder) # Now move the export-sources to the right location merge_directories(export_source_folder, src_folder)
def get_sources_from_exports(): src_folder = conanfile.source_folder if conanfile_folder != src_folder: _run_local_scm(conanfile, conanfile_folder, src_folder, output=conanfile.output) conanfile.output.info("Executing exports to: %s" % src_folder) if not hasattr(conanfile, "layout"): export_recipe(conanfile, conanfile_folder, src_folder) else: # If layout declared, the export_sources will go to base source (like develop2) src_folder = conanfile.folders.base_source if conanfile_folder != src_folder: export_source(conanfile, conanfile_folder, src_folder)
def config_source(export_folder, export_source_folder, local_sources_path, src_folder, conanfile, output, conanfile_path, reference, hook_manager, client_cache): """ creates src folder and retrieve, calling source() from conanfile the necessary source code """ def remove_source(raise_error=True): output.warn("This can take a while for big packages") try: rmdir(src_folder) except BaseException as e_rm: set_dirty(src_folder) msg = str(e_rm) if six.PY2: msg = str(e_rm).decode( "latin1") # Windows prints some chars in latin1 output.error("Unable to remove source folder %s\n%s" % (src_folder, msg)) output.warn("**** Please delete it manually ****") if raise_error or isinstance(e_rm, KeyboardInterrupt): raise ConanException("Unable to remove source folder") if is_dirty(src_folder): output.warn("Trying to remove corrupted source folder") remove_source() elif conanfile.build_policy_always: output.warn( "Detected build_policy 'always', trying to remove source folder") remove_source() elif local_sources_path and os.path.exists(local_sources_path): output.warn( "Detected 'scm' auto in conanfile, trying to remove source folder") remove_source() if not os.path.exists(src_folder): set_dirty(src_folder) mkdir(src_folder) os.chdir(src_folder) conanfile.source_folder = src_folder try: with conanfile_exception_formatter(str(conanfile), "source"): with get_env_context_manager(conanfile): conanfile.build_folder = None conanfile.package_folder = None hook_manager.execute("pre_source", conanfile=conanfile, conanfile_path=conanfile_path, reference=reference) output.info('Configuring sources in %s' % src_folder) scm_data = get_scm_data(conanfile) if scm_data: dest_dir = os.path.normpath( os.path.join(src_folder, scm_data.subfolder)) captured = local_sources_path and os.path.exists( local_sources_path) local_sources_path = local_sources_path if captured else None _fetch_scm(scm_data, dest_dir, local_sources_path, output) # Files from python requires are obtained before the self files from conans.client.cmd.export import export_source for python_require in conanfile.python_requires: src = client_cache.export_sources( python_require.conan_ref) export_source(conanfile, src, src_folder, output) # so self exported files have precedence over python_requires ones merge_directories(export_folder, src_folder) # Now move the export-sources to the right location merge_directories(export_source_folder, src_folder) _clean_source_folder(src_folder) try: shutil.rmtree(os.path.join(src_folder, "__pycache__")) except OSError: pass conanfile.source() hook_manager.execute("post_source", conanfile=conanfile, conanfile_path=conanfile_path, reference=reference) clean_dirty(src_folder) # Everything went well, remove DIRTY flag except Exception as e: os.chdir(export_folder) # in case source() fails (user error, typically), remove the src_folder # and raise to interrupt any other processes (build, package) output.warn("Trying to remove corrupted source folder") remove_source(raise_error=False) if isinstance(e, ConanExceptionInUserConanfileMethod): raise e raise ConanException(e)
def get_sources_from_exports(): if conanfile_folder != src_folder: conanfile.output.info("Executing exports to: %s" % src_folder) export_recipe(conanfile, conanfile_folder, src_folder) export_source(conanfile, conanfile_folder, src_folder)