def getMetapathLoaderBodyCode(bytecode_accessor): metapath_loader_inittab = [] metapath_module_decls = [] for other_module in getDoneModules(): metapath_loader_inittab.append( getModuleMetapathLoaderEntryCode( module=other_module, bytecode_accessor=bytecode_accessor ) ) if other_module.isCompiledPythonModule(): metapath_module_decls.append( """\ extern PyObject *modulecode_%(module_identifier)s(PyObject *, struct Nuitka_MetaPathBasedLoaderEntry const *);""" % {"module_identifier": other_module.getCodeName()} ) for uncompiled_module in getUncompiledModules(): metapath_loader_inittab.append( getModuleMetapathLoaderEntryCode( module=uncompiled_module, bytecode_accessor=bytecode_accessor ) ) frozen_defs = [] for uncompiled_module in getUncompiledTechnicalModules(): module_name = uncompiled_module.getFullName() code_data = uncompiled_module.getByteCode() is_package = uncompiled_module.isUncompiledPythonPackage() size = len(code_data) # Packages are indicated with negative size. if is_package: size = -size accessor_code = bytecode_accessor.getBlobDataCode(code_data) frozen_defs.append( """\ {{"{module_name}", {start}, {size}}},""".format( module_name=module_name, start=accessor_code[accessor_code.find("[") + 1 : -1], size=size, ) ) if Options.isShowInclusion(): inclusion_logger.info("Embedded as frozen module '%s'." % module_name) return template_metapath_loader_body % { "metapath_module_decls": indented(metapath_module_decls, 0), "metapath_loader_inittab": indented(metapath_loader_inittab), "bytecode_count": bytecode_accessor.getConstantsCount(), "frozen_modules": indented(frozen_defs), }
def onModuleCompleteSet(): """The final set of modules is determined, this is only for inspection, cannot change.""" from nuitka.ModuleRegistry import getDoneModules # Make sure it's immutable. module_set = tuple(getDoneModules()) for plugin in getActivePlugins(): plugin.onModuleCompleteSet(module_set)
def writeCompilationReport(report_filename): active_modules_info = getModuleInclusionInfos() root = TreeXML.Element("nuitka-compilation-report") for module in getDoneModules(): active_module_info = active_modules_info[module] root.append( TreeXML.Element( "module", name=module.getFullName(), kind=module.__class__.__name__, reason=active_module_info.reason, )) putTextFileContents(filename=report_filename, contents=TreeXML.toString(root)) general.info("Compilation report in file %r." % report_filename)
def writeCompilationReport(report_filename): active_modules_info = getModuleInclusionInfos() root = TreeXML.Element("nuitka-compilation-report") for module in getDoneModules(): active_module_info = active_modules_info[module] root.append( TreeXML.Element( "module", name=module.getFullName(), kind=module.__class__.__name__, reason=active_module_info.reason, )) for included_datafile in getIncludedDataFiles(): if included_datafile.kind == "data_file": root.append( TreeXML.Element( "data_file", name=included_datafile.dest_path, source=included_datafile.source_path, reason=included_datafile.reason, tags=",".join(included_datafile.tags), )) elif included_datafile.kind == "data_blob": root.append( TreeXML.Element( "data_blob", name=included_datafile.dest_path, reason=included_datafile.reason, tags=",".join(included_datafile.tags), )) putTextFileContents(filename=report_filename, contents=TreeXML.toString(root)) general.info("Compilation report in file %r." % report_filename)
def endGraph(output_filename): if graph is not None: for module in getDoneModules(): _addModuleGraph(module, "final") graph.draw(output_filename + ".dot", prog="dot")