Skip to content

gh-109515: Allow a large number of frozen modules on Windows #109516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

60 changes: 30 additions & 30 deletions PCbuild/_freeze_module.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,33 @@
<OutFile>$(PySourcePath)Python\frozen_modules\getpath.h</OutFile>
</GetPath>
</ItemGroup>
<ItemGroup>
<!-- BEGIN freeze mappings -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to fix the indentation on these lines. I don't see where it is though.

Otherwise anyone who edits this file manually is likely to fix it and trigger regeneration.

<FrozenModule Include="$(PySourcePath)\Python\frozen_modules\importlib._bootstrap.h" FrozenId="importlib._bootstrap" />
<FrozenModule Include="$(PySourcePath)\Python\frozen_modules\importlib._bootstrap_external.h" FrozenId="importlib._bootstrap_external" />
<FrozenModule Include="$(PySourcePath)\Python\frozen_modules\zipimport.h" FrozenId="zipimport" />
<FrozenModule Include="$(PySourcePath)\Python\frozen_modules\abc.h" FrozenId="abc" />
<FrozenModule Include="$(PySourcePath)\Python\frozen_modules\codecs.h" FrozenId="codecs" />
<FrozenModule Include="$(PySourcePath)\Python\frozen_modules\io.h" FrozenId="io" />
<FrozenModule Include="$(PySourcePath)\Python\frozen_modules\_collections_abc.h" FrozenId="_collections_abc" />
<FrozenModule Include="$(PySourcePath)\Python\frozen_modules\_sitebuiltins.h" FrozenId="_sitebuiltins" />
<FrozenModule Include="$(PySourcePath)\Python\frozen_modules\genericpath.h" FrozenId="genericpath" />
<FrozenModule Include="$(PySourcePath)\Python\frozen_modules\ntpath.h" FrozenId="ntpath" />
<FrozenModule Include="$(PySourcePath)\Python\frozen_modules\posixpath.h" FrozenId="posixpath" />
<FrozenModule Include="$(PySourcePath)\Python\frozen_modules\os.h" FrozenId="os" />
<FrozenModule Include="$(PySourcePath)\Python\frozen_modules\site.h" FrozenId="site" />
<FrozenModule Include="$(PySourcePath)\Python\frozen_modules\stat.h" FrozenId="stat" />
<FrozenModule Include="$(PySourcePath)\Python\frozen_modules\importlib.util.h" FrozenId="importlib.util" />
<FrozenModule Include="$(PySourcePath)\Python\frozen_modules\importlib.machinery.h" FrozenId="importlib.machinery" />
<FrozenModule Include="$(PySourcePath)\Python\frozen_modules\runpy.h" FrozenId="runpy" />
<FrozenModule Include="$(PySourcePath)\Python\frozen_modules\__hello__.h" FrozenId="__hello__" />
<FrozenModule Include="$(PySourcePath)\Python\frozen_modules\__phello__.h" FrozenId="__phello__" />
<FrozenModule Include="$(PySourcePath)\Python\frozen_modules\__phello__.ham.h" FrozenId="__phello__.ham" />
<FrozenModule Include="$(PySourcePath)\Python\frozen_modules\__phello__.ham.eggs.h" FrozenId="__phello__.ham.eggs" />
<FrozenModule Include="$(PySourcePath)\Python\frozen_modules\__phello__.spam.h" FrozenId="__phello__.spam" />
<FrozenModule Include="$(PySourcePath)\Python\frozen_modules\frozen_only.h" FrozenId="frozen_only" />
<!-- END freeze mappings -->
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down Expand Up @@ -406,45 +433,18 @@
DependsOnTargets="FindPythonForBuild"
Condition="$(Configuration) != 'PGUpdate'">
<PropertyGroup>
<FreezeMappings>
<!-- BEGIN freeze mappings -->
$(PySourcePath)\Python\frozen_modules\importlib._bootstrap.h:importlib._bootstrap
$(PySourcePath)\Python\frozen_modules\importlib._bootstrap_external.h:importlib._bootstrap_external
$(PySourcePath)\Python\frozen_modules\zipimport.h:zipimport
$(PySourcePath)\Python\frozen_modules\abc.h:abc
$(PySourcePath)\Python\frozen_modules\codecs.h:codecs
$(PySourcePath)\Python\frozen_modules\io.h:io
$(PySourcePath)\Python\frozen_modules\_collections_abc.h:_collections_abc
$(PySourcePath)\Python\frozen_modules\_sitebuiltins.h:_sitebuiltins
$(PySourcePath)\Python\frozen_modules\genericpath.h:genericpath
$(PySourcePath)\Python\frozen_modules\ntpath.h:ntpath
$(PySourcePath)\Python\frozen_modules\posixpath.h:posixpath
$(PySourcePath)\Python\frozen_modules\os.h:os
$(PySourcePath)\Python\frozen_modules\site.h:site
$(PySourcePath)\Python\frozen_modules\stat.h:stat
$(PySourcePath)\Python\frozen_modules\importlib.util.h:importlib.util
$(PySourcePath)\Python\frozen_modules\importlib.machinery.h:importlib.machinery
$(PySourcePath)\Python\frozen_modules\runpy.h:runpy
$(PySourcePath)\Python\frozen_modules\__hello__.h:__hello__
$(PySourcePath)\Python\frozen_modules\__phello__.h:__phello__
$(PySourcePath)\Python\frozen_modules\__phello__.ham.h:__phello__.ham
$(PySourcePath)\Python\frozen_modules\__phello__.ham.eggs.h:__phello__.ham.eggs
$(PySourcePath)\Python\frozen_modules\__phello__.spam.h:__phello__.spam
$(PySourcePath)\Python\frozen_modules\frozen_only.h:frozen_only
<!-- END freeze mappings -->
</FreezeMappings>
<FreezeMappingsFile>
<!-- BEGIN freeze mapping file -->
$(PySourcePath)PCbuild\deepfreeze_mappings.txt
$(IntDir)\deepfreeze_mappings.txt
<!-- END freeze mapping file -->
</FreezeMappingsFile>
</PropertyGroup>
<WriteLinesToFile
File="$(FreezeMappingsFile)"
Overwrite="true"
Lines="$(FreezeMappings)" />
Lines="@(FrozenModule->'%(FullPath):%(FrozenId)')" />
<!-- BEGIN deepfreeze rule -->
<Exec Command='$(PythonForBuild) "$(PySourcePath)Tools\build\deepfreeze.py" -f "$(PySourcePath)PCbuild\deepfreeze_mappings.txt" -o "$(PySourcePath)Python\deepfreeze\deepfreeze.c"' />
<Exec Command='$(PythonForBuild) "$(PySourcePath)Tools\build\deepfreeze.py" -f "$(IntDir)\deepfreeze_mappings.txt" -o "$(PySourcePath)Python\deepfreeze\deepfreeze.c"' />
<!-- END deepfreeze rule -->
</Target>
<Target Name="_CleanFrozen" BeforeTargets="CoreClean" Condition="$(Configuration) != 'PGUpdate'">
Expand Down
4 changes: 2 additions & 2 deletions Tools/build/deepfreeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,8 @@ def main() -> None:
if args.file:
if verbose:
print(f"reading rules from {args.file}")
with open(args.file, "rt", encoding="utf-8") as fin:
rules = [x.strip() for x in fin.readlines()]
with open(args.file, "rt", encoding="utf-8-sig") as fin:
rules = [x.strip() for x in fin]
elif args.args:
rules = args.args
else:
Expand Down
4 changes: 2 additions & 2 deletions Tools/build/freeze_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ def regen_pcbuild(modules):
projlines = []
filterlines = []
corelines = []
deepfreezemappingsfile = f'$(PySourcePath)PCbuild\\{DEEPFREEZE_MAPPING_FNAME}'
deepfreezemappingsfile = f'$(IntDir)\\{DEEPFREEZE_MAPPING_FNAME}'
deepfreezerules = [f'\t<Exec Command=\'$(PythonForBuild) "$(PySourcePath)Tools\\build\\deepfreeze.py" -f "{deepfreezemappingsfile}" -o "$(PySourcePath)Python\\deepfreeze\\deepfreeze.c"\' />']
deepfreezemappings = []
for src in _iter_sources(modules):
Expand All @@ -662,7 +662,7 @@ def regen_pcbuild(modules):
filterlines.append(f' <None Include="..\\{pyfile}">')
filterlines.append(' <Filter>Python Files</Filter>')
filterlines.append(' </None>')
deepfreezemappings.append(f'$(PySourcePath)\\{header}:{src.frozenid}\n')
deepfreezemappings.append(f'\t<FrozenModule Include="$(PySourcePath)\\{header}" FrozenId="{src.frozenid}" />\n')

corelines.append(f' <ClCompile Include="..\\Python\\deepfreeze\\deepfreeze.c" />')

Expand Down