Skip to content

Commit 295eed5

Browse files
committed
Stop freezing a bunch of unnecessary modules.
Python 3.11 now wants to embed the bytecode of a bunch of modules notably a bunch of useless test modules.
1 parent efc093a commit 295eed5

File tree

2 files changed

+4
-193
lines changed

2 files changed

+4
-193
lines changed

Makefile.pre.in

Lines changed: 4 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,53 +1010,11 @@ _bootstrap_python: $(LIBRARY_OBJS_OMIT_FROZEN) Programs/_bootstrap_python.o Modu
10101010
# FROZEN_FILES_* are auto-generated by Tools/scripts/freeze_modules.py.
10111011
FROZEN_FILES_IN = \
10121012
Lib/importlib/_bootstrap.py \
1013-
Lib/importlib/_bootstrap_external.py \
1014-
Lib/zipimport.py \
1015-
Lib/abc.py \
1016-
Lib/codecs.py \
1017-
Lib/io.py \
1018-
Lib/_collections_abc.py \
1019-
Lib/_sitebuiltins.py \
1020-
Lib/genericpath.py \
1021-
Lib/ntpath.py \
1022-
Lib/posixpath.py \
1023-
Lib/os.py \
1024-
Lib/site.py \
1025-
Lib/stat.py \
1026-
Lib/importlib/util.py \
1027-
Lib/importlib/machinery.py \
1028-
Lib/runpy.py \
1029-
Lib/__hello__.py \
1030-
Lib/__phello__/__init__.py \
1031-
Lib/__phello__/ham/__init__.py \
1032-
Lib/__phello__/ham/eggs.py \
1033-
Lib/__phello__/spam.py \
1034-
Tools/freeze/flag.py
1013+
Lib/importlib/_bootstrap_external.py
10351014
# End FROZEN_FILES_IN
10361015
FROZEN_FILES_OUT = \
10371016
Python/frozen_modules/importlib._bootstrap.h \
1038-
Python/frozen_modules/importlib._bootstrap_external.h \
1039-
Python/frozen_modules/zipimport.h \
1040-
Python/frozen_modules/abc.h \
1041-
Python/frozen_modules/codecs.h \
1042-
Python/frozen_modules/io.h \
1043-
Python/frozen_modules/_collections_abc.h \
1044-
Python/frozen_modules/_sitebuiltins.h \
1045-
Python/frozen_modules/genericpath.h \
1046-
Python/frozen_modules/ntpath.h \
1047-
Python/frozen_modules/posixpath.h \
1048-
Python/frozen_modules/os.h \
1049-
Python/frozen_modules/site.h \
1050-
Python/frozen_modules/stat.h \
1051-
Python/frozen_modules/importlib.util.h \
1052-
Python/frozen_modules/importlib.machinery.h \
1053-
Python/frozen_modules/runpy.h \
1054-
Python/frozen_modules/__hello__.h \
1055-
Python/frozen_modules/__phello__.h \
1056-
Python/frozen_modules/__phello__.ham.h \
1057-
Python/frozen_modules/__phello__.ham.eggs.h \
1058-
Python/frozen_modules/__phello__.spam.h \
1059-
Python/frozen_modules/frozen_only.h
1017+
Python/frozen_modules/importlib._bootstrap_external.h
10601018
# End FROZEN_FILES_OUT
10611019

10621020
Programs/_freeze_module.o: Programs/_freeze_module.c Makefile
@@ -1078,69 +1036,8 @@ Python/frozen_modules/importlib._bootstrap.h: Lib/importlib/_bootstrap.py $(FREE
10781036
Python/frozen_modules/importlib._bootstrap_external.h: Lib/importlib/_bootstrap_external.py $(FREEZE_MODULE_BOOTSTRAP_DEPS)
10791037
$(FREEZE_MODULE_BOOTSTRAP) importlib._bootstrap_external $(srcdir)/Lib/importlib/_bootstrap_external.py Python/frozen_modules/importlib._bootstrap_external.h
10801038

1081-
Python/frozen_modules/zipimport.h: Lib/zipimport.py $(FREEZE_MODULE_BOOTSTRAP_DEPS)
1082-
$(FREEZE_MODULE_BOOTSTRAP) zipimport $(srcdir)/Lib/zipimport.py Python/frozen_modules/zipimport.h
1083-
1084-
Python/frozen_modules/abc.h: Lib/abc.py $(FREEZE_MODULE_DEPS)
1085-
$(FREEZE_MODULE) abc $(srcdir)/Lib/abc.py Python/frozen_modules/abc.h
1086-
1087-
Python/frozen_modules/codecs.h: Lib/codecs.py $(FREEZE_MODULE_DEPS)
1088-
$(FREEZE_MODULE) codecs $(srcdir)/Lib/codecs.py Python/frozen_modules/codecs.h
1089-
1090-
Python/frozen_modules/io.h: Lib/io.py $(FREEZE_MODULE_DEPS)
1091-
$(FREEZE_MODULE) io $(srcdir)/Lib/io.py Python/frozen_modules/io.h
1092-
1093-
Python/frozen_modules/_collections_abc.h: Lib/_collections_abc.py $(FREEZE_MODULE_DEPS)
1094-
$(FREEZE_MODULE) _collections_abc $(srcdir)/Lib/_collections_abc.py Python/frozen_modules/_collections_abc.h
1095-
1096-
Python/frozen_modules/_sitebuiltins.h: Lib/_sitebuiltins.py $(FREEZE_MODULE_DEPS)
1097-
$(FREEZE_MODULE) _sitebuiltins $(srcdir)/Lib/_sitebuiltins.py Python/frozen_modules/_sitebuiltins.h
1098-
1099-
Python/frozen_modules/genericpath.h: Lib/genericpath.py $(FREEZE_MODULE_DEPS)
1100-
$(FREEZE_MODULE) genericpath $(srcdir)/Lib/genericpath.py Python/frozen_modules/genericpath.h
1101-
1102-
Python/frozen_modules/ntpath.h: Lib/ntpath.py $(FREEZE_MODULE_DEPS)
1103-
$(FREEZE_MODULE) ntpath $(srcdir)/Lib/ntpath.py Python/frozen_modules/ntpath.h
1104-
1105-
Python/frozen_modules/posixpath.h: Lib/posixpath.py $(FREEZE_MODULE_DEPS)
1106-
$(FREEZE_MODULE) posixpath $(srcdir)/Lib/posixpath.py Python/frozen_modules/posixpath.h
1107-
1108-
Python/frozen_modules/os.h: Lib/os.py $(FREEZE_MODULE_DEPS)
1109-
$(FREEZE_MODULE) os $(srcdir)/Lib/os.py Python/frozen_modules/os.h
1110-
1111-
Python/frozen_modules/site.h: Lib/site.py $(FREEZE_MODULE_DEPS)
1112-
$(FREEZE_MODULE) site $(srcdir)/Lib/site.py Python/frozen_modules/site.h
1113-
1114-
Python/frozen_modules/stat.h: Lib/stat.py $(FREEZE_MODULE_DEPS)
1115-
$(FREEZE_MODULE) stat $(srcdir)/Lib/stat.py Python/frozen_modules/stat.h
1116-
1117-
Python/frozen_modules/importlib.util.h: Lib/importlib/util.py $(FREEZE_MODULE_DEPS)
1118-
$(FREEZE_MODULE) importlib.util $(srcdir)/Lib/importlib/util.py Python/frozen_modules/importlib.util.h
1119-
1120-
Python/frozen_modules/importlib.machinery.h: Lib/importlib/machinery.py $(FREEZE_MODULE_DEPS)
1121-
$(FREEZE_MODULE) importlib.machinery $(srcdir)/Lib/importlib/machinery.py Python/frozen_modules/importlib.machinery.h
1122-
1123-
Python/frozen_modules/runpy.h: Lib/runpy.py $(FREEZE_MODULE_DEPS)
1124-
$(FREEZE_MODULE) runpy $(srcdir)/Lib/runpy.py Python/frozen_modules/runpy.h
1125-
1126-
Python/frozen_modules/__hello__.h: Lib/__hello__.py $(FREEZE_MODULE_DEPS)
1127-
$(FREEZE_MODULE) __hello__ $(srcdir)/Lib/__hello__.py Python/frozen_modules/__hello__.h
1128-
1129-
Python/frozen_modules/__phello__.h: Lib/__phello__/__init__.py $(FREEZE_MODULE_DEPS)
1130-
$(FREEZE_MODULE) __phello__ $(srcdir)/Lib/__phello__/__init__.py Python/frozen_modules/__phello__.h
1131-
1132-
Python/frozen_modules/__phello__.ham.h: Lib/__phello__/ham/__init__.py $(FREEZE_MODULE_DEPS)
1133-
$(FREEZE_MODULE) __phello__.ham $(srcdir)/Lib/__phello__/ham/__init__.py Python/frozen_modules/__phello__.ham.h
1134-
1135-
Python/frozen_modules/__phello__.ham.eggs.h: Lib/__phello__/ham/eggs.py $(FREEZE_MODULE_DEPS)
1136-
$(FREEZE_MODULE) __phello__.ham.eggs $(srcdir)/Lib/__phello__/ham/eggs.py Python/frozen_modules/__phello__.ham.eggs.h
1137-
1138-
Python/frozen_modules/__phello__.spam.h: Lib/__phello__/spam.py $(FREEZE_MODULE_DEPS)
1139-
$(FREEZE_MODULE) __phello__.spam $(srcdir)/Lib/__phello__/spam.py Python/frozen_modules/__phello__.spam.h
1140-
1141-
Python/frozen_modules/frozen_only.h: Tools/freeze/flag.py $(FREEZE_MODULE_DEPS)
1142-
$(FREEZE_MODULE) frozen_only $(srcdir)/Tools/freeze/flag.py Python/frozen_modules/frozen_only.h
1143-
1039+
# We do not freeze modules in Nuitka-Python to avoid contaminating the binary with
1040+
# useless bytecode. Only leave the minimally required modules.
11441041
# END: freezing modules
11451042

11461043
Tools/scripts/freeze_modules.py: $(FREEZE_MODULE)
@@ -1163,27 +1060,6 @@ $(DEEPFREEZE_C): $(DEEPFREEZE_DEPS)
11631060
$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py \
11641061
Python/frozen_modules/importlib._bootstrap.h:importlib._bootstrap \
11651062
Python/frozen_modules/importlib._bootstrap_external.h:importlib._bootstrap_external \
1166-
Python/frozen_modules/zipimport.h:zipimport \
1167-
Python/frozen_modules/abc.h:abc \
1168-
Python/frozen_modules/codecs.h:codecs \
1169-
Python/frozen_modules/io.h:io \
1170-
Python/frozen_modules/_collections_abc.h:_collections_abc \
1171-
Python/frozen_modules/_sitebuiltins.h:_sitebuiltins \
1172-
Python/frozen_modules/genericpath.h:genericpath \
1173-
Python/frozen_modules/ntpath.h:ntpath \
1174-
Python/frozen_modules/posixpath.h:posixpath \
1175-
Python/frozen_modules/os.h:os \
1176-
Python/frozen_modules/site.h:site \
1177-
Python/frozen_modules/stat.h:stat \
1178-
Python/frozen_modules/importlib.util.h:importlib.util \
1179-
Python/frozen_modules/importlib.machinery.h:importlib.machinery \
1180-
Python/frozen_modules/runpy.h:runpy \
1181-
Python/frozen_modules/__hello__.h:__hello__ \
1182-
Python/frozen_modules/__phello__.h:__phello__ \
1183-
Python/frozen_modules/__phello__.ham.h:__phello__.ham \
1184-
Python/frozen_modules/__phello__.ham.eggs.h:__phello__.ham.eggs \
1185-
Python/frozen_modules/__phello__.spam.h:__phello__.spam \
1186-
Python/frozen_modules/frozen_only.h:frozen_only \
11871063
-o Python/deepfreeze/deepfreeze.c
11881064
# END: deepfreeze modules
11891065

Python/frozen.c

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -48,76 +48,17 @@
4848
/* Start extern declarations */
4949
extern PyObject *_Py_get_importlib__bootstrap_toplevel(void);
5050
extern PyObject *_Py_get_importlib__bootstrap_external_toplevel(void);
51-
extern PyObject *_Py_get_zipimport_toplevel(void);
52-
extern PyObject *_Py_get_abc_toplevel(void);
53-
extern PyObject *_Py_get_codecs_toplevel(void);
54-
extern PyObject *_Py_get_io_toplevel(void);
55-
extern PyObject *_Py_get__collections_abc_toplevel(void);
56-
extern PyObject *_Py_get__sitebuiltins_toplevel(void);
57-
extern PyObject *_Py_get_genericpath_toplevel(void);
58-
extern PyObject *_Py_get_ntpath_toplevel(void);
59-
extern PyObject *_Py_get_posixpath_toplevel(void);
60-
extern PyObject *_Py_get_posixpath_toplevel(void);
61-
extern PyObject *_Py_get_os_toplevel(void);
62-
extern PyObject *_Py_get_site_toplevel(void);
63-
extern PyObject *_Py_get_stat_toplevel(void);
64-
extern PyObject *_Py_get_importlib_util_toplevel(void);
65-
extern PyObject *_Py_get_importlib_machinery_toplevel(void);
66-
extern PyObject *_Py_get_runpy_toplevel(void);
67-
extern PyObject *_Py_get___hello___toplevel(void);
68-
extern PyObject *_Py_get___hello___toplevel(void);
69-
extern PyObject *_Py_get___hello___toplevel(void);
70-
extern PyObject *_Py_get___hello___toplevel(void);
71-
extern PyObject *_Py_get___phello___toplevel(void);
72-
extern PyObject *_Py_get___phello___toplevel(void);
73-
extern PyObject *_Py_get___phello___ham_toplevel(void);
74-
extern PyObject *_Py_get___phello___ham_toplevel(void);
75-
extern PyObject *_Py_get___phello___ham_eggs_toplevel(void);
76-
extern PyObject *_Py_get___phello___spam_toplevel(void);
77-
extern PyObject *_Py_get_frozen_only_toplevel(void);
7851
/* End extern declarations */
7952

8053
static const struct _frozen bootstrap_modules[] = {
8154
{"_frozen_importlib", NULL, 0, false, GET_CODE(importlib__bootstrap)},
8255
{"_frozen_importlib_external", NULL, 0, false, GET_CODE(importlib__bootstrap_external)},
83-
{"zipimport", NULL, 0, false, GET_CODE(zipimport)},
8456
{0, 0, 0} /* bootstrap sentinel */
8557
};
8658
static const struct _frozen stdlib_modules[] = {
87-
/* stdlib - startup, without site (python -S) */
88-
{"abc", NULL, 0, false, GET_CODE(abc)},
89-
{"codecs", NULL, 0, false, GET_CODE(codecs)},
90-
{"io", NULL, 0, false, GET_CODE(io)},
91-
92-
/* stdlib - startup, with site */
93-
{"_collections_abc", NULL, 0, false, GET_CODE(_collections_abc)},
94-
{"_sitebuiltins", NULL, 0, false, GET_CODE(_sitebuiltins)},
95-
{"genericpath", NULL, 0, false, GET_CODE(genericpath)},
96-
{"ntpath", NULL, 0, false, GET_CODE(ntpath)},
97-
{"posixpath", NULL, 0, false, GET_CODE(posixpath)},
98-
{"os.path", NULL, 0, false, GET_CODE(posixpath)},
99-
{"os", NULL, 0, false, GET_CODE(os)},
100-
{"site", NULL, 0, false, GET_CODE(site)},
101-
{"stat", NULL, 0, false, GET_CODE(stat)},
102-
103-
/* runpy - run module with -m */
104-
{"importlib.util", NULL, 0, false, GET_CODE(importlib_util)},
105-
{"importlib.machinery", NULL, 0, false, GET_CODE(importlib_machinery)},
106-
{"runpy", NULL, 0, false, GET_CODE(runpy)},
10759
{0, 0, 0} /* stdlib sentinel */
10860
};
10961
static const struct _frozen test_modules[] = {
110-
{"__hello__", NULL, 0, false, GET_CODE(__hello__)},
111-
{"__hello_alias__", NULL, 0, false, GET_CODE(__hello__)},
112-
{"__phello_alias__", NULL, 0, true, GET_CODE(__hello__)},
113-
{"__phello_alias__.spam", NULL, 0, false, GET_CODE(__hello__)},
114-
{"__phello__", NULL, 0, true, GET_CODE(__phello__)},
115-
{"__phello__.__init__", NULL, 0, false, GET_CODE(__phello__)},
116-
{"__phello__.ham", NULL, 0, true, GET_CODE(__phello___ham)},
117-
{"__phello__.ham.__init__", NULL, 0, false, GET_CODE(__phello___ham)},
118-
{"__phello__.ham.eggs", NULL, 0, false, GET_CODE(__phello___ham_eggs)},
119-
{"__phello__.spam", NULL, 0, false, GET_CODE(__phello___spam)},
120-
{"__hello_only__", NULL, 0, false, GET_CODE(frozen_only)},
12162
{0, 0, 0} /* test sentinel */
12263
};
12364
const struct _frozen *_PyImport_FrozenBootstrap = bootstrap_modules;
@@ -128,12 +69,6 @@ static const struct _module_alias aliases[] = {
12869
{"_frozen_importlib", "importlib._bootstrap"},
12970
{"_frozen_importlib_external", "importlib._bootstrap_external"},
13071
{"os.path", "posixpath"},
131-
{"__hello_alias__", "__hello__"},
132-
{"__phello_alias__", "__hello__"},
133-
{"__phello_alias__.spam", "__hello__"},
134-
{"__phello__.__init__", "<__phello__"},
135-
{"__phello__.ham.__init__", "<__phello__.ham"},
136-
{"__hello_only__", NULL},
13772
{0, 0} /* aliases sentinel */
13873
};
13974
const struct _module_alias *_PyImport_FrozenAliases = aliases;

0 commit comments

Comments
 (0)