Demote a compiled module to uncompiled (bytecode).
(module)
| 35 | |
| 36 | |
| 37 | def demoteCompiledModuleToBytecode(module): |
| 38 | """Demote a compiled module to uncompiled (bytecode).""" |
| 39 | |
| 40 | full_name = module.getFullName() |
| 41 | filename = module.getCompileTimeFilename() |
| 42 | |
| 43 | if isShowProgress(): |
| 44 | inclusion_logger.info( |
| 45 | "Demoting module '%s' to bytecode from '%s'." |
| 46 | % (full_name.asString(), filename) |
| 47 | ) |
| 48 | |
| 49 | source_code = module.getSourceCode() |
| 50 | |
| 51 | bytecode = demoteSourceCodeToBytecode( |
| 52 | module_name=full_name, source_code=source_code, filename=filename |
| 53 | ) |
| 54 | |
| 55 | uncompiled_module = makeUncompiledPythonModule( |
| 56 | module_name=full_name, |
| 57 | reason=module.reason, |
| 58 | filename=getNormalizedPath(filename), |
| 59 | bytecode=bytecode, |
| 60 | is_package=module.isCompiledPythonPackage(), |
| 61 | technical=full_name in detectEarlyImports(), |
| 62 | ) |
| 63 | |
| 64 | used_modules = module.getUsedModules() |
| 65 | uncompiled_module.setUsedModules(used_modules) |
| 66 | |
| 67 | distribution_names = module.getUsedDistributions() |
| 68 | uncompiled_module.setUsedDistributions(distribution_names) |
| 69 | |
| 70 | module.finalize() |
| 71 | |
| 72 | if isImportedModuleByName(full_name): |
| 73 | replaceImportedModule(old=module, new=uncompiled_module) |
| 74 | replaceRootModule(old=module, new=uncompiled_module) |
| 75 | |
| 76 | if isTriggerModule(module): |
| 77 | replaceTriggerModule(old=module, new=uncompiled_module) |
| 78 | |
| 79 | writeImportedModulesNamesToCache( |
| 80 | module_name=full_name, |
| 81 | source_code=source_code, |
| 82 | used_modules=used_modules, |
| 83 | distribution_names=distribution_names, |
| 84 | ) |
| 85 | |
| 86 | |
| 87 | # Part of "Nuitka", an optimizing Python compiler that is compatible and |
no test coverage detected
searching dependent graphs…