def compile_generic_routine(formula, aliases, dllname, dtype, lang, optional_flags, build_folder): aliases = check_aliases_list(aliases) def process_alias(alias): if alias.find("=") == -1: return "" # because in this case it is not really an alias, the variable is just named else: return "auto " + str(alias) + "; " def process_disp_alias(alias): return str(alias) + "; " alias_string = "".join([process_alias(alias) for alias in aliases]) alias_disp_string = "".join( [process_disp_alias(alias) for alias in aliases]) print( "Compiling " + dllname + " in " + os.path.realpath(build_folder + os.path.sep + "..") + ":\n" + " formula: " + formula + "\n aliases: " + alias_disp_string + "\n dtype : " + dtype + "\n... ", end="", flush=True, ) command_line = [ "cmake", pykeops.config.script_folder, "-DCMAKE_BUILD_TYPE=" + "'{}'".format(pykeops.config.build_type), "-DFORMULA_OBJ=" + "'{}'".format(formula), "-DVAR_ALIASES=" + "'{}'".format(alias_string), "-Dshared_obj_name=" + "'{}'".format(dllname), "-D__TYPE__=" + "'{}'".format(c_type[dtype]), "-DPYTHON_LANG=" + "'{}'".format(lang), "-DPYTHON_EXECUTABLE=" + "'{}'".format(sys.executable), "-DPYBIND11_PYTHON_VERSION=" + "'{}'".format( str(sys.version_info.major) + "." + str(sys.version_info.minor)), "-DC_CONTIGUOUS=1", ] + optional_flags run_and_display( command_line + ["-DcommandLine=" + " ".join(command_line)], build_folder, msg="CMAKE", ) run_and_display( ["cmake", "--build", ".", "--target", dllname, "--", "VERBOSE=1"], build_folder, msg="MAKE", ) print("Done.")
def compile_generic_routine(formula, aliases, dllname, dtype, lang, optional_flags, build_folder=bin_folder): aliases = check_aliases_list(aliases) def process_alias(alias): if alias.find("=") == -1: return '' # because in this case it is not really an alias, the variable is just named else: return 'auto ' + str(alias) + '; ' def process_disp_alias(alias): return str(alias) + '; ' alias_string = ''.join([process_alias(alias) for alias in aliases]) alias_disp_string = ''.join( [process_disp_alias(alias) for alias in aliases]) print('Compiling ' + dllname + ' in ' + build_folder + ':\n' + ' formula: ' + formula + '\n aliases: ' + alias_disp_string + '\n dtype : ' + dtype + '\n... ', end='', flush=True) command_line = [ "cmake", script_folder, "-DCMAKE_BUILD_TYPE=" + "'{}'".format(build_type), "-DFORMULA_OBJ=" + "'{}'".format(formula), "-DVAR_ALIASES=" + "'{}'".format(alias_string), "-Dshared_obj_name=" + "'{}'".format(dllname), "-D__TYPE__=" + "'{}'".format(c_type[dtype]), "-DPYTHON_LANG=" + "'{}'".format(lang), "-DPYTHON_EXECUTABLE=" + "'{}'".format(sys.executable), "-DPYBIND11_PYTHON_VERSION=" + "'{}'".format( str(sys.version_info.major) + "." + str(sys.version_info.minor)), "-DC_CONTIGUOUS=1", ] + optional_flags run_and_display(command_line + ["-DcommandLine=" + " ".join(command_line)], build_folder, msg="CMAKE") run_and_display( ["cmake", "--build", ".", "--target", dllname, "--", "VERBOSE=1"], build_folder, msg="MAKE") print('Done.')
def compile_generic_routine(formula, aliases, dllname, dtype, lang, optional_flags, build_folder=bin_folder): aliases = check_aliases_list(aliases) def process_alias(alias): if alias.find("=") == -1: return '' # because in this case it is not really an alias, the variable is just named else: return 'auto ' + str(alias) + '; ' def process_disp_alias(alias): return str(alias) + '; ' alias_string = ''.join([process_alias(alias) for alias in aliases]) alias_disp_string = ''.join( [process_disp_alias(alias) for alias in aliases]) print('Compiling ' + dllname + ' in ' + build_folder + ':\n' + ' formula: ' + formula + '\n aliases: ' + alias_disp_string + '\n dtype : ' + dtype + '\n... ', end='', flush=True) command_line = [ 'cmake', script_folder, '-DCMAKE_BUILD_TYPE=' + build_type, '-DFORMULA_OBJ=' + formula, '-DVAR_ALIASES=' + alias_string, '-Dshared_obj_name=' + dllname, '-D__TYPE__=' + c_type[dtype], '-DPYTHON_LANG=' + lang, '-DC_CONTIGUOUS=1', ] + optional_flags run_and_display(command_line + ['-DcommandLine=' + ' '.join(command_line)], build_folder, msg='CMAKE') run_and_display( ['cmake', '--build', '.', '--target', dllname, '--', 'VERBOSE=1'], build_folder, msg='MAKE') print('Done.')
def compile_generic_routine(formula, aliases, dllname, dtype, lang, optional_flags, include_dirs, build_folder): aliases = check_aliases_list(aliases) def process_alias(alias): if alias.find("=") == -1: return "" # because in this case it is not really an alias, the variable is just named else: return "auto " + str(alias) + "; " def process_disp_alias(alias): return str(alias) + "; " alias_string = "".join([process_alias(alias) for alias in aliases]) alias_disp_string = "".join([process_disp_alias(alias) for alias in aliases]) print( '[pyKeOps] Compiling ' + dllname + ' in ' + os.path.realpath(build_folder + os.path.sep + '..') + ':\n' + ' formula: ' + formula + '\n' + ' aliases: ' + alias_disp_string + '\n' + ' dtype : ' + dtype + '\n... ', flush=True) build_keops_formula_object_file(build_folder, dtype, formula, alias_string, optional_flags) template_name, is_rebuilt = get_or_build_pybind11_template(dtype, lang, include_dirs, use_prebuilt_formula=True) template_build_folder = pykeops.config.bin_folder + os.path.sep + 'build-pybind11_template-' + template_name if not is_rebuilt: fname = pykeops.config.shared_obj_name + ".o" os.rename(pykeops.config.bin_folder + os.path.sep + fname, template_build_folder + os.path.sep + fname) run_and_display(["cmake", "--build", ".", "--target", template_name, "--", "VERBOSE=1"], template_build_folder, msg="MAKE") os.makedirs(pykeops.config.bin_folder + os.path.sep + dllname, exist_ok=True) fname = list(pathlib.Path(template_build_folder).glob(template_name + '*.so'))[0].name os.rename(template_build_folder + os.path.sep + fname, pykeops.config.bin_folder + os.path.sep + dllname + os.path.sep + fname) print('done.', flush=True)