From 27627d516202c6b0a7a6fc96b7ec51f7e0a0437c Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Fri, 17 Sep 2021 15:49:29 -0600 Subject: [PATCH 01/12] Allow update_file_with_tmpfile() to create the file. --- Tools/scripts/update_file.py | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/Tools/scripts/update_file.py b/Tools/scripts/update_file.py index 5e22486ec09e34..633d98aec5eaf8 100644 --- a/Tools/scripts/update_file.py +++ b/Tools/scripts/update_file.py @@ -46,11 +46,19 @@ def updating_file_with_tmpfile(filename, tmpfile=None): update_file_with_tmpfile(filename, tmpfile) -def update_file_with_tmpfile(filename, tmpfile): - with open(filename, 'rb') as f: - old_contents = f.read() - with open(tmpfile, 'rb') as f: - new_contents = f.read() +def update_file_with_tmpfile(filename, tmpfile, *, create=False): + try: + targetfile = open(filename, 'rb') + except FileNotFoundError: + if not create: + raise # re-raise + old_contents = '' + new_contents = '...' + else: + with targetfile: + old_contents = targetfile.read() + with open(tmpfile, 'rb') as f: + new_contents = f.read() if old_contents != new_contents: os.replace(tmpfile, filename) else: @@ -58,7 +66,10 @@ def update_file_with_tmpfile(filename, tmpfile): if __name__ == '__main__': - if len(sys.argv) != 3: - print("Usage: %s " % (sys.argv[0],)) - sys.exit(1) - update_file_with_tmpfile(sys.argv[1], sys.argv[2]) + import argparse + parser = argparse.ArgumentParser() + parser.add_argument('--create', action='store_true') + parser.add_argument('filename', help='path to be updated') + parser.add_argument('tmpfile', help='path with new contents') + args = parser.parse_args() + update_file_with_tmpfile(**vars(args)) From 8ab15d08011f7c6b3009e54fe73fcee0c0152e0d Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Thu, 23 Sep 2021 17:58:29 -0600 Subject: [PATCH 02/12] Optionally set the update_file.py exit code based on the outcome. --- Tools/scripts/update_file.py | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/Tools/scripts/update_file.py b/Tools/scripts/update_file.py index 633d98aec5eaf8..b4182c1d0cb638 100644 --- a/Tools/scripts/update_file.py +++ b/Tools/scripts/update_file.py @@ -52,24 +52,41 @@ def update_file_with_tmpfile(filename, tmpfile, *, create=False): except FileNotFoundError: if not create: raise # re-raise - old_contents = '' - new_contents = '...' + outcome = 'created' + os.replace(tmpfile, filename) else: with targetfile: old_contents = targetfile.read() with open(tmpfile, 'rb') as f: new_contents = f.read() - if old_contents != new_contents: - os.replace(tmpfile, filename) - else: - os.unlink(tmpfile) + # Now compare! + if old_contents != new_contents: + outcome = 'updated' + os.replace(tmpfile, filename) + else: + outcome = 'same' + os.unlink(tmpfile) + return outcome if __name__ == '__main__': import argparse parser = argparse.ArgumentParser() parser.add_argument('--create', action='store_true') + parser.add_argument('--exitcode', action='store_true') parser.add_argument('filename', help='path to be updated') parser.add_argument('tmpfile', help='path with new contents') args = parser.parse_args() - update_file_with_tmpfile(**vars(args)) + kwargs = vars(args) + setexitcode = kwargs.pop('exitcode') + + outcome = update_file_with_tmpfile(**kwargs) + if setexitcode: + if outcome == 'same': + sys.exit(0) + elif outcome == 'updated': + sys.exit(1) + elif outcome == 'created': + sys.exit(2) + else: + raise NotImplementedError From ea9999edae1241beacf311e9b9175b0a32577faf Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Fri, 17 Sep 2021 18:32:26 -0600 Subject: [PATCH 03/12] Use dots in frozen file names. --- Makefile.pre.in | 12 ++++++------ PCbuild/_freeze_module.vcxproj | 8 ++++---- Python/frozen.c | 4 ++-- Tools/scripts/freeze_modules.py | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index 9ea359b70a22c5..9403a3afd55ba7 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -750,11 +750,11 @@ regen-frozen: Tools/scripts/freeze_modules.py $(FROZEN_FILES) # BEGIN: freezing modules -Python/frozen_modules/importlib__bootstrap.h: Programs/_freeze_module Lib/importlib/_bootstrap.py - Programs/_freeze_module importlib._bootstrap $(srcdir)/Lib/importlib/_bootstrap.py $(srcdir)/Python/frozen_modules/importlib__bootstrap.h +Python/frozen_modules/importlib._bootstrap.h: Programs/_freeze_module Lib/importlib/_bootstrap.py + Programs/_freeze_module importlib._bootstrap $(srcdir)/Lib/importlib/_bootstrap.py $(srcdir)/Python/frozen_modules/importlib._bootstrap.h -Python/frozen_modules/importlib__bootstrap_external.h: Programs/_freeze_module Lib/importlib/_bootstrap_external.py - Programs/_freeze_module importlib._bootstrap_external $(srcdir)/Lib/importlib/_bootstrap_external.py $(srcdir)/Python/frozen_modules/importlib__bootstrap_external.h +Python/frozen_modules/importlib._bootstrap_external.h: Programs/_freeze_module Lib/importlib/_bootstrap_external.py + Programs/_freeze_module importlib._bootstrap_external $(srcdir)/Lib/importlib/_bootstrap_external.py $(srcdir)/Python/frozen_modules/importlib._bootstrap_external.h Python/frozen_modules/zipimport.h: Programs/_freeze_module Lib/zipimport.py Programs/_freeze_module zipimport $(srcdir)/Lib/zipimport.py $(srcdir)/Python/frozen_modules/zipimport.h @@ -1028,8 +1028,8 @@ Python/ceval.o: $(srcdir)/Python/opcode_targets.h $(srcdir)/Python/ceval_gil.h \ # FROZEN_FILES is auto-generated by Tools/scripts/freeze_modules.py. FROZEN_FILES = \ - Python/frozen_modules/importlib__bootstrap.h \ - Python/frozen_modules/importlib__bootstrap_external.h \ + Python/frozen_modules/importlib._bootstrap.h \ + Python/frozen_modules/importlib._bootstrap_external.h \ Python/frozen_modules/zipimport.h \ Python/frozen_modules/abc.h \ Python/frozen_modules/codecs.h \ diff --git a/PCbuild/_freeze_module.vcxproj b/PCbuild/_freeze_module.vcxproj index 382351ce233387..ea6532d10d8ccc 100644 --- a/PCbuild/_freeze_module.vcxproj +++ b/PCbuild/_freeze_module.vcxproj @@ -232,13 +232,13 @@ importlib._bootstrap - $(IntDir)importlib__bootstrap.g.h - $(PySourcePath)Python\frozen_modules\importlib__bootstrap.h + $(IntDir)importlib._bootstrap.g.h + $(PySourcePath)Python\frozen_modules\importlib._bootstrap.h importlib._bootstrap_external - $(IntDir)importlib__bootstrap_external.g.h - $(PySourcePath)Python\frozen_modules\importlib__bootstrap_external.h + $(IntDir)importlib._bootstrap_external.g.h + $(PySourcePath)Python\frozen_modules\importlib._bootstrap_external.h zipimport diff --git a/Python/frozen.c b/Python/frozen.c index 05b5281cce0c06..f9ad07c0b49e14 100644 --- a/Python/frozen.c +++ b/Python/frozen.c @@ -38,8 +38,8 @@ #include "Python.h" /* Includes for frozen modules: */ -#include "frozen_modules/importlib__bootstrap.h" -#include "frozen_modules/importlib__bootstrap_external.h" +#include "frozen_modules/importlib._bootstrap.h" +#include "frozen_modules/importlib._bootstrap_external.h" #include "frozen_modules/zipimport.h" #include "frozen_modules/abc.h" #include "frozen_modules/codecs.h" diff --git a/Tools/scripts/freeze_modules.py b/Tools/scripts/freeze_modules.py index b3ae5c72a9a664..a2a39d02f7693d 100644 --- a/Tools/scripts/freeze_modules.py +++ b/Tools/scripts/freeze_modules.py @@ -272,7 +272,7 @@ def resolve_frozen_file(frozenid, destdir=MODULES_DIR): except AttributeError: raise ValueError(f'unsupported frozenid {frozenid!r}') # We use a consistent naming convention for all frozen modules. - frozenfile = frozenid.replace('.', '_') + '.h' + frozenfile = f'{frozenid}.h' if not destdir: return frozenfile return os.path.join(destdir, frozenfile) From 8be81cb9405bd0ffd7d071da5ce42d6f434628f4 Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Mon, 20 Sep 2021 12:55:25 -0600 Subject: [PATCH 04/12] "regen-frozen" does not depend on the frozen .h files. --- Makefile.pre.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index 9403a3afd55ba7..a319f677a1894e 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -744,7 +744,7 @@ Programs/_freeze_module: Programs/_freeze_module.o $(LIBRARY_OBJS_OMIT_FROZEN) Tools/scripts/freeze_modules.py: Programs/_freeze_module .PHONY: regen-frozen -regen-frozen: Tools/scripts/freeze_modules.py $(FROZEN_FILES) +regen-frozen: Tools/scripts/freeze_modules.py $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/freeze_modules.py @echo "The Makefile was updated, you may need to re-run make." From fe35ad2121066f452cfb267a4cfd64ecdf05d39e Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Mon, 20 Sep 2021 13:17:48 -0600 Subject: [PATCH 05/12] Regen build-related files before regenerating the frozen files. --- Tools/scripts/freeze_modules.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Tools/scripts/freeze_modules.py b/Tools/scripts/freeze_modules.py index a2a39d02f7693d..729852ccb20ec1 100644 --- a/Tools/scripts/freeze_modules.py +++ b/Tools/scripts/freeze_modules.py @@ -652,15 +652,17 @@ def main(): # Expand the raw specs, preserving order. modules = list(parse_frozen_specs(destdir=MODULES_DIR)) + # Regen build-related files. + regen_makefile(modules) + regen_pcbuild(modules) + # Freeze the target modules. for src in _iter_sources(modules): _freeze_module(src.frozenid, src.pyfile, src.frozenfile) - # Regen build-related files. - regen_manifest(modules) + # Regen files dependent of frozen file details. regen_frozen(modules) - regen_makefile(modules) - regen_pcbuild(modules) + regen_manifest(modules) if __name__ == '__main__': From 9f2ce1f6f1ae976774fe5efa62e3f9ddd596873d Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Mon, 20 Sep 2021 12:56:47 -0600 Subject: [PATCH 06/12] Move FROZEN_FILES up to the rest of the frozen modules stuff. --- Makefile.pre.in | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index a319f677a1894e..7223a783326e0b 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -736,6 +736,25 @@ Programs/_testembed: Programs/_testembed.o $(LIBRARY_DEPS) ############################################################################ # frozen modules (including importlib) +# FROZEN_FILES is auto-generated by Tools/scripts/freeze_modules.py. +FROZEN_FILES = \ + Python/frozen_modules/importlib._bootstrap.h \ + Python/frozen_modules/importlib._bootstrap_external.h \ + Python/frozen_modules/zipimport.h \ + Python/frozen_modules/abc.h \ + Python/frozen_modules/codecs.h \ + Python/frozen_modules/io.h \ + Python/frozen_modules/_collections_abc.h \ + Python/frozen_modules/_sitebuiltins.h \ + Python/frozen_modules/genericpath.h \ + Python/frozen_modules/ntpath.h \ + Python/frozen_modules/posixpath.h \ + Python/frozen_modules/os.h \ + Python/frozen_modules/site.h \ + Python/frozen_modules/stat.h \ + Python/frozen_modules/__hello__.h +# End FROZEN_FILES + Programs/_freeze_module.o: Programs/_freeze_module.c Makefile Programs/_freeze_module: Programs/_freeze_module.o $(LIBRARY_OBJS_OMIT_FROZEN) @@ -1026,25 +1045,6 @@ regen-opcode-targets: Python/ceval.o: $(srcdir)/Python/opcode_targets.h $(srcdir)/Python/ceval_gil.h \ $(srcdir)/Python/condvar.h -# FROZEN_FILES is auto-generated by Tools/scripts/freeze_modules.py. -FROZEN_FILES = \ - Python/frozen_modules/importlib._bootstrap.h \ - Python/frozen_modules/importlib._bootstrap_external.h \ - Python/frozen_modules/zipimport.h \ - Python/frozen_modules/abc.h \ - Python/frozen_modules/codecs.h \ - Python/frozen_modules/io.h \ - Python/frozen_modules/_collections_abc.h \ - Python/frozen_modules/_sitebuiltins.h \ - Python/frozen_modules/genericpath.h \ - Python/frozen_modules/ntpath.h \ - Python/frozen_modules/posixpath.h \ - Python/frozen_modules/os.h \ - Python/frozen_modules/site.h \ - Python/frozen_modules/stat.h \ - Python/frozen_modules/__hello__.h -# End FROZEN_FILES - Python/frozen.o: $(FROZEN_FILES) # Generate DTrace probe macros, then rename them (PYTHON_ -> PyDTrace_) to From e9c66993a082101f9f8fcfeadf32f3b15b25504a Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Fri, 17 Sep 2021 14:20:24 -0600 Subject: [PATCH 07/12] Don't write the generated files if they haven't changed. --- Makefile.pre.in | 45 ++++++++++++++++++++++----------- Tools/scripts/freeze_modules.py | 21 ++++++++------- 2 files changed, 42 insertions(+), 24 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index 7223a783326e0b..35b17966b63be1 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -770,49 +770,64 @@ regen-frozen: Tools/scripts/freeze_modules.py # BEGIN: freezing modules Python/frozen_modules/importlib._bootstrap.h: Programs/_freeze_module Lib/importlib/_bootstrap.py - Programs/_freeze_module importlib._bootstrap $(srcdir)/Lib/importlib/_bootstrap.py $(srcdir)/Python/frozen_modules/importlib._bootstrap.h + Programs/_freeze_module importlib._bootstrap $(srcdir)/Lib/importlib/_bootstrap.py $(srcdir)/Python/frozen_modules/importlib._bootstrap.h.new && \ + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/importlib._bootstrap.h $(srcdir)/Python/frozen_modules/importlib._bootstrap.h.new Python/frozen_modules/importlib._bootstrap_external.h: Programs/_freeze_module Lib/importlib/_bootstrap_external.py - Programs/_freeze_module importlib._bootstrap_external $(srcdir)/Lib/importlib/_bootstrap_external.py $(srcdir)/Python/frozen_modules/importlib._bootstrap_external.h + Programs/_freeze_module importlib._bootstrap_external $(srcdir)/Lib/importlib/_bootstrap_external.py $(srcdir)/Python/frozen_modules/importlib._bootstrap_external.h.new && \ + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/importlib._bootstrap_external.h $(srcdir)/Python/frozen_modules/importlib._bootstrap_external.h.new Python/frozen_modules/zipimport.h: Programs/_freeze_module Lib/zipimport.py - Programs/_freeze_module zipimport $(srcdir)/Lib/zipimport.py $(srcdir)/Python/frozen_modules/zipimport.h + Programs/_freeze_module zipimport $(srcdir)/Lib/zipimport.py $(srcdir)/Python/frozen_modules/zipimport.h.new && \ + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/zipimport.h $(srcdir)/Python/frozen_modules/zipimport.h.new Python/frozen_modules/abc.h: Programs/_freeze_module Lib/abc.py - Programs/_freeze_module abc $(srcdir)/Lib/abc.py $(srcdir)/Python/frozen_modules/abc.h + Programs/_freeze_module abc $(srcdir)/Lib/abc.py $(srcdir)/Python/frozen_modules/abc.h.new && \ + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/abc.h $(srcdir)/Python/frozen_modules/abc.h.new Python/frozen_modules/codecs.h: Programs/_freeze_module Lib/codecs.py - Programs/_freeze_module codecs $(srcdir)/Lib/codecs.py $(srcdir)/Python/frozen_modules/codecs.h + Programs/_freeze_module codecs $(srcdir)/Lib/codecs.py $(srcdir)/Python/frozen_modules/codecs.h.new && \ + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/codecs.h $(srcdir)/Python/frozen_modules/codecs.h.new Python/frozen_modules/io.h: Programs/_freeze_module Lib/io.py - Programs/_freeze_module io $(srcdir)/Lib/io.py $(srcdir)/Python/frozen_modules/io.h + Programs/_freeze_module io $(srcdir)/Lib/io.py $(srcdir)/Python/frozen_modules/io.h.new && \ + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/io.h $(srcdir)/Python/frozen_modules/io.h.new Python/frozen_modules/_collections_abc.h: Programs/_freeze_module Lib/_collections_abc.py - Programs/_freeze_module _collections_abc $(srcdir)/Lib/_collections_abc.py $(srcdir)/Python/frozen_modules/_collections_abc.h + Programs/_freeze_module _collections_abc $(srcdir)/Lib/_collections_abc.py $(srcdir)/Python/frozen_modules/_collections_abc.h.new && \ + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/_collections_abc.h $(srcdir)/Python/frozen_modules/_collections_abc.h.new Python/frozen_modules/_sitebuiltins.h: Programs/_freeze_module Lib/_sitebuiltins.py - Programs/_freeze_module _sitebuiltins $(srcdir)/Lib/_sitebuiltins.py $(srcdir)/Python/frozen_modules/_sitebuiltins.h + Programs/_freeze_module _sitebuiltins $(srcdir)/Lib/_sitebuiltins.py $(srcdir)/Python/frozen_modules/_sitebuiltins.h.new && \ + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/_sitebuiltins.h $(srcdir)/Python/frozen_modules/_sitebuiltins.h.new Python/frozen_modules/genericpath.h: Programs/_freeze_module Lib/genericpath.py - Programs/_freeze_module genericpath $(srcdir)/Lib/genericpath.py $(srcdir)/Python/frozen_modules/genericpath.h + Programs/_freeze_module genericpath $(srcdir)/Lib/genericpath.py $(srcdir)/Python/frozen_modules/genericpath.h.new && \ + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/genericpath.h $(srcdir)/Python/frozen_modules/genericpath.h.new Python/frozen_modules/ntpath.h: Programs/_freeze_module Lib/ntpath.py - Programs/_freeze_module ntpath $(srcdir)/Lib/ntpath.py $(srcdir)/Python/frozen_modules/ntpath.h + Programs/_freeze_module ntpath $(srcdir)/Lib/ntpath.py $(srcdir)/Python/frozen_modules/ntpath.h.new && \ + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/ntpath.h $(srcdir)/Python/frozen_modules/ntpath.h.new Python/frozen_modules/posixpath.h: Programs/_freeze_module Lib/posixpath.py - Programs/_freeze_module posixpath $(srcdir)/Lib/posixpath.py $(srcdir)/Python/frozen_modules/posixpath.h + Programs/_freeze_module posixpath $(srcdir)/Lib/posixpath.py $(srcdir)/Python/frozen_modules/posixpath.h.new && \ + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/posixpath.h $(srcdir)/Python/frozen_modules/posixpath.h.new Python/frozen_modules/os.h: Programs/_freeze_module Lib/os.py - Programs/_freeze_module os $(srcdir)/Lib/os.py $(srcdir)/Python/frozen_modules/os.h + Programs/_freeze_module os $(srcdir)/Lib/os.py $(srcdir)/Python/frozen_modules/os.h.new && \ + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/os.h $(srcdir)/Python/frozen_modules/os.h.new Python/frozen_modules/site.h: Programs/_freeze_module Lib/site.py - Programs/_freeze_module site $(srcdir)/Lib/site.py $(srcdir)/Python/frozen_modules/site.h + Programs/_freeze_module site $(srcdir)/Lib/site.py $(srcdir)/Python/frozen_modules/site.h.new && \ + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/site.h $(srcdir)/Python/frozen_modules/site.h.new Python/frozen_modules/stat.h: Programs/_freeze_module Lib/stat.py - Programs/_freeze_module stat $(srcdir)/Lib/stat.py $(srcdir)/Python/frozen_modules/stat.h + Programs/_freeze_module stat $(srcdir)/Lib/stat.py $(srcdir)/Python/frozen_modules/stat.h.new && \ + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/stat.h $(srcdir)/Python/frozen_modules/stat.h.new Python/frozen_modules/__hello__.h: Programs/_freeze_module Lib/__hello__.py - Programs/_freeze_module __hello__ $(srcdir)/Lib/__hello__.py $(srcdir)/Python/frozen_modules/__hello__.h + Programs/_freeze_module __hello__ $(srcdir)/Lib/__hello__.py $(srcdir)/Python/frozen_modules/__hello__.h.new && \ + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/__hello__.h $(srcdir)/Python/frozen_modules/__hello__.h.new # END: freezing modules diff --git a/Tools/scripts/freeze_modules.py b/Tools/scripts/freeze_modules.py index 729852ccb20ec1..c42ad92205e86a 100644 --- a/Tools/scripts/freeze_modules.py +++ b/Tools/scripts/freeze_modules.py @@ -12,7 +12,7 @@ import sys import textwrap -from update_file import updating_file_with_tmpfile +from update_file import updating_file_with_tmpfile, update_file_with_tmpfile ROOT_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) @@ -549,13 +549,16 @@ def regen_makefile(modules): frozenfiles.append(f'\t\t{header} \\') pyfile = relpath_for_posix_display(src.pyfile, ROOT_DIR) - # Note that we freeze the module to the target .h file - # instead of going through an intermediate file like we used to. - rules.append(f'{header}: Programs/_freeze_module {pyfile}') - rules.append( - (f'\tPrograms/_freeze_module {src.frozenid} ' - f'$(srcdir)/{pyfile} $(srcdir)/{header}')) - rules.append('') + freeze = (f'Programs/_freeze_module {src.frozenid} ' + f'$(srcdir)/{pyfile} $(srcdir)/{header}.new') + update = (f'$(UPDATE_FILE) --create $(srcdir)/{header} ' + f'$(srcdir)/{header}.new') + rules.extend([ + f'{header}: Programs/_freeze_module {pyfile}', + f'\t{freeze} && \\', + f'\t\t{update}', + '', + ]) frozenfiles[-1] = frozenfiles[-1].rstrip(" \\") @@ -642,7 +645,7 @@ def _freeze_module(frozenid, pyfile, frozenfile): sys.exit(f'ERROR: missing {TOOL}; you need to run "make regen-frozen"') raise # re-raise - os.replace(tmpfile, frozenfile) + update_file_with_tmpfile(frozenfile, tmpfile, create=True) ####################################### From 0320470bdf801d183408b1882d4bf2463a61f7c1 Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Mon, 20 Sep 2021 13:26:38 -0600 Subject: [PATCH 08/12] Add FROZEN_FILES_IN. --- Makefile.pre.in | 27 ++++++++++++++++++++++----- Tools/scripts/freeze_modules.py | 16 +++++++++++++--- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index 35b17966b63be1..13cd2d0d2ee355 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -736,8 +736,25 @@ Programs/_testembed: Programs/_testembed.o $(LIBRARY_DEPS) ############################################################################ # frozen modules (including importlib) -# FROZEN_FILES is auto-generated by Tools/scripts/freeze_modules.py. -FROZEN_FILES = \ +# FROZEN_FILES_* are auto-generated by Tools/scripts/freeze_modules.py. +FROZEN_FILES_IN = \ + Lib/importlib/_bootstrap.py \ + Lib/importlib/_bootstrap_external.py \ + Lib/zipimport.py \ + Lib/abc.py \ + Lib/codecs.py \ + Lib/io.py \ + Lib/_collections_abc.py \ + Lib/_sitebuiltins.py \ + Lib/genericpath.py \ + Lib/ntpath.py \ + Lib/posixpath.py \ + Lib/os.py \ + Lib/site.py \ + Lib/stat.py \ + Lib/__hello__.py +# End FROZEN_FILES_IN +FROZEN_FILES_OUT = \ Python/frozen_modules/importlib._bootstrap.h \ Python/frozen_modules/importlib._bootstrap_external.h \ Python/frozen_modules/zipimport.h \ @@ -753,7 +770,7 @@ FROZEN_FILES = \ Python/frozen_modules/site.h \ Python/frozen_modules/stat.h \ Python/frozen_modules/__hello__.h -# End FROZEN_FILES +# End FROZEN_FILES_OUT Programs/_freeze_module.o: Programs/_freeze_module.c Makefile @@ -763,7 +780,7 @@ Programs/_freeze_module: Programs/_freeze_module.o $(LIBRARY_OBJS_OMIT_FROZEN) Tools/scripts/freeze_modules.py: Programs/_freeze_module .PHONY: regen-frozen -regen-frozen: Tools/scripts/freeze_modules.py +regen-frozen: Tools/scripts/freeze_modules.py $(FROZEN_FILES_IN) $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/freeze_modules.py @echo "The Makefile was updated, you may need to re-run make." @@ -1060,7 +1077,7 @@ regen-opcode-targets: Python/ceval.o: $(srcdir)/Python/opcode_targets.h $(srcdir)/Python/ceval_gil.h \ $(srcdir)/Python/condvar.h -Python/frozen.o: $(FROZEN_FILES) +Python/frozen.o: $(FROZEN_FILES_OUT) # Generate DTrace probe macros, then rename them (PYTHON_ -> PyDTrace_) to # follow our naming conventions. dtrace(1) uses the output filename to generate diff --git a/Tools/scripts/freeze_modules.py b/Tools/scripts/freeze_modules.py index c42ad92205e86a..d387d6c88f6675 100644 --- a/Tools/scripts/freeze_modules.py +++ b/Tools/scripts/freeze_modules.py @@ -542,6 +542,7 @@ def regen_frozen(modules): def regen_makefile(modules): + pyfiles = [] frozenfiles = [] rules = [''] for src in _iter_sources(modules): @@ -549,6 +550,8 @@ def regen_makefile(modules): frozenfiles.append(f'\t\t{header} \\') pyfile = relpath_for_posix_display(src.pyfile, ROOT_DIR) + pyfiles.append(f'\t\t{pyfile} \\') + freeze = (f'Programs/_freeze_module {src.frozenid} ' f'$(srcdir)/{pyfile} $(srcdir)/{header}.new') update = (f'$(UPDATE_FILE) --create $(srcdir)/{header} ' @@ -559,7 +562,7 @@ def regen_makefile(modules): f'\t\t{update}', '', ]) - + pyfiles[-1] = pyfiles[-1].rstrip(" \\") frozenfiles[-1] = frozenfiles[-1].rstrip(" \\") print(f'# Updating {os.path.relpath(MAKEFILE)}') @@ -567,8 +570,15 @@ def regen_makefile(modules): lines = infile.readlines() lines = replace_block( lines, - "FROZEN_FILES =", - "# End FROZEN_FILES", + "FROZEN_FILES_IN =", + "# End FROZEN_FILES_IN", + pyfiles, + MAKEFILE, + ) + lines = replace_block( + lines, + "FROZEN_FILES_OUT =", + "# End FROZEN_FILES_OUT", frozenfiles, MAKEFILE, ) From 87e5c5f2f4885d990f4f0eee3c8f41214ce5e5ed Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Wed, 22 Sep 2021 17:55:43 -0600 Subject: [PATCH 09/12] Move "regen-frozen" down where it belongs. --- Makefile.pre.in | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index 13cd2d0d2ee355..a7a6045ee75dcb 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -777,13 +777,6 @@ Programs/_freeze_module.o: Programs/_freeze_module.c Makefile Programs/_freeze_module: Programs/_freeze_module.o $(LIBRARY_OBJS_OMIT_FROZEN) $(LINKCC) $(PY_CORE_LDFLAGS) -o $@ Programs/_freeze_module.o $(LIBRARY_OBJS_OMIT_FROZEN) $(LIBS) $(MODLIBS) $(SYSLIBS) -Tools/scripts/freeze_modules.py: Programs/_freeze_module - -.PHONY: regen-frozen -regen-frozen: Tools/scripts/freeze_modules.py $(FROZEN_FILES_IN) - $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/freeze_modules.py - @echo "The Makefile was updated, you may need to re-run make." - # BEGIN: freezing modules Python/frozen_modules/importlib._bootstrap.h: Programs/_freeze_module Lib/importlib/_bootstrap.py @@ -848,6 +841,13 @@ Python/frozen_modules/__hello__.h: Programs/_freeze_module Lib/__hello__.py # END: freezing modules +Tools/scripts/freeze_modules.py: Programs/_freeze_module + +.PHONY: regen-frozen +regen-frozen: Tools/scripts/freeze_modules.py $(FROZEN_FILES_IN) + $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/freeze_modules.py + @echo "The Makefile was updated, you may need to re-run make." + # We keep this renamed target around for folks with muscle memory. .PHONY: regen-importlib regen-importlib: regen-frozen From 6fe0b1a8c3930dd13b8cc3748479c1e1f53b75e0 Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Fri, 24 Sep 2021 09:42:30 -0600 Subject: [PATCH 10/12] Use a unique temporary filename when freezing explicitly. --- Tools/scripts/freeze_modules.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Tools/scripts/freeze_modules.py b/Tools/scripts/freeze_modules.py index d387d6c88f6675..5c80468ef9e1ca 100644 --- a/Tools/scripts/freeze_modules.py +++ b/Tools/scripts/freeze_modules.py @@ -11,6 +11,7 @@ import subprocess import sys import textwrap +import time from update_file import updating_file_with_tmpfile, update_file_with_tmpfile @@ -638,13 +639,15 @@ def regen_pcbuild(modules): def freeze_module(modname, pyfile=None, destdir=MODULES_DIR): """Generate the frozen module .h file for the given module.""" + tmpsuffix = f'.{int(time.time())}' for modname, pyfile, ispkg in resolve_modules(modname, pyfile): frozenfile = resolve_frozen_file(modname, destdir) - _freeze_module(modname, pyfile, frozenfile) + _freeze_module(modname, pyfile, frozenfile, tmpsuffix) -def _freeze_module(frozenid, pyfile, frozenfile): - tmpfile = frozenfile + '.new' +def _freeze_module(frozenid, pyfile, frozenfile, tmpsuffix): + tmpfile = f'{frozenfile}.{int(time.time())}' + print(tmpfile) argv = [TOOL, frozenid, pyfile, tmpfile] print('#', ' '.join(os.path.relpath(a) for a in argv), flush=True) @@ -670,8 +673,9 @@ def main(): regen_pcbuild(modules) # Freeze the target modules. + tmpsuffix = f'.{int(time.time())}' for src in _iter_sources(modules): - _freeze_module(src.frozenid, src.pyfile, src.frozenfile) + _freeze_module(src.frozenid, src.pyfile, src.frozenfile, tmpsuffix) # Regen files dependent of frozen file details. regen_frozen(modules) From b4933ad50ce12233146b46c99829e0467c3b1452 Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Fri, 24 Sep 2021 09:03:35 -0600 Subject: [PATCH 11/12] Do not combine the freeze and update. --- Makefile.pre.in | 60 ++++++++++++++++----------------- Tools/scripts/freeze_modules.py | 4 +-- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index a7a6045ee75dcb..f8bb431b566943 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -780,64 +780,64 @@ Programs/_freeze_module: Programs/_freeze_module.o $(LIBRARY_OBJS_OMIT_FROZEN) # BEGIN: freezing modules Python/frozen_modules/importlib._bootstrap.h: Programs/_freeze_module Lib/importlib/_bootstrap.py - Programs/_freeze_module importlib._bootstrap $(srcdir)/Lib/importlib/_bootstrap.py $(srcdir)/Python/frozen_modules/importlib._bootstrap.h.new && \ - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/importlib._bootstrap.h $(srcdir)/Python/frozen_modules/importlib._bootstrap.h.new + Programs/_freeze_module importlib._bootstrap $(srcdir)/Lib/importlib/_bootstrap.py $(srcdir)/Python/frozen_modules/importlib._bootstrap.h.new + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/importlib._bootstrap.h $(srcdir)/Python/frozen_modules/importlib._bootstrap.h.new Python/frozen_modules/importlib._bootstrap_external.h: Programs/_freeze_module Lib/importlib/_bootstrap_external.py - Programs/_freeze_module importlib._bootstrap_external $(srcdir)/Lib/importlib/_bootstrap_external.py $(srcdir)/Python/frozen_modules/importlib._bootstrap_external.h.new && \ - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/importlib._bootstrap_external.h $(srcdir)/Python/frozen_modules/importlib._bootstrap_external.h.new + Programs/_freeze_module importlib._bootstrap_external $(srcdir)/Lib/importlib/_bootstrap_external.py $(srcdir)/Python/frozen_modules/importlib._bootstrap_external.h.new + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/importlib._bootstrap_external.h $(srcdir)/Python/frozen_modules/importlib._bootstrap_external.h.new Python/frozen_modules/zipimport.h: Programs/_freeze_module Lib/zipimport.py - Programs/_freeze_module zipimport $(srcdir)/Lib/zipimport.py $(srcdir)/Python/frozen_modules/zipimport.h.new && \ - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/zipimport.h $(srcdir)/Python/frozen_modules/zipimport.h.new + Programs/_freeze_module zipimport $(srcdir)/Lib/zipimport.py $(srcdir)/Python/frozen_modules/zipimport.h.new + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/zipimport.h $(srcdir)/Python/frozen_modules/zipimport.h.new Python/frozen_modules/abc.h: Programs/_freeze_module Lib/abc.py - Programs/_freeze_module abc $(srcdir)/Lib/abc.py $(srcdir)/Python/frozen_modules/abc.h.new && \ - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/abc.h $(srcdir)/Python/frozen_modules/abc.h.new + Programs/_freeze_module abc $(srcdir)/Lib/abc.py $(srcdir)/Python/frozen_modules/abc.h.new + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/abc.h $(srcdir)/Python/frozen_modules/abc.h.new Python/frozen_modules/codecs.h: Programs/_freeze_module Lib/codecs.py - Programs/_freeze_module codecs $(srcdir)/Lib/codecs.py $(srcdir)/Python/frozen_modules/codecs.h.new && \ - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/codecs.h $(srcdir)/Python/frozen_modules/codecs.h.new + Programs/_freeze_module codecs $(srcdir)/Lib/codecs.py $(srcdir)/Python/frozen_modules/codecs.h.new + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/codecs.h $(srcdir)/Python/frozen_modules/codecs.h.new Python/frozen_modules/io.h: Programs/_freeze_module Lib/io.py - Programs/_freeze_module io $(srcdir)/Lib/io.py $(srcdir)/Python/frozen_modules/io.h.new && \ - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/io.h $(srcdir)/Python/frozen_modules/io.h.new + Programs/_freeze_module io $(srcdir)/Lib/io.py $(srcdir)/Python/frozen_modules/io.h.new + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/io.h $(srcdir)/Python/frozen_modules/io.h.new Python/frozen_modules/_collections_abc.h: Programs/_freeze_module Lib/_collections_abc.py - Programs/_freeze_module _collections_abc $(srcdir)/Lib/_collections_abc.py $(srcdir)/Python/frozen_modules/_collections_abc.h.new && \ - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/_collections_abc.h $(srcdir)/Python/frozen_modules/_collections_abc.h.new + Programs/_freeze_module _collections_abc $(srcdir)/Lib/_collections_abc.py $(srcdir)/Python/frozen_modules/_collections_abc.h.new + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/_collections_abc.h $(srcdir)/Python/frozen_modules/_collections_abc.h.new Python/frozen_modules/_sitebuiltins.h: Programs/_freeze_module Lib/_sitebuiltins.py - Programs/_freeze_module _sitebuiltins $(srcdir)/Lib/_sitebuiltins.py $(srcdir)/Python/frozen_modules/_sitebuiltins.h.new && \ - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/_sitebuiltins.h $(srcdir)/Python/frozen_modules/_sitebuiltins.h.new + Programs/_freeze_module _sitebuiltins $(srcdir)/Lib/_sitebuiltins.py $(srcdir)/Python/frozen_modules/_sitebuiltins.h.new + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/_sitebuiltins.h $(srcdir)/Python/frozen_modules/_sitebuiltins.h.new Python/frozen_modules/genericpath.h: Programs/_freeze_module Lib/genericpath.py - Programs/_freeze_module genericpath $(srcdir)/Lib/genericpath.py $(srcdir)/Python/frozen_modules/genericpath.h.new && \ - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/genericpath.h $(srcdir)/Python/frozen_modules/genericpath.h.new + Programs/_freeze_module genericpath $(srcdir)/Lib/genericpath.py $(srcdir)/Python/frozen_modules/genericpath.h.new + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/genericpath.h $(srcdir)/Python/frozen_modules/genericpath.h.new Python/frozen_modules/ntpath.h: Programs/_freeze_module Lib/ntpath.py - Programs/_freeze_module ntpath $(srcdir)/Lib/ntpath.py $(srcdir)/Python/frozen_modules/ntpath.h.new && \ - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/ntpath.h $(srcdir)/Python/frozen_modules/ntpath.h.new + Programs/_freeze_module ntpath $(srcdir)/Lib/ntpath.py $(srcdir)/Python/frozen_modules/ntpath.h.new + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/ntpath.h $(srcdir)/Python/frozen_modules/ntpath.h.new Python/frozen_modules/posixpath.h: Programs/_freeze_module Lib/posixpath.py - Programs/_freeze_module posixpath $(srcdir)/Lib/posixpath.py $(srcdir)/Python/frozen_modules/posixpath.h.new && \ - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/posixpath.h $(srcdir)/Python/frozen_modules/posixpath.h.new + Programs/_freeze_module posixpath $(srcdir)/Lib/posixpath.py $(srcdir)/Python/frozen_modules/posixpath.h.new + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/posixpath.h $(srcdir)/Python/frozen_modules/posixpath.h.new Python/frozen_modules/os.h: Programs/_freeze_module Lib/os.py - Programs/_freeze_module os $(srcdir)/Lib/os.py $(srcdir)/Python/frozen_modules/os.h.new && \ - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/os.h $(srcdir)/Python/frozen_modules/os.h.new + Programs/_freeze_module os $(srcdir)/Lib/os.py $(srcdir)/Python/frozen_modules/os.h.new + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/os.h $(srcdir)/Python/frozen_modules/os.h.new Python/frozen_modules/site.h: Programs/_freeze_module Lib/site.py - Programs/_freeze_module site $(srcdir)/Lib/site.py $(srcdir)/Python/frozen_modules/site.h.new && \ - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/site.h $(srcdir)/Python/frozen_modules/site.h.new + Programs/_freeze_module site $(srcdir)/Lib/site.py $(srcdir)/Python/frozen_modules/site.h.new + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/site.h $(srcdir)/Python/frozen_modules/site.h.new Python/frozen_modules/stat.h: Programs/_freeze_module Lib/stat.py - Programs/_freeze_module stat $(srcdir)/Lib/stat.py $(srcdir)/Python/frozen_modules/stat.h.new && \ - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/stat.h $(srcdir)/Python/frozen_modules/stat.h.new + Programs/_freeze_module stat $(srcdir)/Lib/stat.py $(srcdir)/Python/frozen_modules/stat.h.new + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/stat.h $(srcdir)/Python/frozen_modules/stat.h.new Python/frozen_modules/__hello__.h: Programs/_freeze_module Lib/__hello__.py - Programs/_freeze_module __hello__ $(srcdir)/Lib/__hello__.py $(srcdir)/Python/frozen_modules/__hello__.h.new && \ - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/__hello__.h $(srcdir)/Python/frozen_modules/__hello__.h.new + Programs/_freeze_module __hello__ $(srcdir)/Lib/__hello__.py $(srcdir)/Python/frozen_modules/__hello__.h.new + $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/__hello__.h $(srcdir)/Python/frozen_modules/__hello__.h.new # END: freezing modules diff --git a/Tools/scripts/freeze_modules.py b/Tools/scripts/freeze_modules.py index 5c80468ef9e1ca..781e5872bfeaa8 100644 --- a/Tools/scripts/freeze_modules.py +++ b/Tools/scripts/freeze_modules.py @@ -559,8 +559,8 @@ def regen_makefile(modules): f'$(srcdir)/{header}.new') rules.extend([ f'{header}: Programs/_freeze_module {pyfile}', - f'\t{freeze} && \\', - f'\t\t{update}', + f'\t{freeze}', + f'\t{update}', '', ]) pyfiles[-1] = pyfiles[-1].rstrip(" \\") From 25b1ce6e6125ca4b01235f0de0af68c5399a0456 Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Fri, 24 Sep 2021 09:06:48 -0600 Subject: [PATCH 12/12] Stop using update_file.py for now. --- Makefile.pre.in | 45 +++++++++++---------------------- Tools/scripts/freeze_modules.py | 5 +--- 2 files changed, 16 insertions(+), 34 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index f8bb431b566943..5564c1bae1ce2a 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -780,64 +780,49 @@ Programs/_freeze_module: Programs/_freeze_module.o $(LIBRARY_OBJS_OMIT_FROZEN) # BEGIN: freezing modules Python/frozen_modules/importlib._bootstrap.h: Programs/_freeze_module Lib/importlib/_bootstrap.py - Programs/_freeze_module importlib._bootstrap $(srcdir)/Lib/importlib/_bootstrap.py $(srcdir)/Python/frozen_modules/importlib._bootstrap.h.new - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/importlib._bootstrap.h $(srcdir)/Python/frozen_modules/importlib._bootstrap.h.new + Programs/_freeze_module importlib._bootstrap $(srcdir)/Lib/importlib/_bootstrap.py $(srcdir)/Python/frozen_modules/importlib._bootstrap.h Python/frozen_modules/importlib._bootstrap_external.h: Programs/_freeze_module Lib/importlib/_bootstrap_external.py - Programs/_freeze_module importlib._bootstrap_external $(srcdir)/Lib/importlib/_bootstrap_external.py $(srcdir)/Python/frozen_modules/importlib._bootstrap_external.h.new - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/importlib._bootstrap_external.h $(srcdir)/Python/frozen_modules/importlib._bootstrap_external.h.new + Programs/_freeze_module importlib._bootstrap_external $(srcdir)/Lib/importlib/_bootstrap_external.py $(srcdir)/Python/frozen_modules/importlib._bootstrap_external.h Python/frozen_modules/zipimport.h: Programs/_freeze_module Lib/zipimport.py - Programs/_freeze_module zipimport $(srcdir)/Lib/zipimport.py $(srcdir)/Python/frozen_modules/zipimport.h.new - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/zipimport.h $(srcdir)/Python/frozen_modules/zipimport.h.new + Programs/_freeze_module zipimport $(srcdir)/Lib/zipimport.py $(srcdir)/Python/frozen_modules/zipimport.h Python/frozen_modules/abc.h: Programs/_freeze_module Lib/abc.py - Programs/_freeze_module abc $(srcdir)/Lib/abc.py $(srcdir)/Python/frozen_modules/abc.h.new - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/abc.h $(srcdir)/Python/frozen_modules/abc.h.new + Programs/_freeze_module abc $(srcdir)/Lib/abc.py $(srcdir)/Python/frozen_modules/abc.h Python/frozen_modules/codecs.h: Programs/_freeze_module Lib/codecs.py - Programs/_freeze_module codecs $(srcdir)/Lib/codecs.py $(srcdir)/Python/frozen_modules/codecs.h.new - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/codecs.h $(srcdir)/Python/frozen_modules/codecs.h.new + Programs/_freeze_module codecs $(srcdir)/Lib/codecs.py $(srcdir)/Python/frozen_modules/codecs.h Python/frozen_modules/io.h: Programs/_freeze_module Lib/io.py - Programs/_freeze_module io $(srcdir)/Lib/io.py $(srcdir)/Python/frozen_modules/io.h.new - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/io.h $(srcdir)/Python/frozen_modules/io.h.new + Programs/_freeze_module io $(srcdir)/Lib/io.py $(srcdir)/Python/frozen_modules/io.h Python/frozen_modules/_collections_abc.h: Programs/_freeze_module Lib/_collections_abc.py - Programs/_freeze_module _collections_abc $(srcdir)/Lib/_collections_abc.py $(srcdir)/Python/frozen_modules/_collections_abc.h.new - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/_collections_abc.h $(srcdir)/Python/frozen_modules/_collections_abc.h.new + Programs/_freeze_module _collections_abc $(srcdir)/Lib/_collections_abc.py $(srcdir)/Python/frozen_modules/_collections_abc.h Python/frozen_modules/_sitebuiltins.h: Programs/_freeze_module Lib/_sitebuiltins.py - Programs/_freeze_module _sitebuiltins $(srcdir)/Lib/_sitebuiltins.py $(srcdir)/Python/frozen_modules/_sitebuiltins.h.new - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/_sitebuiltins.h $(srcdir)/Python/frozen_modules/_sitebuiltins.h.new + Programs/_freeze_module _sitebuiltins $(srcdir)/Lib/_sitebuiltins.py $(srcdir)/Python/frozen_modules/_sitebuiltins.h Python/frozen_modules/genericpath.h: Programs/_freeze_module Lib/genericpath.py - Programs/_freeze_module genericpath $(srcdir)/Lib/genericpath.py $(srcdir)/Python/frozen_modules/genericpath.h.new - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/genericpath.h $(srcdir)/Python/frozen_modules/genericpath.h.new + Programs/_freeze_module genericpath $(srcdir)/Lib/genericpath.py $(srcdir)/Python/frozen_modules/genericpath.h Python/frozen_modules/ntpath.h: Programs/_freeze_module Lib/ntpath.py - Programs/_freeze_module ntpath $(srcdir)/Lib/ntpath.py $(srcdir)/Python/frozen_modules/ntpath.h.new - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/ntpath.h $(srcdir)/Python/frozen_modules/ntpath.h.new + Programs/_freeze_module ntpath $(srcdir)/Lib/ntpath.py $(srcdir)/Python/frozen_modules/ntpath.h Python/frozen_modules/posixpath.h: Programs/_freeze_module Lib/posixpath.py - Programs/_freeze_module posixpath $(srcdir)/Lib/posixpath.py $(srcdir)/Python/frozen_modules/posixpath.h.new - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/posixpath.h $(srcdir)/Python/frozen_modules/posixpath.h.new + Programs/_freeze_module posixpath $(srcdir)/Lib/posixpath.py $(srcdir)/Python/frozen_modules/posixpath.h Python/frozen_modules/os.h: Programs/_freeze_module Lib/os.py - Programs/_freeze_module os $(srcdir)/Lib/os.py $(srcdir)/Python/frozen_modules/os.h.new - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/os.h $(srcdir)/Python/frozen_modules/os.h.new + Programs/_freeze_module os $(srcdir)/Lib/os.py $(srcdir)/Python/frozen_modules/os.h Python/frozen_modules/site.h: Programs/_freeze_module Lib/site.py - Programs/_freeze_module site $(srcdir)/Lib/site.py $(srcdir)/Python/frozen_modules/site.h.new - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/site.h $(srcdir)/Python/frozen_modules/site.h.new + Programs/_freeze_module site $(srcdir)/Lib/site.py $(srcdir)/Python/frozen_modules/site.h Python/frozen_modules/stat.h: Programs/_freeze_module Lib/stat.py - Programs/_freeze_module stat $(srcdir)/Lib/stat.py $(srcdir)/Python/frozen_modules/stat.h.new - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/stat.h $(srcdir)/Python/frozen_modules/stat.h.new + Programs/_freeze_module stat $(srcdir)/Lib/stat.py $(srcdir)/Python/frozen_modules/stat.h Python/frozen_modules/__hello__.h: Programs/_freeze_module Lib/__hello__.py - Programs/_freeze_module __hello__ $(srcdir)/Lib/__hello__.py $(srcdir)/Python/frozen_modules/__hello__.h.new - $(UPDATE_FILE) --create $(srcdir)/Python/frozen_modules/__hello__.h $(srcdir)/Python/frozen_modules/__hello__.h.new + Programs/_freeze_module __hello__ $(srcdir)/Lib/__hello__.py $(srcdir)/Python/frozen_modules/__hello__.h # END: freezing modules diff --git a/Tools/scripts/freeze_modules.py b/Tools/scripts/freeze_modules.py index 781e5872bfeaa8..aa799d763a55b9 100644 --- a/Tools/scripts/freeze_modules.py +++ b/Tools/scripts/freeze_modules.py @@ -554,13 +554,10 @@ def regen_makefile(modules): pyfiles.append(f'\t\t{pyfile} \\') freeze = (f'Programs/_freeze_module {src.frozenid} ' - f'$(srcdir)/{pyfile} $(srcdir)/{header}.new') - update = (f'$(UPDATE_FILE) --create $(srcdir)/{header} ' - f'$(srcdir)/{header}.new') + f'$(srcdir)/{pyfile} $(srcdir)/{header}') rules.extend([ f'{header}: Programs/_freeze_module {pyfile}', f'\t{freeze}', - f'\t{update}', '', ]) pyfiles[-1] = pyfiles[-1].rstrip(" \\")