diff options
author | Guido van Rossum <guido@python.org> | 2021-11-22 18:09:48 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-22 18:09:48 (GMT) |
commit | 1037ca5a8ea001bfa2a198e08655620234e9befd (patch) | |
tree | dcf9b1966caca1eab0437f730f487701a960d851 /Tools/scripts/freeze_modules.py | |
parent | 4d6c0c0cce05befa06e0cad7351b1303ac048277 (diff) | |
download | cpython-1037ca5a8ea001bfa2a198e08655620234e9befd.zip cpython-1037ca5a8ea001bfa2a198e08655620234e9befd.tar.gz cpython-1037ca5a8ea001bfa2a198e08655620234e9befd.tar.bz2 |
bpo-45850: Implement deep-freeze on Windows (#29648)
Implement changes to build with deep-frozen modules on Windows.
Note that we now require Python 3.10 as the "bootstrap" or "host" Python.
This causes a modest startup speed (around 7%) on Windows.
Diffstat (limited to 'Tools/scripts/freeze_modules.py')
-rw-r--r-- | Tools/scripts/freeze_modules.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/Tools/scripts/freeze_modules.py b/Tools/scripts/freeze_modules.py index ccea4e1..61ccae6 100644 --- a/Tools/scripts/freeze_modules.py +++ b/Tools/scripts/freeze_modules.py @@ -11,7 +11,6 @@ import posixpath import platform import subprocess import sys -import textwrap import time from update_file import updating_file_with_tmpfile, update_file_with_tmpfile @@ -55,6 +54,7 @@ FROZEN_FILE = os.path.join(ROOT_DIR, 'Python', 'frozen.c') MAKEFILE = os.path.join(ROOT_DIR, 'Makefile.pre.in') PCBUILD_PROJECT = os.path.join(ROOT_DIR, 'PCbuild', '_freeze_module.vcxproj') PCBUILD_FILTERS = os.path.join(ROOT_DIR, 'PCbuild', '_freeze_module.vcxproj.filters') +PCBUILD_PYTHONCORE = os.path.join(ROOT_DIR, 'PCbuild', 'pythoncore.vcxproj') OS_PATH = 'ntpath' if os.name == 'nt' else 'posixpath' @@ -717,20 +717,28 @@ def regen_makefile(modules): def regen_pcbuild(modules): projlines = [] filterlines = [] + corelines = [] for src in _iter_sources(modules): pyfile = relpath_for_windows_display(src.pyfile, ROOT_DIR) header = relpath_for_windows_display(src.frozenfile, ROOT_DIR) + deepbase = "df." + src.id + deepoutfile = f"Python\\deepfreeze\\{deepbase}.c" intfile = ntpath.splitext(ntpath.basename(header))[0] + '.g.h' + deepintfile = ntpath.splitext(ntpath.basename(header))[0] + '.g.c' projlines.append(f' <None Include="..\\{pyfile}">') projlines.append(f' <ModName>{src.frozenid}</ModName>') projlines.append(f' <IntFile>$(IntDir){intfile}</IntFile>') projlines.append(f' <OutFile>$(PySourcePath){header}</OutFile>') + projlines.append(f' <DeepIntFile>$(IntDir){deepintfile}</DeepIntFile>') + projlines.append(f' <DeepOutFile>$(PySourcePath){deepoutfile}</DeepOutFile>') projlines.append(f' </None>') filterlines.append(f' <None Include="..\\{pyfile}">') filterlines.append(' <Filter>Python Files</Filter>') filterlines.append(' </None>') + corelines.append(f' <ClCompile Include="..\\{deepoutfile}" />') + print(f'# Updating {os.path.relpath(PCBUILD_PROJECT)}') with updating_file_with_tmpfile(PCBUILD_PROJECT) as (infile, outfile): lines = infile.readlines() @@ -753,6 +761,17 @@ 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) ####################################### |