diff --git a/Makefile.pre.in b/Makefile.pre.in index 27a26c225230b4e..af19515bbadc670 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1108,6 +1108,11 @@ FROZEN_FILES_IN = \ Lib/zipimport.py \ Lib/abc.py \ Lib/codecs.py \ + Lib/encodings/__init__.py \ + Lib/encodings/aliases.py \ + Lib/encodings/ascii.py \ + Lib/encodings/latin_1.py \ + Lib/encodings/utf_8.py \ Lib/io.py \ Lib/_collections_abc.py \ Lib/_sitebuiltins.py \ @@ -1133,6 +1138,11 @@ FROZEN_FILES_OUT = \ Python/frozen_modules/zipimport.h \ Python/frozen_modules/abc.h \ Python/frozen_modules/codecs.h \ + Python/frozen_modules/encodings.h \ + Python/frozen_modules/encodings.aliases.h \ + Python/frozen_modules/encodings.ascii.h \ + Python/frozen_modules/encodings.latin_1.h \ + Python/frozen_modules/encodings.utf_8.h \ Python/frozen_modules/io.h \ Python/frozen_modules/_collections_abc.h \ Python/frozen_modules/_sitebuiltins.h \ @@ -1181,6 +1191,21 @@ Python/frozen_modules/abc.h: Lib/abc.py $(FREEZE_MODULE_DEPS) Python/frozen_modules/codecs.h: Lib/codecs.py $(FREEZE_MODULE_DEPS) $(FREEZE_MODULE) codecs $(srcdir)/Lib/codecs.py Python/frozen_modules/codecs.h +Python/frozen_modules/encodings.h: Lib/encodings/__init__.py $(FREEZE_MODULE_DEPS) + $(FREEZE_MODULE) encodings $(srcdir)/Lib/encodings/__init__.py Python/frozen_modules/encodings.h + +Python/frozen_modules/encodings.aliases.h: Lib/encodings/aliases.py $(FREEZE_MODULE_DEPS) + $(FREEZE_MODULE) encodings.aliases $(srcdir)/Lib/encodings/aliases.py Python/frozen_modules/encodings.aliases.h + +Python/frozen_modules/encodings.ascii.h: Lib/encodings/ascii.py $(FREEZE_MODULE_DEPS) + $(FREEZE_MODULE) encodings.ascii $(srcdir)/Lib/encodings/ascii.py Python/frozen_modules/encodings.ascii.h + +Python/frozen_modules/encodings.latin_1.h: Lib/encodings/latin_1.py $(FREEZE_MODULE_DEPS) + $(FREEZE_MODULE) encodings.latin_1 $(srcdir)/Lib/encodings/latin_1.py Python/frozen_modules/encodings.latin_1.h + +Python/frozen_modules/encodings.utf_8.h: Lib/encodings/utf_8.py $(FREEZE_MODULE_DEPS) + $(FREEZE_MODULE) encodings.utf_8 $(srcdir)/Lib/encodings/utf_8.py Python/frozen_modules/encodings.utf_8.h + Python/frozen_modules/io.h: Lib/io.py $(FREEZE_MODULE_DEPS) $(FREEZE_MODULE) io $(srcdir)/Lib/io.py Python/frozen_modules/io.h @@ -1260,6 +1285,11 @@ $(DEEPFREEZE_C): $(DEEPFREEZE_DEPS) Python/frozen_modules/zipimport.h:zipimport \ Python/frozen_modules/abc.h:abc \ Python/frozen_modules/codecs.h:codecs \ + Python/frozen_modules/encodings.h:encodings \ + Python/frozen_modules/encodings.aliases.h:encodings.aliases \ + Python/frozen_modules/encodings.ascii.h:encodings.ascii \ + Python/frozen_modules/encodings.latin_1.h:encodings.latin_1 \ + Python/frozen_modules/encodings.utf_8.h:encodings.utf_8 \ Python/frozen_modules/io.h:io \ Python/frozen_modules/_collections_abc.h:_collections_abc \ Python/frozen_modules/_sitebuiltins.h:_sitebuiltins \ diff --git a/PCbuild/_freeze_module.vcxproj b/PCbuild/_freeze_module.vcxproj index 3df0a072045208a..938d06ca9790905 100644 --- a/PCbuild/_freeze_module.vcxproj +++ b/PCbuild/_freeze_module.vcxproj @@ -271,6 +271,31 @@ $(IntDir)codecs.g.h $(PySourcePath)Python\frozen_modules\codecs.h + + encodings + $(IntDir)encodings.g.h + $(PySourcePath)Python\frozen_modules\encodings.h + + + encodings.aliases + $(IntDir)encodings.aliases.g.h + $(PySourcePath)Python\frozen_modules\encodings.aliases.h + + + encodings.ascii + $(IntDir)encodings.ascii.g.h + $(PySourcePath)Python\frozen_modules\encodings.ascii.h + + + encodings.latin_1 + $(IntDir)encodings.latin_1.g.h + $(PySourcePath)Python\frozen_modules\encodings.latin_1.h + + + encodings.utf_8 + $(IntDir)encodings.utf_8.g.h + $(PySourcePath)Python\frozen_modules\encodings.utf_8.h + io $(IntDir)io.g.h @@ -409,6 +434,11 @@ "$(PySourcePath)Python\frozen_modules\zipimport.h:zipimport" ^ "$(PySourcePath)Python\frozen_modules\abc.h:abc" ^ "$(PySourcePath)Python\frozen_modules\codecs.h:codecs" ^ + "$(PySourcePath)Python\frozen_modules\encodings.h:encodings" ^ + "$(PySourcePath)Python\frozen_modules\encodings.aliases.h:encodings.aliases" ^ + "$(PySourcePath)Python\frozen_modules\encodings.ascii.h:encodings.ascii" ^ + "$(PySourcePath)Python\frozen_modules\encodings.latin_1.h:encodings.latin_1" ^ + "$(PySourcePath)Python\frozen_modules\encodings.utf_8.h:encodings.utf_8" ^ "$(PySourcePath)Python\frozen_modules\io.h:io" ^ "$(PySourcePath)Python\frozen_modules\_collections_abc.h:_collections_abc" ^ "$(PySourcePath)Python\frozen_modules\_sitebuiltins.h:_sitebuiltins" ^ diff --git a/PCbuild/_freeze_module.vcxproj.filters b/PCbuild/_freeze_module.vcxproj.filters index d98a4c5ae4e2bbb..9112067a093455b 100644 --- a/PCbuild/_freeze_module.vcxproj.filters +++ b/PCbuild/_freeze_module.vcxproj.filters @@ -444,6 +444,21 @@ Python Files + + Python Files + + + Python Files + + + Python Files + + + Python Files + + + Python Files + Python Files diff --git a/Python/frozen.c b/Python/frozen.c index f8e0b8b065a2203..667e6f422a9422e 100644 --- a/Python/frozen.c +++ b/Python/frozen.c @@ -46,6 +46,11 @@ #include "frozen_modules/zipimport.h" #include "frozen_modules/abc.h" #include "frozen_modules/codecs.h" +#include "frozen_modules/encodings.h" +#include "frozen_modules/encodings.aliases.h" +#include "frozen_modules/encodings.ascii.h" +#include "frozen_modules/encodings.latin_1.h" +#include "frozen_modules/encodings.utf_8.h" #include "frozen_modules/io.h" #include "frozen_modules/_collections_abc.h" #include "frozen_modules/_sitebuiltins.h" @@ -74,6 +79,11 @@ extern PyObject *_Py_get_importlib__bootstrap_external_toplevel(void); extern PyObject *_Py_get_zipimport_toplevel(void); extern PyObject *_Py_get_abc_toplevel(void); extern PyObject *_Py_get_codecs_toplevel(void); +extern PyObject *_Py_get_encodings_toplevel(void); +extern PyObject *_Py_get_encodings_aliases_toplevel(void); +extern PyObject *_Py_get_encodings_ascii_toplevel(void); +extern PyObject *_Py_get_encodings_latin_1_toplevel(void); +extern PyObject *_Py_get_encodings_utf_8_toplevel(void); extern PyObject *_Py_get_io_toplevel(void); extern PyObject *_Py_get__collections_abc_toplevel(void); extern PyObject *_Py_get__sitebuiltins_toplevel(void); @@ -104,6 +114,11 @@ 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)}, + {"encodings", _Py_M__encodings, (int)sizeof(_Py_M__encodings), true, GET_CODE(encodings)}, + {"encodings.aliases", _Py_M__encodings_aliases, (int)sizeof(_Py_M__encodings_aliases), false, GET_CODE(encodings_aliases)}, + {"encodings.ascii", _Py_M__encodings_ascii, (int)sizeof(_Py_M__encodings_ascii), false, GET_CODE(encodings_ascii)}, + {"encodings.latin_1", _Py_M__encodings_latin_1, (int)sizeof(_Py_M__encodings_latin_1), false, GET_CODE(encodings_latin_1)}, + {"encodings.utf_8", _Py_M__encodings_utf_8, (int)sizeof(_Py_M__encodings_utf_8), false, GET_CODE(encodings_utf_8)}, {"io", _Py_M__io, (int)sizeof(_Py_M__io), false, GET_CODE(io)}, /* stdlib - startup, with site */ diff --git a/Tools/build/freeze_modules.py b/Tools/build/freeze_modules.py index 5e3bd1f614713e8..707de12dbb9e300 100644 --- a/Tools/build/freeze_modules.py +++ b/Tools/build/freeze_modules.py @@ -52,10 +52,14 @@ ('stdlib - startup, without site (python -S)', [ 'abc', 'codecs', - # For now we do not freeze the encodings, due # to the noise all - # those extra modules add to the text printed during the build. - # (See https://github.com/python/cpython/pull/28398#pullrequestreview-756856469.) - #'', + # Freeze the encodings package and the codecs imported during every + # interpreter start-up. This eliminates filesystem I/O that is + # prohibitively slow on Nanvix ramfs/microvm. + '', + 'encodings.aliases', + 'encodings.ascii', + 'encodings.latin_1', + 'encodings.utf_8', 'io', ]), ('stdlib - startup, with site', [