]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-45654: Freeze the runpy module and stuff it imports (GH-29903)
authorKumar Aditya <rahuladitya303@gmail.com>
Thu, 9 Dec 2021 16:51:09 +0000 (22:21 +0530)
committerGitHub <noreply@github.com>
Thu, 9 Dec 2021 16:51:09 +0000 (08:51 -0800)
Makefile.pre.in
Misc/NEWS.d/next/Core and Builtins/2021-12-09-11-57-43.bpo-45654.MZc7ei.rst [new file with mode: 0644]
PCbuild/_freeze_module.vcxproj
PCbuild/_freeze_module.vcxproj.filters
PCbuild/pythoncore.vcxproj
Python/frozen.c
Tools/scripts/freeze_modules.py

index 8e6e553554de12ceb3c627d8ffc3fc2a28834023..f6801353cfeb464e4bfaa8ff3515ba8b0a7d6551 100644 (file)
@@ -490,6 +490,10 @@ DEEPFREEZE_OBJS = \
                Python/deepfreeze/os.o \
                Python/deepfreeze/site.o \
                Python/deepfreeze/stat.o \
+               Python/deepfreeze/types.o \
+               Python/deepfreeze/importlib.util.o \
+               Python/deepfreeze/importlib.machinery.o \
+               Python/deepfreeze/runpy.o \
                Python/deepfreeze/__hello__.o \
                Python/deepfreeze/__phello__.o \
                Python/deepfreeze/__phello__.ham.o \
@@ -1010,6 +1014,18 @@ Python/deepfreeze/site.c: Python/frozen_modules/site.h $(DEEPFREEZE_DEPS)
 Python/deepfreeze/stat.c: Python/frozen_modules/stat.h $(DEEPFREEZE_DEPS)
        $(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/stat.h -m stat -o Python/deepfreeze/stat.c
 
+Python/deepfreeze/types.c: Python/frozen_modules/types.h $(DEEPFREEZE_DEPS)
+       $(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/types.h -m types -o Python/deepfreeze/types.c
+
+Python/deepfreeze/importlib.util.c: Python/frozen_modules/importlib.util.h $(DEEPFREEZE_DEPS)
+       $(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/importlib.util.h -m importlib.util -o Python/deepfreeze/importlib.util.c
+
+Python/deepfreeze/importlib.machinery.c: Python/frozen_modules/importlib.machinery.h $(DEEPFREEZE_DEPS)
+       $(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/importlib.machinery.h -m importlib.machinery -o Python/deepfreeze/importlib.machinery.c
+
+Python/deepfreeze/runpy.c: Python/frozen_modules/runpy.h $(DEEPFREEZE_DEPS)
+       $(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/runpy.h -m runpy -o Python/deepfreeze/runpy.c
+
 Python/deepfreeze/__hello__.c: Python/frozen_modules/__hello__.h $(DEEPFREEZE_DEPS)
        $(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/__hello__.h -m __hello__ -o Python/deepfreeze/__hello__.c
 
@@ -1049,6 +1065,10 @@ FROZEN_FILES_IN = \
                Lib/os.py \
                Lib/site.py \
                Lib/stat.py \
+               Lib/types.py \
+               Lib/importlib/util.py \
+               Lib/importlib/machinery.py \
+               Lib/runpy.py \
                Lib/__hello__.py \
                Lib/__phello__/__init__.py \
                Lib/__phello__/ham/__init__.py \
@@ -1071,6 +1091,10 @@ FROZEN_FILES_OUT = \
                Python/frozen_modules/os.h \
                Python/frozen_modules/site.h \
                Python/frozen_modules/stat.h \
+               Python/frozen_modules/types.h \
+               Python/frozen_modules/importlib.util.h \
+               Python/frozen_modules/importlib.machinery.h \
+               Python/frozen_modules/runpy.h \
                Python/frozen_modules/__hello__.h \
                Python/frozen_modules/__phello__.h \
                Python/frozen_modules/__phello__.ham.h \
@@ -1130,6 +1154,18 @@ Python/frozen_modules/site.h: $(FREEZE_MODULE) Lib/site.py
 Python/frozen_modules/stat.h: $(FREEZE_MODULE) Lib/stat.py
        $(FREEZE_MODULE) stat $(srcdir)/Lib/stat.py Python/frozen_modules/stat.h
 
+Python/frozen_modules/types.h: $(FREEZE_MODULE) Lib/types.py
+       $(FREEZE_MODULE) types $(srcdir)/Lib/types.py Python/frozen_modules/types.h
+
+Python/frozen_modules/importlib.util.h: $(FREEZE_MODULE) Lib/importlib/util.py
+       $(FREEZE_MODULE) importlib.util $(srcdir)/Lib/importlib/util.py Python/frozen_modules/importlib.util.h
+
+Python/frozen_modules/importlib.machinery.h: $(FREEZE_MODULE) Lib/importlib/machinery.py
+       $(FREEZE_MODULE) importlib.machinery $(srcdir)/Lib/importlib/machinery.py Python/frozen_modules/importlib.machinery.h
+
+Python/frozen_modules/runpy.h: $(FREEZE_MODULE) Lib/runpy.py
+       $(FREEZE_MODULE) runpy $(srcdir)/Lib/runpy.py Python/frozen_modules/runpy.h
+
 Python/frozen_modules/__hello__.h: $(FREEZE_MODULE) Lib/__hello__.py
        $(FREEZE_MODULE) __hello__ $(srcdir)/Lib/__hello__.py Python/frozen_modules/__hello__.h
 
diff --git a/Misc/NEWS.d/next/Core and Builtins/2021-12-09-11-57-43.bpo-45654.MZc7ei.rst b/Misc/NEWS.d/next/Core and Builtins/2021-12-09-11-57-43.bpo-45654.MZc7ei.rst
new file mode 100644 (file)
index 0000000..9072558
--- /dev/null
@@ -0,0 +1 @@
+Deepfreeze :mod:`runpy`, patch by Kumar Aditya.
\ No newline at end of file
index 07a6bfdde7402d6ed06a2960b0848fb4be47df76..2c06a8956ae4518f32c8480438532ac556bca8c5 100644 (file)
       <DeepIntFile>$(IntDir)stat.g.c</DeepIntFile>
       <DeepOutFile>$(PySourcePath)Python\deepfreeze\df.stat.c</DeepOutFile>
     </None>
+    <None Include="..\Lib\types.py">
+      <ModName>types</ModName>
+      <IntFile>$(IntDir)types.g.h</IntFile>
+      <OutFile>$(PySourcePath)Python\frozen_modules\types.h</OutFile>
+      <DeepIntFile>$(IntDir)types.g.c</DeepIntFile>
+      <DeepOutFile>$(PySourcePath)Python\deepfreeze\df.types.c</DeepOutFile>
+    </None>
+    <None Include="..\Lib\importlib\util.py">
+      <ModName>importlib.util</ModName>
+      <IntFile>$(IntDir)importlib.util.g.h</IntFile>
+      <OutFile>$(PySourcePath)Python\frozen_modules\importlib.util.h</OutFile>
+      <DeepIntFile>$(IntDir)importlib.util.g.c</DeepIntFile>
+      <DeepOutFile>$(PySourcePath)Python\deepfreeze\df.importlib.util.c</DeepOutFile>
+    </None>
+    <None Include="..\Lib\importlib\machinery.py">
+      <ModName>importlib.machinery</ModName>
+      <IntFile>$(IntDir)importlib.machinery.g.h</IntFile>
+      <OutFile>$(PySourcePath)Python\frozen_modules\importlib.machinery.h</OutFile>
+      <DeepIntFile>$(IntDir)importlib.machinery.g.c</DeepIntFile>
+      <DeepOutFile>$(PySourcePath)Python\deepfreeze\df.importlib.machinery.c</DeepOutFile>
+    </None>
+    <None Include="..\Lib\runpy.py">
+      <ModName>runpy</ModName>
+      <IntFile>$(IntDir)runpy.g.h</IntFile>
+      <OutFile>$(PySourcePath)Python\frozen_modules\runpy.h</OutFile>
+      <DeepIntFile>$(IntDir)runpy.g.c</DeepIntFile>
+      <DeepOutFile>$(PySourcePath)Python\deepfreeze\df.runpy.c</DeepOutFile>
+    </None>
     <None Include="..\Lib\__hello__.py">
       <ModName>__hello__</ModName>
       <IntFile>$(IntDir)__hello__.g.h</IntFile>
index 1c8f1b0dcf449941288170b02ceede74e25b0797..7690e5ee58890a8facee6df2d99ecfd3e7cb3278 100644 (file)
     <None Include="..\Lib\stat.py">
       <Filter>Python Files</Filter>
     </None>
+    <None Include="..\Lib\types.py">
+      <Filter>Python Files</Filter>
+    </None>
+    <None Include="..\Lib\importlib\util.py">
+      <Filter>Python Files</Filter>
+    </None>
+    <None Include="..\Lib\importlib\machinery.py">
+      <Filter>Python Files</Filter>
+    </None>
+    <None Include="..\Lib\runpy.py">
+      <Filter>Python Files</Filter>
+    </None>
     <None Include="..\Lib\__hello__.py">
       <Filter>Python Files</Filter>
     </None>
index 119650a1eec51b36dd58a135e2201a0e82f21f56..a2ee95e0ae9fc5215ca3c19c004c0c6bacfff8ea 100644 (file)
     <ClCompile Include="..\Python\deepfreeze\df.os.c" />
     <ClCompile Include="..\Python\deepfreeze\df.site.c" />
     <ClCompile Include="..\Python\deepfreeze\df.stat.c" />
+    <ClCompile Include="..\Python\deepfreeze\df.types.c" />
+    <ClCompile Include="..\Python\deepfreeze\df.importlib.util.c" />
+    <ClCompile Include="..\Python\deepfreeze\df.importlib.machinery.c" />
+    <ClCompile Include="..\Python\deepfreeze\df.runpy.c" />
     <ClCompile Include="..\Python\deepfreeze\df.__hello__.c" />
     <ClCompile Include="..\Python\deepfreeze\df.__phello__.c" />
     <ClCompile Include="..\Python\deepfreeze\df.__phello__.ham.c" />
index 9f43db70886f79f02395a4f6e0538fbaa44ed284..377c32249a83e5b07fe76508a739f5ca83f63bf8 100644 (file)
 #include "frozen_modules/os.h"
 #include "frozen_modules/site.h"
 #include "frozen_modules/stat.h"
+#include "frozen_modules/types.h"
+#include "frozen_modules/importlib.util.h"
+#include "frozen_modules/importlib.machinery.h"
+#include "frozen_modules/runpy.h"
 #include "frozen_modules/__hello__.h"
 #include "frozen_modules/__phello__.h"
 #include "frozen_modules/__phello__.ham.h"
@@ -79,6 +83,10 @@ extern PyObject *_Py_get_posixpath_toplevel(void);
 extern PyObject *_Py_get_os_toplevel(void);
 extern PyObject *_Py_get_site_toplevel(void);
 extern PyObject *_Py_get_stat_toplevel(void);
+extern PyObject *_Py_get_types_toplevel(void);
+extern PyObject *_Py_get_importlib_util_toplevel(void);
+extern PyObject *_Py_get_importlib_machinery_toplevel(void);
+extern PyObject *_Py_get_runpy_toplevel(void);
 extern PyObject *_Py_get___hello___toplevel(void);
 extern PyObject *_Py_get___hello___toplevel(void);
 extern PyObject *_Py_get___hello___toplevel(void);
@@ -116,6 +124,12 @@ static const struct _frozen stdlib_modules[] = {
     {"os", _Py_M__os, (int)sizeof(_Py_M__os), GET_CODE(os)},
     {"site", _Py_M__site, (int)sizeof(_Py_M__site), GET_CODE(site)},
     {"stat", _Py_M__stat, (int)sizeof(_Py_M__stat), GET_CODE(stat)},
+
+    /* runpy - run module with -m */
+    {"types", _Py_M__types, (int)sizeof(_Py_M__types), GET_CODE(types)},
+    {"importlib.util", _Py_M__importlib_util, (int)sizeof(_Py_M__importlib_util), GET_CODE(importlib_util)},
+    {"importlib.machinery", _Py_M__importlib_machinery, (int)sizeof(_Py_M__importlib_machinery), GET_CODE(importlib_machinery)},
+    {"runpy", _Py_M__runpy, (int)sizeof(_Py_M__runpy), GET_CODE(runpy)},
     {0, 0, 0} /* stdlib sentinel */
 };
 static const struct _frozen test_modules[] = {
index 363a2e66bef52dfd6fd2aa043fbe3abc2622b370..b0c953159dc347e067e0a6bcb3e6eed353085b62 100644 (file)
@@ -68,6 +68,12 @@ FROZEN = [
         'site',
         'stat',
         ]),
+    ('runpy - run module with -m', [
+        "types",
+        "importlib.util",
+        "importlib.machinery",
+        "runpy"
+    ]),
     (TESTS_SECTION, [
         '__hello__',
         '__hello__ : __hello_alias__',