예제 #1
0
def generateBytecodeFrozenCode():
    frozen_defs = []

    for uncompiled_module in getUncompiledModules():
        module_name = uncompiled_module.getFullName()
        code_data = uncompiled_module.getByteCode()
        is_package = uncompiled_module.isPackage()

        size = len(code_data)

        # Packages are indicated with negative size.
        if is_package:
            size = -size

        frozen_defs.append(
            """\
{{ (char *)"{module_name}", (unsigned char *){data}, {size} }},""".format(
                module_name = module_name,
                data        = stream_data.getStreamDataCode(
                    value      = code_data,
                    fixed_size = True
                ),
                size        = size
            )
        )

        if Options.isShowInclusion():
            info("Embedded as frozen module '%s'.", module_name)

    return template_frozen_modules % {
        "frozen_modules" : indented(frozen_defs, 2)
    }
예제 #2
0
def generateBytecodeFrozenCode():
    frozen_defs = []

    for uncompiled_module in getUncompiledModules():
        module_name = uncompiled_module.getFullName()
        code_data = uncompiled_module.getByteCode()
        is_package = uncompiled_module.isPackage()

        size = len(code_data)

        # Packages are indicated with negative size.
        if is_package:
            size = -size

        frozen_defs.append("""\
{{ (char *)"{module_name}", (unsigned char *){data}, {size} }},""".format(
            module_name=module_name,
            data=stream_data.getStreamDataCode(value=code_data,
                                               fixed_size=True),
            size=size))

        if Options.isShowInclusion():
            info("Embedded as frozen module '%s'.", module_name)

    return template_frozen_modules % {
        "frozen_modules": indented(frozen_defs, 2)
    }
예제 #3
0
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),
    }
예제 #4
0
def getMetapathLoaderBodyCode(other_modules):
    metapath_loader_inittab = []
    metapath_module_decls = []

    for other_module in other_modules:
        metapath_loader_inittab.append(
            getModuleMetapathLoaderEntryCode(module=other_module))

        if other_module.isCompiledPythonModule():
            metapath_module_decls.append(
                "extern PyObject *modulecode_%(module_identifier)s(PyObject *);"
                % {"module_identifier": other_module.getCodeName()})

    for uncompiled_module in getUncompiledModules():
        metapath_loader_inittab.append(
            getModuleMetapathLoaderEntryCode(module=uncompiled_module))

    return template_metapath_loader_body % {
        "metapath_module_decls": indented(metapath_module_decls, 0),
        "metapath_loader_inittab": indented(metapath_loader_inittab),
    }