/* End extern declarations */
static const struct _frozen bootstrap_modules[] = {
- {"_frozen_importlib", _Py_M__importlib__bootstrap, (int)sizeof(_Py_M__importlib__bootstrap), false, GET_CODE(importlib__bootstrap)},
- {"_frozen_importlib_external", _Py_M__importlib__bootstrap_external, (int)sizeof(_Py_M__importlib__bootstrap_external), false, GET_CODE(importlib__bootstrap_external)},
- {"zipimport", _Py_M__zipimport, (int)sizeof(_Py_M__zipimport), false, GET_CODE(zipimport)},
+ {"_frozen_importlib", _Py_M__importlib__bootstrap, (int)sizeof(_Py_M__importlib__bootstrap), false},
+ {"_frozen_importlib_external", _Py_M__importlib__bootstrap_external, (int)sizeof(_Py_M__importlib__bootstrap_external), false},
+ {"zipimport", _Py_M__zipimport, (int)sizeof(_Py_M__zipimport), false},
{0, 0, 0} /* bootstrap sentinel */
};
static const struct _frozen stdlib_modules[] = {
/* stdlib - startup, without site (python -S) */
- {"abc", _Py_M__abc, (int)sizeof(_Py_M__abc), false, GET_CODE(abc)},
- {"codecs", _Py_M__codecs, (int)sizeof(_Py_M__codecs), false, GET_CODE(codecs)},
- {"io", _Py_M__io, (int)sizeof(_Py_M__io), false, GET_CODE(io)},
+ {"abc", _Py_M__abc, (int)sizeof(_Py_M__abc), false},
+ {"codecs", _Py_M__codecs, (int)sizeof(_Py_M__codecs), false},
+ {"io", _Py_M__io, (int)sizeof(_Py_M__io), false},
/* stdlib - startup, with site */
- {"_collections_abc", _Py_M___collections_abc, (int)sizeof(_Py_M___collections_abc), false, GET_CODE(_collections_abc)},
- {"_sitebuiltins", _Py_M___sitebuiltins, (int)sizeof(_Py_M___sitebuiltins), false, GET_CODE(_sitebuiltins)},
- {"genericpath", _Py_M__genericpath, (int)sizeof(_Py_M__genericpath), false, GET_CODE(genericpath)},
- {"ntpath", _Py_M__ntpath, (int)sizeof(_Py_M__ntpath), false, GET_CODE(ntpath)},
- {"posixpath", _Py_M__posixpath, (int)sizeof(_Py_M__posixpath), false, GET_CODE(posixpath)},
- {"os.path", _Py_M__posixpath, (int)sizeof(_Py_M__posixpath), false, GET_CODE(posixpath)},
- {"os", _Py_M__os, (int)sizeof(_Py_M__os), false, GET_CODE(os)},
- {"site", _Py_M__site, (int)sizeof(_Py_M__site), false, GET_CODE(site)},
- {"stat", _Py_M__stat, (int)sizeof(_Py_M__stat), false, GET_CODE(stat)},
+ {"_collections_abc", _Py_M___collections_abc, (int)sizeof(_Py_M___collections_abc), false},
+ {"_sitebuiltins", _Py_M___sitebuiltins, (int)sizeof(_Py_M___sitebuiltins), false},
+ {"genericpath", _Py_M__genericpath, (int)sizeof(_Py_M__genericpath), false},
+ {"ntpath", _Py_M__ntpath, (int)sizeof(_Py_M__ntpath), false},
+ {"posixpath", _Py_M__posixpath, (int)sizeof(_Py_M__posixpath), false},
+ {"os.path", _Py_M__posixpath, (int)sizeof(_Py_M__posixpath), false},
+ {"os", _Py_M__os, (int)sizeof(_Py_M__os), false},
+ {"site", _Py_M__site, (int)sizeof(_Py_M__site), false},
+ {"stat", _Py_M__stat, (int)sizeof(_Py_M__stat), false},
/* runpy - run module with -m */
- {"importlib.util", _Py_M__importlib_util, (int)sizeof(_Py_M__importlib_util), false, GET_CODE(importlib_util)},
- {"importlib.machinery", _Py_M__importlib_machinery, (int)sizeof(_Py_M__importlib_machinery), false, GET_CODE(importlib_machinery)},
- {"runpy", _Py_M__runpy, (int)sizeof(_Py_M__runpy), false, GET_CODE(runpy)},
+ {"importlib.util", _Py_M__importlib_util, (int)sizeof(_Py_M__importlib_util), false},
+ {"importlib.machinery", _Py_M__importlib_machinery, (int)sizeof(_Py_M__importlib_machinery), false},
+ {"runpy", _Py_M__runpy, (int)sizeof(_Py_M__runpy), false},
{0, 0, 0} /* stdlib sentinel */
};
static const struct _frozen test_modules[] = {
- {"__hello__", _Py_M____hello__, (int)sizeof(_Py_M____hello__), false, GET_CODE(__hello__)},
- {"__hello_alias__", _Py_M____hello__, (int)sizeof(_Py_M____hello__), false, GET_CODE(__hello__)},
- {"__phello_alias__", _Py_M____hello__, (int)sizeof(_Py_M____hello__), true, GET_CODE(__hello__)},
- {"__phello_alias__.spam", _Py_M____hello__, (int)sizeof(_Py_M____hello__), false, GET_CODE(__hello__)},
- {"__phello__", _Py_M____phello__, (int)sizeof(_Py_M____phello__), true, GET_CODE(__phello__)},
- {"__phello__.__init__", _Py_M____phello__, (int)sizeof(_Py_M____phello__), false, GET_CODE(__phello__)},
- {"__phello__.ham", _Py_M____phello___ham, (int)sizeof(_Py_M____phello___ham), true, GET_CODE(__phello___ham)},
- {"__phello__.ham.__init__", _Py_M____phello___ham, (int)sizeof(_Py_M____phello___ham), false, GET_CODE(__phello___ham)},
- {"__phello__.ham.eggs", _Py_M____phello___ham_eggs, (int)sizeof(_Py_M____phello___ham_eggs), false, GET_CODE(__phello___ham_eggs)},
- {"__phello__.spam", _Py_M____phello___spam, (int)sizeof(_Py_M____phello___spam), false, GET_CODE(__phello___spam)},
- {"__hello_only__", _Py_M__frozen_only, (int)sizeof(_Py_M__frozen_only), false, GET_CODE(frozen_only)},
+ {"__hello__", _Py_M____hello__, (int)sizeof(_Py_M____hello__), false},
+ {"__hello_alias__", _Py_M____hello__, (int)sizeof(_Py_M____hello__), false},
+ {"__phello_alias__", _Py_M____hello__, (int)sizeof(_Py_M____hello__), true},
+ {"__phello_alias__.spam", _Py_M____hello__, (int)sizeof(_Py_M____hello__), false},
+ {"__phello__", _Py_M____phello__, (int)sizeof(_Py_M____phello__), true},
+ {"__phello__.__init__", _Py_M____phello__, (int)sizeof(_Py_M____phello__), false},
+ {"__phello__.ham", _Py_M____phello___ham, (int)sizeof(_Py_M____phello___ham), true},
+ {"__phello__.ham.__init__", _Py_M____phello___ham, (int)sizeof(_Py_M____phello___ham), false},
+ {"__phello__.ham.eggs", _Py_M____phello___ham_eggs, (int)sizeof(_Py_M____phello___ham_eggs), false},
+ {"__phello__.spam", _Py_M____phello___spam, (int)sizeof(_Py_M____phello___spam), false},
+ {"__hello_only__", _Py_M__frozen_only, (int)sizeof(_Py_M__frozen_only), false},
{0, 0, 0} /* test sentinel */
};
const struct _frozen *_PyImport_FrozenBootstrap = bootstrap_modules;
return lines[:start_pos + 1] + replacements + lines[end_pos:]
-def regen_frozen(modules, frozen_modules: bool):
+def regen_frozen(modules):
headerlines = []
parentdir = os.path.dirname(FROZEN_FILE)
- if frozen_modules:
- for src in _iter_sources(modules):
- # Adding a comment to separate sections here doesn't add much,
- # so we don't.
- header = relpath_for_posix_display(src.frozenfile, parentdir)
- headerlines.append(f'#include "{header}"')
+ for src in _iter_sources(modules):
+ # Adding a comment to separate sections here doesn't add much,
+ # so we don't.
+ header = relpath_for_posix_display(src.frozenfile, parentdir)
+ headerlines.append(f'#include "{header}"')
externlines = []
bootstraplines = []
get_code_name = "_Py_get_%s_toplevel" % code_name
externlines.append("extern PyObject *%s(void);" % get_code_name)
- symbol = mod.symbol
pkg = 'true' if mod.ispkg else 'false'
- if not frozen_modules:
- line = ('{"%s", NULL, 0, %s, GET_CODE(%s)},'
- ) % (mod.name, pkg, code_name)
- else:
- line = ('{"%s", %s, (int)sizeof(%s), %s, GET_CODE(%s)},'
- ) % (mod.name, symbol, symbol, pkg, code_name)
+ size = f"(int)sizeof({mod.symbol})"
+ line = f'{{"{mod.name}", {mod.symbol}, {size}, {pkg}}},'
lines.append(line)
if mod.isalias:
#######################################
# the script
-parser = argparse.ArgumentParser()
-parser.add_argument("--frozen-modules", action="store_true",
- help="Use both frozen and deepfrozen modules. (default: uses only deepfrozen modules)")
-
def main():
- args = parser.parse_args()
- frozen_modules: bool = args.frozen_modules
# Expand the raw specs, preserving order.
modules = list(parse_frozen_specs())
# Regen build-related files.
regen_makefile(modules)
regen_pcbuild(modules)
- regen_frozen(modules, frozen_modules)
+ regen_frozen(modules)
if __name__ == '__main__':