def getModuleMetapathLoaderEntryCode(module, bytecode_accessor): module_c_name = encodePythonStringToC( Plugins.encodeDataComposerName(module.getFullName().asString())) flags = ["NUITKA_TRANSLATED_FLAG"] if not Options.isStandaloneMode() and python_version >= 0x370: if Options.isWin32Windows(): file_path = encodePythonUnicodeToC(module.getCompileTimeFilename()) else: file_path = encodePythonStringToC( module.getCompileTimeFilename().encode( sys.getfilesystemencoding())) else: file_path = "NULL" if module.isUncompiledPythonModule(): code_data = module.getByteCode() is_package = module.isUncompiledPythonPackage() flags.append("NUITKA_BYTECODE_FLAG") if is_package: flags.append("NUITKA_PACKAGE_FLAG") accessor_code = bytecode_accessor.getBlobDataCode( data=code_data, name="bytecode of module '%s'" % module.getFullName().asString(), ) return template_metapath_loader_bytecode_module_entry % { "module_name": module_c_name, "bytecode": accessor_code[accessor_code.find("[") + 1:-1], "size": len(code_data), "flags": " | ".join(flags), "file_path": file_path, } elif module.isPythonExtensionModule(): flags.append("NUITKA_EXTENSION_MODULE_FLAG") return template_metapath_loader_extension_module_entry % { "module_name": module_c_name, "flags": " | ".join(flags), "file_path": file_path, } else: if module.isCompiledPythonPackage(): flags.append("NUITKA_PACKAGE_FLAG") return template_metapath_loader_compiled_module_entry % { "module_name": module_c_name, "module_identifier": module.getCodeName(), "flags": " | ".join(flags), "file_path": file_path, }
def getModuleMetapathLoaderEntryCode(module, bytecode_accessor): module_c_name = encodePythonStringToC( Plugins.encodeDataComposerName(module.getFullName().asString())) flags = ["NUITKA_TRANSLATED_FLAG"] if module.isUncompiledPythonModule(): code_data = module.getByteCode() is_package = module.isUncompiledPythonPackage() flags.append("NUITKA_BYTECODE_FLAG") if is_package: flags.append("NUITKA_PACKAGE_FLAG") accessor_code = bytecode_accessor.getBlobDataCode( data=code_data, name="bytecode of module '%s'" % module.getFullName().asString(), ) return template_metapath_loader_bytecode_module_entry % { "module_name": module_c_name, "bytecode": accessor_code[accessor_code.find("[") + 1:-1], "size": len(code_data), "flags": " | ".join(flags) or "0", } elif module.isPythonExtensionModule(): flags.append("NUITKA_EXTENSION_MODULE_FLAG") return template_metapath_loader_extension_module_entry % { "module_name": module_c_name, "flags": " | ".join(flags) or "0", } else: if module.isCompiledPythonPackage(): flags.append("NUITKA_PACKAGE_FLAG") return template_metapath_loader_compiled_module_entry % { "module_name": module_c_name, "module_identifier": module.getCodeName(), "flags": " | ".join(flags), }