Skip to content
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
Prev Previous commit
Next Next commit
Properly generate lines in pythoncore.vcxproj; add codecs back
  • Loading branch information
gvanrossum committed Nov 19, 2021
commit 1bc777f607ccbea8934c2a6df402db80722f420c
44 changes: 25 additions & 19 deletions PCbuild/_freeze_module.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -234,115 +234,121 @@
<ModName>importlib._bootstrap</ModName>
<IntFile>$(IntDir)importlib._bootstrap.g.h</IntFile>
<OutFile>$(PySourcePath)Python\frozen_modules\importlib._bootstrap.h</OutFile>
<DeepOutFile>$(PySourcePath)Python/deepfreeze/importlib._bootstrap.c</DeepOutFile>
<DeepOutFile>$(PySourcePath)Python\deepfreeze\importlib._bootstrap.c</DeepOutFile>
</None>
<None Include="..\Lib\importlib\_bootstrap_external.py">
<ModName>importlib._bootstrap_external</ModName>
<IntFile>$(IntDir)importlib._bootstrap_external.g.h</IntFile>
<OutFile>$(PySourcePath)Python\frozen_modules\importlib._bootstrap_external.h</OutFile>
<DeepOutFile>$(PySourcePath)Python/deepfreeze/importlib._bootstrap_external.c</DeepOutFile>
<DeepOutFile>$(PySourcePath)Python\deepfreeze\importlib._bootstrap_external.c</DeepOutFile>
</None>
<None Include="..\Lib\zipimport.py">
<ModName>zipimport</ModName>
<IntFile>$(IntDir)zipimport.g.h</IntFile>
<OutFile>$(PySourcePath)Python\frozen_modules\zipimport.h</OutFile>
<DeepOutFile>$(PySourcePath)Python/deepfreeze/zipimport.c</DeepOutFile>
<DeepOutFile>$(PySourcePath)Python\deepfreeze\zipimport.c</DeepOutFile>
</None>
<None Include="..\Lib\abc.py">
<ModName>abc</ModName>
<IntFile>$(IntDir)abc.g.h</IntFile>
<OutFile>$(PySourcePath)Python\frozen_modules\abc.h</OutFile>
<DeepOutFile>$(PySourcePath)Python/deepfreeze/abc.c</DeepOutFile>
<DeepOutFile>$(PySourcePath)Python\deepfreeze\abc.c</DeepOutFile>
</None>
<None Include="..\Lib\codecs.py">
<ModName>codecs</ModName>
<IntFile>$(IntDir)codecs.g.h</IntFile>
<OutFile>$(PySourcePath)Python\frozen_modules\codecs.h</OutFile>
<DeepOutFile>$(PySourcePath)Python\deepfreeze\codecs_.c</DeepOutFile>
</None>
<None Include="..\Lib\io.py">
<ModName>io</ModName>
<IntFile>$(IntDir)io.g.h</IntFile>
<OutFile>$(PySourcePath)Python\frozen_modules\io.h</OutFile>
<DeepOutFile>$(PySourcePath)Python/deepfreeze/io.c</DeepOutFile>
<DeepOutFile>$(PySourcePath)Python\deepfreeze\io.c</DeepOutFile>
</None>
<None Include="..\Lib\_collections_abc.py">
<ModName>_collections_abc</ModName>
<IntFile>$(IntDir)_collections_abc.g.h</IntFile>
<OutFile>$(PySourcePath)Python\frozen_modules\_collections_abc.h</OutFile>
<DeepOutFile>$(PySourcePath)Python/deepfreeze/_collections_abc.c</DeepOutFile>
<DeepOutFile>$(PySourcePath)Python\deepfreeze\_collections_abc.c</DeepOutFile>
</None>
<None Include="..\Lib\_sitebuiltins.py">
<ModName>_sitebuiltins</ModName>
<IntFile>$(IntDir)_sitebuiltins.g.h</IntFile>
<OutFile>$(PySourcePath)Python\frozen_modules\_sitebuiltins.h</OutFile>
<DeepOutFile>$(PySourcePath)Python/deepfreeze/_sitebuiltins.c</DeepOutFile>
<DeepOutFile>$(PySourcePath)Python\deepfreeze\_sitebuiltins.c</DeepOutFile>
</None>
<None Include="..\Lib\genericpath.py">
<ModName>genericpath</ModName>
<IntFile>$(IntDir)genericpath.g.h</IntFile>
<OutFile>$(PySourcePath)Python\frozen_modules\genericpath.h</OutFile>
<DeepOutFile>$(PySourcePath)Python/deepfreeze/genericpath.c</DeepOutFile>
<DeepOutFile>$(PySourcePath)Python\deepfreeze\genericpath.c</DeepOutFile>
</None>
<None Include="..\Lib\ntpath.py">
<ModName>ntpath</ModName>
<IntFile>$(IntDir)ntpath.g.h</IntFile>
<OutFile>$(PySourcePath)Python\frozen_modules\ntpath.h</OutFile>
<DeepOutFile>$(PySourcePath)Python/deepfreeze/ntpath.c</DeepOutFile>
<DeepOutFile>$(PySourcePath)Python\deepfreeze\ntpath.c</DeepOutFile>
</None>
<None Include="..\Lib\posixpath.py">
<ModName>posixpath</ModName>
<IntFile>$(IntDir)posixpath.g.h</IntFile>
<OutFile>$(PySourcePath)Python\frozen_modules\posixpath.h</OutFile>
<DeepOutFile>$(PySourcePath)Python/deepfreeze/posixpath.c</DeepOutFile>
<DeepOutFile>$(PySourcePath)Python\deepfreeze\posixpath.c</DeepOutFile>
</None>
<None Include="..\Lib\os.py">
<ModName>os</ModName>
<IntFile>$(IntDir)os.g.h</IntFile>
<OutFile>$(PySourcePath)Python\frozen_modules\os.h</OutFile>
<DeepOutFile>$(PySourcePath)Python/deepfreeze/os.c</DeepOutFile>
<DeepOutFile>$(PySourcePath)Python\deepfreeze\os.c</DeepOutFile>
</None>
<None Include="..\Lib\site.py">
<ModName>site</ModName>
<IntFile>$(IntDir)site.g.h</IntFile>
<OutFile>$(PySourcePath)Python\frozen_modules\site.h</OutFile>
<DeepOutFile>$(PySourcePath)Python/deepfreeze/site.c</DeepOutFile>
<DeepOutFile>$(PySourcePath)Python\deepfreeze\site.c</DeepOutFile>
</None>
<None Include="..\Lib\stat.py">
<ModName>stat</ModName>
<IntFile>$(IntDir)stat.g.h</IntFile>
<OutFile>$(PySourcePath)Python\frozen_modules\stat.h</OutFile>
<DeepOutFile>$(PySourcePath)Python/deepfreeze/stat.c</DeepOutFile>
<DeepOutFile>$(PySourcePath)Python\deepfreeze\stat.c</DeepOutFile>
</None>
<None Include="..\Lib\__hello__.py">
<ModName>__hello__</ModName>
<IntFile>$(IntDir)__hello__.g.h</IntFile>
<OutFile>$(PySourcePath)Python\frozen_modules\__hello__.h</OutFile>
<DeepOutFile>$(PySourcePath)Python/deepfreeze/__hello__.c</DeepOutFile>
<DeepOutFile>$(PySourcePath)Python\deepfreeze\__hello__.c</DeepOutFile>
</None>
<None Include="..\Lib\__phello__\__init__.py">
<ModName>__phello__</ModName>
<IntFile>$(IntDir)__phello__.g.h</IntFile>
<OutFile>$(PySourcePath)Python\frozen_modules\__phello__.h</OutFile>
<DeepOutFile>$(PySourcePath)Python/deepfreeze/__phello__.c</DeepOutFile>
<DeepOutFile>$(PySourcePath)Python\deepfreeze\__phello__.c</DeepOutFile>
</None>
<None Include="..\Lib\__phello__\ham\__init__.py">
<ModName>__phello__.ham</ModName>
<IntFile>$(IntDir)__phello__.ham.g.h</IntFile>
<OutFile>$(PySourcePath)Python\frozen_modules\__phello__.ham.h</OutFile>
<DeepOutFile>$(PySourcePath)Python/deepfreeze/__phello__.ham.c</DeepOutFile>
<DeepOutFile>$(PySourcePath)Python\deepfreeze\__phello__.ham.c</DeepOutFile>
</None>
<None Include="..\Lib\__phello__\ham\eggs.py">
<ModName>__phello__.ham.eggs</ModName>
<IntFile>$(IntDir)__phello__.ham.eggs.g.h</IntFile>
<OutFile>$(PySourcePath)Python\frozen_modules\__phello__.ham.eggs.h</OutFile>
<DeepOutFile>$(PySourcePath)Python/deepfreeze/__phello__.ham.eggs.c</DeepOutFile>
<DeepOutFile>$(PySourcePath)Python\deepfreeze\__phello__.ham.eggs.c</DeepOutFile>
</None>
<None Include="..\Lib\__phello__\spam.py">
<ModName>__phello__.spam</ModName>
<IntFile>$(IntDir)__phello__.spam.g.h</IntFile>
<OutFile>$(PySourcePath)Python\frozen_modules\__phello__.spam.h</OutFile>
<DeepOutFile>$(PySourcePath)Python/deepfreeze/__phello__.spam.c</DeepOutFile>
<DeepOutFile>$(PySourcePath)Python\deepfreeze\__phello__.spam.c</DeepOutFile>
</None>
<None Include="..\Tools\freeze\flag.py">
<ModName>frozen_only</ModName>
<IntFile>$(IntDir)frozen_only.g.h</IntFile>
<OutFile>$(PySourcePath)Python\frozen_modules\frozen_only.h</OutFile>
<DeepOutFile>$(PySourcePath)Python/deepfreeze/frozen_only.c</DeepOutFile>
<DeepOutFile>$(PySourcePath)Python\deepfreeze\frozen_only.c</DeepOutFile>
</None>
<!-- END frozen modules -->
</ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions PCbuild/_freeze_module.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
<None Include="..\Lib\abc.py">
<Filter>Python Files</Filter>
</None>
<None Include="..\Lib\codecs.py">
<Filter>Python Files</Filter>
</None>
<None Include="..\Lib\io.py">
<Filter>Python Files</Filter>
</None>
Expand Down
40 changes: 20 additions & 20 deletions PCbuild/pythoncore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -502,26 +502,26 @@
</ItemGroup>
<ItemGroup>
<!-- BEGIN deepfreeze -->
<ClCompile Include="..\Python\deepfreeze\importlib._bootstrap.c" />
<ClCompile Include="..\Python\deepfreeze\importlib._bootstrap_external.c" />
<ClCompile Include="..\Python\deepfreeze\zipimport.c" />
<ClCompile Include="..\Python\deepfreeze\abc.c" />
<!-- <ClCompile Include="..\Python\deepfreeze\codecs.c" /> -->
<ClCompile Include="..\Python\deepfreeze\io.c" />
<ClCompile Include="..\Python\deepfreeze\_collections_abc.c" />
<ClCompile Include="..\Python\deepfreeze\_sitebuiltins.c" />
<ClCompile Include="..\Python\deepfreeze\genericpath.c" />
<ClCompile Include="..\Python\deepfreeze\ntpath.c" />
<ClCompile Include="..\Python\deepfreeze\posixpath.c" />
<ClCompile Include="..\Python\deepfreeze\os.c" />
<ClCompile Include="..\Python\deepfreeze\site.c" />
<ClCompile Include="..\Python\deepfreeze\stat.c" />
<ClCompile Include="..\Python\deepfreeze\__hello__.c" />
<ClCompile Include="..\Python\deepfreeze\__phello__.c" />
<ClCompile Include="..\Python\deepfreeze\__phello__.spam.c" />
<ClCompile Include="..\Python\deepfreeze\__phello__.ham.c" />
<ClCompile Include="..\Python\deepfreeze\__phello__.ham.eggs.c" />
<ClCompile Include="..\Python\deepfreeze\frozen_only.c" />
<ClCompile Include="..\Python\deepfreeze\importlib._bootstrap.c" />
<ClCompile Include="..\Python\deepfreeze\importlib._bootstrap_external.c" />
<ClCompile Include="..\Python\deepfreeze\zipimport.c" />
<ClCompile Include="..\Python\deepfreeze\abc.c" />
<ClCompile Include="..\Python\deepfreeze\codecs_.c" />
<ClCompile Include="..\Python\deepfreeze\io.c" />
<ClCompile Include="..\Python\deepfreeze\_collections_abc.c" />
<ClCompile Include="..\Python\deepfreeze\_sitebuiltins.c" />
<ClCompile Include="..\Python\deepfreeze\genericpath.c" />
<ClCompile Include="..\Python\deepfreeze\ntpath.c" />
<ClCompile Include="..\Python\deepfreeze\posixpath.c" />
<ClCompile Include="..\Python\deepfreeze\os.c" />
<ClCompile Include="..\Python\deepfreeze\site.c" />
<ClCompile Include="..\Python\deepfreeze\stat.c" />
<ClCompile Include="..\Python\deepfreeze\__hello__.c" />
<ClCompile Include="..\Python\deepfreeze\__phello__.c" />
<ClCompile Include="..\Python\deepfreeze\__phello__.ham.c" />
<ClCompile Include="..\Python\deepfreeze\__phello__.ham.eggs.c" />
<ClCompile Include="..\Python\deepfreeze\__phello__.spam.c" />
<ClCompile Include="..\Python\deepfreeze\frozen_only.c" />
<!-- END deepfreeze -->
</ItemGroup>
<ItemGroup Condition="$(IncludeExternals)">
Expand Down
8 changes: 4 additions & 4 deletions Python/frozen.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ 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_posixpath_toplevel(void);
extern PyObject *_Py_get_ntpath_toplevel(void);
extern PyObject *_Py_get_os_toplevel(void);
extern PyObject *_Py_get_site_toplevel(void);
extern PyObject *_Py_get_stat_toplevel(void);
Expand Down Expand Up @@ -103,7 +103,7 @@ static const struct _frozen bootstrap_modules[] = {
static const struct _frozen stdlib_modules[] = {
/* stdlib - startup, without site (python -S) */
{"abc", _Py_M__abc, (int)sizeof(_Py_M__abc), GET_CODE(abc)},
// {"codecs", _Py_M__codecs, (int)sizeof(_Py_M__codecs), GET_CODE(codecs)},
{"codecs", _Py_M__codecs, (int)sizeof(_Py_M__codecs), GET_CODE(codecs)},
{"io", _Py_M__io, (int)sizeof(_Py_M__io), GET_CODE(io)},

/* stdlib - startup, with site */
Expand All @@ -112,7 +112,7 @@ static const struct _frozen stdlib_modules[] = {
{"genericpath", _Py_M__genericpath, (int)sizeof(_Py_M__genericpath), GET_CODE(genericpath)},
{"ntpath", _Py_M__ntpath, (int)sizeof(_Py_M__ntpath), GET_CODE(ntpath)},
{"posixpath", _Py_M__posixpath, (int)sizeof(_Py_M__posixpath), GET_CODE(posixpath)},
{"os.path", _Py_M__posixpath, (int)sizeof(_Py_M__posixpath), GET_CODE(posixpath)},
{"os.path", _Py_M__ntpath, (int)sizeof(_Py_M__ntpath), GET_CODE(ntpath)},
Comment thread
gvanrossum marked this conversation as resolved.
Outdated
{"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)},
Expand All @@ -139,7 +139,7 @@ const struct _frozen *_PyImport_FrozenTest = test_modules;
static const struct _module_alias aliases[] = {
{"_frozen_importlib", "importlib._bootstrap"},
{"_frozen_importlib_external", "importlib._bootstrap_external"},
{"os.path", "posixpath"},
{"os.path", "ntpath"},
{"__hello_alias__", "__hello__"},
{"__phello_alias__", "__hello__"},
{"__phello_alias__.spam", "__hello__"},
Expand Down
23 changes: 20 additions & 3 deletions Tools/scripts/freeze_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import platform
import subprocess
import sys
import textwrap
import time

from update_file import updating_file_with_tmpfile, update_file_with_tmpfile
Expand Down Expand Up @@ -55,6 +54,7 @@ def find_tool():
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'
Expand All @@ -75,7 +75,7 @@ def find_tool():
]),
('stdlib - startup, without site (python -S)', [
'abc',
# 'codecs', # TODO: Windows name conflict with Python\codecs.c
'codecs',
# For now we do not freeze the encodings, due # to the noise all
# those extra modules add to the text printed during the build.
# (See https://github.com/python/cpython/pull/28398#pullrequestreview-756856469.)
Expand Down Expand Up @@ -717,10 +717,14 @@ 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)
deepoutfile = f"Python/deepfreeze/{src.id}.c"
deepbase = src.id
if deepbase == "codecs":
deepbase = "codecs_" # Annoying exception (duplicate file)
deepoutfile = f"Python\\deepfreeze\\{deepbase}.c"
intfile = ntpath.splitext(ntpath.basename(header))[0] + '.g.h'
projlines.append(f' <None Include="..\\{pyfile}">')
projlines.append(f' <ModName>{src.frozenid}</ModName>')
Expand All @@ -733,6 +737,8 @@ def regen_pcbuild(modules):
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()
Expand All @@ -755,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)


#######################################
Expand Down