https://github.com/python/cpython/commit/9c7b3688e6ff071456e0ee623b82870755ea7808
commit: 9c7b3688e6ff071456e0ee623b82870755ea7808
branch: main
author: Guido van Rossum <gu...@python.org>
committer: gvanrossum <gvanros...@gmail.com>
date: 2024-03-18T11:13:11-07:00
summary:

gh-108716: Cleanup remaining deepfreeze infrastructure (#116919)

Keep Tools/build/deepfreeze.py around (we may repurpose it for deepfreezing 
non-code objects),
and keep basic "clean" targets that remove the output of former deep-freeze 
activities,
to keep the build directories of current devs clean.

files:
D Python/deepfreeze/README.txt
M .gitignore
M Makefile.pre.in
M PCbuild/_freeze_module.vcxproj
M PCbuild/pythoncore.vcxproj
M Python/frozen.c
M Tools/build/freeze_modules.py
M configure
M configure.ac

diff --git a/.gitignore b/.gitignore
index 3e1213ef925305..2d380a441d2394 100644
--- a/.gitignore
+++ b/.gitignore
@@ -142,7 +142,6 @@ Tools/unicode/data/
 /profile-clean-stamp
 /profile-run-stamp
 /profile-bolt-stamp
-/Python/deepfreeze/*.c
 /pybuilddir.txt
 /pyconfig.h
 /python-config
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 3cf4de08a0c842..5958b6bdb05a57 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -1400,7 +1400,7 @@ Programs/_testembed: Programs/_testembed.o 
$(LINK_PYTHON_DEPS)
        $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ 
Programs/_testembed.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS)
 
 ############################################################################
-# "Bootstrap Python" used to run deepfreeze.py
+# "Bootstrap Python" used to run Programs/_freeze_module.py
 
 BOOTSTRAP_HEADERS = \
        Python/frozen_modules/importlib._bootstrap.h \
@@ -1419,7 +1419,7 @@ _bootstrap_python: $(LIBRARY_OBJS_OMIT_FROZEN) 
Programs/_bootstrap_python.o Modu
 #
 # Freezing is a multi step process. It works differently for standard builds
 # and cross builds. Standard builds use Programs/_freeze_module and
-# _bootstrap_python for freezing and deepfreezing, so users can build Python
+# _bootstrap_python for freezing, so users can build Python
 # without an existing Python installation. Cross builds cannot execute
 # compiled binaries and therefore rely on an external build Python
 # interpreter. The build interpreter must have same version and same bytecode
@@ -1433,12 +1433,10 @@ _bootstrap_python: $(LIBRARY_OBJS_OMIT_FROZEN) 
Programs/_bootstrap_python.o Modu
 # 5) create remaining frozen module headers with
 #    ``./_bootstrap_python Programs/_freeze_module.py``. The pure Python
 #    script is used to test the cross compile code path.
-# 6) deepfreeze modules with _bootstrap_python
 #
 # Cross compile process:
 # 1) create all frozen module headers with external build Python and
 #    Programs/_freeze_module.py script.
-# 2) deepfreeze modules with external build Python.
 #
 
 # FROZEN_FILES_* are auto-generated by Tools/build/freeze_modules.py.
@@ -1584,41 +1582,6 @@ regen-frozen: Tools/build/freeze_modules.py 
$(FROZEN_FILES_IN)
        $(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/freeze_modules.py 
--frozen-modules
        @echo "The Makefile was updated, you may need to re-run make."
 
-############################################################################
-# Deepfreeze targets
-
-DEEPFREEZE_C = Python/deepfreeze/deepfreeze.c
-DEEPFREEZE_DEPS=$(srcdir)/Tools/build/deepfreeze.py 
Include/internal/pycore_global_strings.h $(FREEZE_MODULE_DEPS) 
$(FROZEN_FILES_OUT)
-
-# BEGIN: deepfreeze modules
-$(DEEPFREEZE_C): $(DEEPFREEZE_DEPS)
-       $(PYTHON_FOR_FREEZE) $(srcdir)/Tools/build/deepfreeze.py \
-       Python/frozen_modules/importlib._bootstrap.h:importlib._bootstrap \
-       
Python/frozen_modules/importlib._bootstrap_external.h:importlib._bootstrap_external
 \
-       Python/frozen_modules/zipimport.h:zipimport \
-       Python/frozen_modules/abc.h:abc \
-       Python/frozen_modules/codecs.h:codecs \
-       Python/frozen_modules/io.h:io \
-       Python/frozen_modules/_collections_abc.h:_collections_abc \
-       Python/frozen_modules/_sitebuiltins.h:_sitebuiltins \
-       Python/frozen_modules/genericpath.h:genericpath \
-       Python/frozen_modules/ntpath.h:ntpath \
-       Python/frozen_modules/posixpath.h:posixpath \
-       Python/frozen_modules/os.h:os \
-       Python/frozen_modules/site.h:site \
-       Python/frozen_modules/stat.h:stat \
-       Python/frozen_modules/importlib.util.h:importlib.util \
-       Python/frozen_modules/importlib.machinery.h:importlib.machinery \
-       Python/frozen_modules/runpy.h:runpy \
-       Python/frozen_modules/__hello__.h:__hello__ \
-       Python/frozen_modules/__phello__.h:__phello__ \
-       Python/frozen_modules/__phello__.ham.h:__phello__.ham \
-       Python/frozen_modules/__phello__.ham.eggs.h:__phello__.ham.eggs \
-       Python/frozen_modules/__phello__.spam.h:__phello__.spam \
-       Python/frozen_modules/frozen_only.h:frozen_only \
-       -o Python/deepfreeze/deepfreeze.c
-# END: deepfreeze modules
-
 # We keep this renamed target around for folks with muscle memory.
 .PHONY: regen-importlib
 regen-importlib: regen-frozen
@@ -2933,7 +2896,7 @@ clean-retain-profile: pycremoval
        -rm -f python.html python*.js python.data python*.symbols python*.map
        -rm -f $(WASM_STDLIB)
        -rm -f Programs/_testembed Programs/_freeze_module
-       -rm -f Python/deepfreeze/*.[co]
+       -rm -rf Python/deepfreeze
        -rm -f Python/frozen_modules/*.h
        -rm -f Python/frozen_modules/MANIFEST
        -rm -f jit_stencils.h
diff --git a/PCbuild/_freeze_module.vcxproj b/PCbuild/_freeze_module.vcxproj
index 3a8a417a6bf47a..bce92c91f1ca0d 100644
--- a/PCbuild/_freeze_module.vcxproj
+++ b/PCbuild/_freeze_module.vcxproj
@@ -476,25 +476,6 @@
     <Message Text="Updated files: @(_Updated->'%(Filename)%(Extension)',', ')"
              Condition="'@(_Updated)' != ''" Importance="high" />
   </Target>
-  <Target Name="_RebuildDeepFrozen"
-          AfterTargets="_RebuildFrozen"
-          DependsOnTargets="FindPythonForBuild"
-          Condition="$(Configuration) != 'PGUpdate'">
-    <PropertyGroup>
-      <FreezeMappingsFile>
-        <!-- BEGIN freeze mapping file -->
-$(IntDir)\deepfreeze_mappings.txt
-        <!-- END freeze mapping file -->
-      </FreezeMappingsFile>
-    </PropertyGroup>
-    <WriteLinesToFile
-      File="$(FreezeMappingsFile)"
-      Overwrite="true"
-      Lines="@(FrozenModule->'%(FullPath):%(FrozenId)')" />
-    <!-- BEGIN deepfreeze rule -->
-    <Exec Command='$(PythonForBuild) 
"$(PySourcePath)Tools\build\deepfreeze.py" -f 
"$(IntDir)\deepfreeze_mappings.txt" -o 
"$(GeneratedFrozenModulesDir)deepfreeze.c"' />
-    <!-- END deepfreeze rule -->
-  </Target>
   <Target Name="_CleanFrozen" BeforeTargets="CoreClean" 
Condition="$(Configuration) != 'PGUpdate'">
     <ItemGroup>
       <Clean Include="%(None.IntFile)" />
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index 88a4a7c9564309..9131ce87db6c84 100644
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -632,11 +632,6 @@
     <ClCompile Include="..\Python\traceback.c" />
     <ClCompile Include="..\Python\tracemalloc.c" />
   </ItemGroup>
-  <ItemGroup>
-    <!-- BEGIN deepfreeze -->
-    <ClCompile Include="$(GeneratedFrozenModulesDir)deepfreeze.c" />
-    <!-- END deepfreeze -->
-  </ItemGroup>
   <ItemGroup Condition="$(IncludeExternals)">
     <ClCompile Include="..\Modules\zlibmodule.c" />
     <ClCompile Include="$(zlibDir)\adler32.c" />
diff --git a/Python/deepfreeze/README.txt b/Python/deepfreeze/README.txt
deleted file mode 100644
index 276ab51143ab33..00000000000000
--- a/Python/deepfreeze/README.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-This directory contains the generated .c files for all the deep-frozen
-modules.  Python/frozen.c depends on these files.
-
-None of these files are committed into the repo.
-
-See Tools/build/freeze_modules.py for more info.
diff --git a/Python/frozen.c b/Python/frozen.c
index 77f51a7f750965..627f2ff9413562 100644
--- a/Python/frozen.c
+++ b/Python/frozen.c
@@ -66,34 +66,6 @@
 #include "frozen_modules/frozen_only.h"
 /* End includes */
 
-#define GET_CODE(name) _Py_get_##name##_toplevel
-
-/* Start extern declarations */
-extern PyObject *_Py_get_importlib__bootstrap_toplevel(void);
-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_io_toplevel(void);
-extern PyObject *_Py_get__collections_abc_toplevel(void);
-extern PyObject *_Py_get__sitebuiltins_toplevel(void);
-extern PyObject *_Py_get_genericpath_toplevel(void);
-extern PyObject *_Py_get_ntpath_toplevel(void);
-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_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___phello___toplevel(void);
-extern PyObject *_Py_get___phello___ham_toplevel(void);
-extern PyObject *_Py_get___phello___ham_eggs_toplevel(void);
-extern PyObject *_Py_get___phello___spam_toplevel(void);
-extern PyObject *_Py_get_frozen_only_toplevel(void);
-/* End extern declarations */
-
 static const struct _frozen bootstrap_modules[] = {
     {"_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},
diff --git a/Tools/build/freeze_modules.py b/Tools/build/freeze_modules.py
index a541b4b33c519b..eef2d0af046f51 100644
--- a/Tools/build/freeze_modules.py
+++ b/Tools/build/freeze_modules.py
@@ -20,8 +20,6 @@
 # If FROZEN_MODULES_DIR or DEEPFROZEN_MODULES_DIR is changed then the
 # .gitattributes and .gitignore files needs to be updated.
 FROZEN_MODULES_DIR = os.path.join(ROOT_DIR, 'Python', 'frozen_modules')
-DEEPFROZEN_MODULES_DIR = os.path.join(ROOT_DIR, 'Python', 'deepfreeze')
-DEEPFREEZE_MAPPING_FNAME = 'deepfreeze_mappings.txt'
 
 FROZEN_FILE = os.path.join(ROOT_DIR, 'Python', 'frozen.c')
 MAKEFILE = os.path.join(ROOT_DIR, 'Makefile.pre.in')
@@ -233,7 +231,7 @@ def iter_subs():
 #######################################
 # frozen source files
 
-class FrozenSource(namedtuple('FrozenSource', 'id pyfile frozenfile 
deepfreezefile')):
+class FrozenSource(namedtuple('FrozenSource', 'id pyfile frozenfile')):
 
     @classmethod
     def from_id(cls, frozenid, pyfile=None):
@@ -241,8 +239,7 @@ def from_id(cls, frozenid, pyfile=None):
             pyfile = os.path.join(STDLIB_DIR, *frozenid.split('.')) + '.py'
             #assert os.path.exists(pyfile), (frozenid, pyfile)
         frozenfile = resolve_frozen_file(frozenid, FROZEN_MODULES_DIR)
-        deepfreezefile = resolve_frozen_file(frozenid, DEEPFROZEN_MODULES_DIR)
-        return cls(frozenid, pyfile, frozenfile, deepfreezefile)
+        return cls(frozenid, pyfile, frozenfile)
 
     @property
     def frozenid(self):
@@ -508,13 +505,6 @@ def regen_frozen(modules):
                 lines.append(f'/* {mod.section} */')
             lastsection = mod.section
 
-        # Also add a extern declaration for the corresponding
-        # deepfreeze-generated function.
-        orig_name = mod.source.id
-        code_name = orig_name.replace(".", "_")
-        get_code_name = "_Py_get_%s_toplevel" % code_name
-        externlines.append("extern PyObject *%s(void);" % get_code_name)
-
         pkg = 'true' if mod.ispkg else 'false'
         size = f"(int)sizeof({mod.symbol})"
         line = f'{{"{mod.name}", {mod.symbol}, {size}, {pkg}}},'
@@ -549,13 +539,6 @@ def regen_frozen(modules):
             headerlines,
             FROZEN_FILE,
         )
-        lines = replace_block(
-            lines,
-            "/* Start extern declarations */",
-            "/* End extern declarations */",
-            externlines,
-            FROZEN_FILE,
-        )
         lines = replace_block(
             lines,
             "static const struct _frozen bootstrap_modules[] =",
@@ -591,8 +574,6 @@ def regen_makefile(modules):
     pyfiles = []
     frozenfiles = []
     rules = ['']
-    deepfreezerules = ["$(DEEPFREEZE_C): $(DEEPFREEZE_DEPS)",
-                       "\t$(PYTHON_FOR_FREEZE) 
$(srcdir)/Tools/build/deepfreeze.py \\"]
     for src in _iter_sources(modules):
         frozen_header = relpath_for_posix_display(src.frozenfile, ROOT_DIR)
         frozenfiles.append(f'\t\t{frozen_header} \\')
@@ -614,8 +595,6 @@ def regen_makefile(modules):
             f'\t{freeze}',
             '',
         ])
-        deepfreezerules.append(f"\t{frozen_header}:{src.frozenid} \\")
-    deepfreezerules.append('\t-o Python/deepfreeze/deepfreeze.c')
     pyfiles[-1] = pyfiles[-1].rstrip(" \\")
     frozenfiles[-1] = frozenfiles[-1].rstrip(" \\")
 
@@ -643,13 +622,6 @@ def regen_makefile(modules):
             rules,
             MAKEFILE,
         )
-        lines = replace_block(
-            lines,
-            "# BEGIN: deepfreeze modules",
-            "# END: deepfreeze modules",
-            deepfreezerules,
-            MAKEFILE,
-        )
         outfile.writelines(lines)
 
 
@@ -657,9 +629,6 @@ def regen_pcbuild(modules):
     projlines = []
     filterlines = []
     corelines = []
-    deepfreezemappingsfile = f'$(IntDir)\\{DEEPFREEZE_MAPPING_FNAME}'
-    deepfreezerules = [f'    <Exec Command=\'$(PythonForBuild) 
"$(PySourcePath)Tools\\build\\deepfreeze.py" -f "{deepfreezemappingsfile}" -o 
"$(GeneratedFrozenModulesDir)deepfreeze.c"\' />']
-    deepfreezemappings = []
     for src in _iter_sources(modules):
         pyfile = relpath_for_windows_display(src.pyfile, ROOT_DIR)
         header = relpath_for_windows_display(src.frozenfile, ROOT_DIR)
@@ -673,9 +642,6 @@ def regen_pcbuild(modules):
         filterlines.append(f'    <None Include="..\\{pyfile}">')
         filterlines.append('      <Filter>Python Files</Filter>')
         filterlines.append('    </None>')
-        deepfreezemappings.append(f'    <FrozenModule 
Include="$(GeneratedFrozenModulesDir){header}" FrozenId="{src.frozenid}" />\n')
-
-    corelines.append(f'    <ClCompile 
Include="$(GeneratedFrozenModulesDir)deepfreeze.c" />')
 
     print(f'# Updating {os.path.relpath(PCBUILD_PROJECT)}')
     with updating_file_with_tmpfile(PCBUILD_PROJECT) as (infile, outfile):
@@ -688,36 +654,6 @@ def regen_pcbuild(modules):
             PCBUILD_PROJECT,
         )
         outfile.writelines(lines)
-    with updating_file_with_tmpfile(PCBUILD_PROJECT) as (infile, outfile):
-        lines = infile.readlines()
-        lines = replace_block(
-            lines,
-            '<!-- BEGIN freeze mappings -->',
-            '<!-- END freeze mappings -->',
-            deepfreezemappings,
-            PCBUILD_PROJECT,
-        )
-        outfile.writelines(lines)
-    with updating_file_with_tmpfile(PCBUILD_PROJECT) as (infile, outfile):
-        lines = infile.readlines()
-        lines = replace_block(
-            lines,
-            '<!-- BEGIN freeze mapping file -->',
-            '<!-- END freeze mapping file -->',
-            [deepfreezemappingsfile, ],
-            PCBUILD_PROJECT,
-        )
-        outfile.writelines(lines)
-    with updating_file_with_tmpfile(PCBUILD_PROJECT) as (infile, outfile):
-        lines = infile.readlines()
-        lines = replace_block(
-            lines,
-            '<!-- BEGIN deepfreeze rule -->',
-            '<!-- END deepfreeze rule -->',
-            deepfreezerules,
-            PCBUILD_PROJECT,
-        )
-        outfile.writelines(lines)
     print(f'# Updating {os.path.relpath(PCBUILD_FILTERS)}')
     with updating_file_with_tmpfile(PCBUILD_FILTERS) as (infile, outfile):
         lines = infile.readlines()
@@ -729,17 +665,6 @@ def regen_pcbuild(modules):
             PCBUILD_FILTERS,
         )
         outfile.writelines(lines)
-    print(f'# Updating {os.path.relpath(PCBUILD_PYTHONCORE)}')
-    with updating_file_with_tmpfile(PCBUILD_PYTHONCORE) as (infile, outfile):
-        lines = infile.readlines()
-        lines = replace_block(
-            lines,
-            '<!-- BEGIN deepfreeze -->',
-            '<!-- END deepfreeze -->',
-            corelines,
-            PCBUILD_FILTERS,
-        )
-        outfile.writelines(lines)
 
 
 #######################################
diff --git a/configure b/configure
index 9b40c48979b1be..07dce38c92724f 100755
--- a/configure
+++ b/configure
@@ -27318,8 +27318,7 @@ SRCDIRS="\
   Parser/lexer \
   Programs \
   Python \
-  Python/frozen_modules \
-  Python/deepfreeze"
+  Python/frozen_modules"
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for build directories" 
>&5
 printf %s "checking for build directories... " >&6; }
 for dir in $SRCDIRS; do
diff --git a/configure.ac b/configure.ac
index 02913cef06a5f9..3e676c56693a3c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6826,8 +6826,7 @@ SRCDIRS="\
   Parser/lexer \
   Programs \
   Python \
-  Python/frozen_modules \
-  Python/deepfreeze"
+  Python/frozen_modules"
 AC_MSG_CHECKING([for build directories])
 for dir in $SRCDIRS; do
     if test ! -d $dir; then

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to