MCPcopy
hub / github.com/Nuitka/Nuitka / getModuleMetaPathLoaderEntryCode

Function getModuleMetaPathLoaderEntryCode

nuitka/code_generation/LoaderCodes.py:57–128  ·  view source on GitHub ↗
(module, bytecode_accessor, name_index)

Source from the content-addressed store, hash-verified

55
56
57def getModuleMetaPathLoaderEntryCode(module, bytecode_accessor, name_index):
58 module_name = module.getFullName()
59
60 module_c_name = _getMetaPathLoaderNameCode(module_name.asString(), name_index)
61
62 # Value of compile_time_name defaults to NULL and is only present in module
63 # mode.
64 if shallMakeModule():
65 module_c_name += ", NULL"
66
67 flags = ["NUITKA_TRANSLATED_FLAG"]
68
69 if (
70 not isStandaloneMode()
71 and not shallMakeModule()
72 and getFileReferenceMode() == "original"
73 and python_version >= 0x370
74 ):
75 # File system paths that will hopefully work, spell-checker: ignore getfilesystemencoding
76 if isWin32Windows():
77 file_path = encodePythonUnicodeToC(module.getCompileTimeFilename())
78 else:
79 file_path = encodePythonStringToC(
80 module.getCompileTimeFilename().encode(sys.getfilesystemencoding())
81 )
82 else:
83 file_path = "NULL"
84
85 if hasNonDeploymentIndicator("perfect-support") and isPerfectSupported(module_name):
86 flags.append("NUITKA_PERFECT_SUPPORTED_FLAG")
87
88 if module.isUncompiledPythonModule():
89 code_data = module.getByteCode()
90 is_package = module.isUncompiledPythonPackage()
91
92 flags.append("NUITKA_BYTECODE_FLAG")
93 if is_package:
94 flags.append("NUITKA_PACKAGE_FLAG")
95
96 accessor_code = bytecode_accessor.getBlobDataCode(
97 data=code_data,
98 name="bytecode of module '%s'" % module.getFullName(),
99 )
100
101 return template_metapath_loader_bytecode_module_entry % {
102 "module_name": module_c_name,
103 "bytecode": accessor_code[accessor_code.find("[") + 1 : -1],
104 "size": len(code_data),
105 "flags": " | ".join(flags),
106 "file_path": file_path,
107 }
108 elif module.isPythonExtensionModule():
109 flags.append("NUITKA_EXTENSION_MODULE_FLAG")
110
111 if module.isExtensionModulePackage():
112 flags.append("NUITKA_PACKAGE_FLAG")
113
114 return template_metapath_loader_extension_module_entry % {

Callers 1

Calls 15

shallMakeModuleFunction · 0.90
isStandaloneModeFunction · 0.90
getFileReferenceModeFunction · 0.90
isWin32WindowsFunction · 0.90
encodePythonUnicodeToCFunction · 0.90
encodePythonStringToCFunction · 0.90
isPerfectSupportedFunction · 0.85
lenFunction · 0.85
getFullNameMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…