From 0d41300e5b31042436de6ff1d4744ac19ef22406 Mon Sep 17 00:00:00 2001 From: Itamar Ostricher Date: Tue, 19 Dec 2023 19:35:45 -0800 Subject: [PATCH 1/7] gh-113258: Write frozen modules to IntDir --- Modules/getpath.c | 2 +- PCbuild/_freeze_module.vcxproj | 98 +++++++++++++++++----------------- PCbuild/pythoncore.vcxproj | 6 ++- 3 files changed, 54 insertions(+), 52 deletions(-) diff --git a/Modules/getpath.c b/Modules/getpath.c index a3c8fc269d1c3c..da02fe401be22e 100644 --- a/Modules/getpath.c +++ b/Modules/getpath.c @@ -22,7 +22,7 @@ #endif /* Reference the precompiled getpath.py */ -#include "Python/frozen_modules/getpath.h" +#include "frozen_modules/getpath.h" #if (!defined(PREFIX) || !defined(EXEC_PREFIX) \ || !defined(VERSION) || !defined(VPATH) \ diff --git a/PCbuild/_freeze_module.vcxproj b/PCbuild/_freeze_module.vcxproj index f8c5fafa561efa..1978ae5c8e6cd2 100644 --- a/PCbuild/_freeze_module.vcxproj +++ b/PCbuild/_freeze_module.vcxproj @@ -266,117 +266,117 @@ importlib._bootstrap $(IntDir)importlib._bootstrap.g.h - $(PySourcePath)Python\frozen_modules\importlib._bootstrap.h + $(IntDir)frozen_modules\importlib._bootstrap.h importlib._bootstrap_external $(IntDir)importlib._bootstrap_external.g.h - $(PySourcePath)Python\frozen_modules\importlib._bootstrap_external.h + $(IntDir)frozen_modules\importlib._bootstrap_external.h zipimport $(IntDir)zipimport.g.h - $(PySourcePath)Python\frozen_modules\zipimport.h + $(IntDir)frozen_modules\zipimport.h abc $(IntDir)abc.g.h - $(PySourcePath)Python\frozen_modules\abc.h + $(IntDir)frozen_modules\abc.h codecs $(IntDir)codecs.g.h - $(PySourcePath)Python\frozen_modules\codecs.h + $(IntDir)frozen_modules\codecs.h io $(IntDir)io.g.h - $(PySourcePath)Python\frozen_modules\io.h + $(IntDir)frozen_modules\io.h _collections_abc $(IntDir)_collections_abc.g.h - $(PySourcePath)Python\frozen_modules\_collections_abc.h + $(IntDir)frozen_modules\_collections_abc.h _sitebuiltins $(IntDir)_sitebuiltins.g.h - $(PySourcePath)Python\frozen_modules\_sitebuiltins.h + $(IntDir)frozen_modules\_sitebuiltins.h genericpath $(IntDir)genericpath.g.h - $(PySourcePath)Python\frozen_modules\genericpath.h + $(IntDir)frozen_modules\genericpath.h ntpath $(IntDir)ntpath.g.h - $(PySourcePath)Python\frozen_modules\ntpath.h + $(IntDir)frozen_modules\ntpath.h posixpath $(IntDir)posixpath.g.h - $(PySourcePath)Python\frozen_modules\posixpath.h + $(IntDir)frozen_modules\posixpath.h os $(IntDir)os.g.h - $(PySourcePath)Python\frozen_modules\os.h + $(IntDir)frozen_modules\os.h site $(IntDir)site.g.h - $(PySourcePath)Python\frozen_modules\site.h + $(IntDir)frozen_modules\site.h stat $(IntDir)stat.g.h - $(PySourcePath)Python\frozen_modules\stat.h + $(IntDir)frozen_modules\stat.h importlib.util $(IntDir)importlib.util.g.h - $(PySourcePath)Python\frozen_modules\importlib.util.h + $(IntDir)frozen_modules\importlib.util.h importlib.machinery $(IntDir)importlib.machinery.g.h - $(PySourcePath)Python\frozen_modules\importlib.machinery.h + $(IntDir)frozen_modules\importlib.machinery.h runpy $(IntDir)runpy.g.h - $(PySourcePath)Python\frozen_modules\runpy.h + $(IntDir)frozen_modules\runpy.h __hello__ $(IntDir)__hello__.g.h - $(PySourcePath)Python\frozen_modules\__hello__.h + $(IntDir)frozen_modules\__hello__.h __phello__ $(IntDir)__phello__.g.h - $(PySourcePath)Python\frozen_modules\__phello__.h + $(IntDir)frozen_modules\__phello__.h __phello__.ham $(IntDir)__phello__.ham.g.h - $(PySourcePath)Python\frozen_modules\__phello__.ham.h + $(IntDir)frozen_modules\__phello__.ham.h __phello__.ham.eggs $(IntDir)__phello__.ham.eggs.g.h - $(PySourcePath)Python\frozen_modules\__phello__.ham.eggs.h + $(IntDir)frozen_modules\__phello__.ham.eggs.h __phello__.spam $(IntDir)__phello__.spam.g.h - $(PySourcePath)Python\frozen_modules\__phello__.spam.h + $(IntDir)frozen_modules\__phello__.spam.h frozen_only $(IntDir)frozen_only.g.h - $(PySourcePath)Python\frozen_modules\frozen_only.h + $(IntDir)frozen_modules\frozen_only.h @@ -385,34 +385,34 @@ getpath $(IntDir)getpath.g.h - $(PySourcePath)Python\frozen_modules\getpath.h + $(IntDir)frozen_modules\getpath.h - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -484,7 +484,7 @@ $(IntDir)\deepfreeze_mappings.txt Overwrite="true" Lines="@(FrozenModule->'%(FullPath):%(FrozenId)')" /> - + @@ -493,7 +493,7 @@ $(IntDir)\deepfreeze_mappings.txt - + diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index c90ad1a3592f67..cb7d35ba958a3b 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -120,7 +120,7 @@ PLATLIBDIR="DLLs"; %(PreprocessorDefinitions) - $(PySourcePath);%(AdditionalIncludeDirectories) + $(IntDir);%(AdditionalIncludeDirectories) @@ -562,7 +562,9 @@ - + + $(IntDir);%(AdditionalIncludeDirectories) + From 4c069c4405d4a42a02a627eb88ca63935b3ed71d Mon Sep 17 00:00:00 2001 From: Itamar Ostricher Date: Wed, 20 Dec 2023 18:45:54 -0800 Subject: [PATCH 2/7] Use $(GeneratedFrozenModulesDir) --- Modules/getpath.c | 2 +- PCbuild/_freeze_module.vcxproj | 98 +++++++++++++++++----------------- PCbuild/pyproject.props | 1 + PCbuild/pythoncore.vcxproj | 6 +-- Tools/build/freeze_modules.py | 8 +-- 5 files changed, 58 insertions(+), 57 deletions(-) diff --git a/Modules/getpath.c b/Modules/getpath.c index da02fe401be22e..a3c8fc269d1c3c 100644 --- a/Modules/getpath.c +++ b/Modules/getpath.c @@ -22,7 +22,7 @@ #endif /* Reference the precompiled getpath.py */ -#include "frozen_modules/getpath.h" +#include "Python/frozen_modules/getpath.h" #if (!defined(PREFIX) || !defined(EXEC_PREFIX) \ || !defined(VERSION) || !defined(VPATH) \ diff --git a/PCbuild/_freeze_module.vcxproj b/PCbuild/_freeze_module.vcxproj index 1978ae5c8e6cd2..292bfa76519507 100644 --- a/PCbuild/_freeze_module.vcxproj +++ b/PCbuild/_freeze_module.vcxproj @@ -266,117 +266,117 @@ importlib._bootstrap $(IntDir)importlib._bootstrap.g.h - $(IntDir)frozen_modules\importlib._bootstrap.h + $(GeneratedFrozenModulesDir)Python\frozen_modules\importlib._bootstrap.h importlib._bootstrap_external $(IntDir)importlib._bootstrap_external.g.h - $(IntDir)frozen_modules\importlib._bootstrap_external.h + $(GeneratedFrozenModulesDir)Python\frozen_modules\importlib._bootstrap_external.h zipimport $(IntDir)zipimport.g.h - $(IntDir)frozen_modules\zipimport.h + $(GeneratedFrozenModulesDir)Python\frozen_modules\zipimport.h abc $(IntDir)abc.g.h - $(IntDir)frozen_modules\abc.h + $(GeneratedFrozenModulesDir)Python\frozen_modules\abc.h codecs $(IntDir)codecs.g.h - $(IntDir)frozen_modules\codecs.h + $(GeneratedFrozenModulesDir)Python\frozen_modules\codecs.h io $(IntDir)io.g.h - $(IntDir)frozen_modules\io.h + $(GeneratedFrozenModulesDir)Python\frozen_modules\io.h _collections_abc $(IntDir)_collections_abc.g.h - $(IntDir)frozen_modules\_collections_abc.h + $(GeneratedFrozenModulesDir)Python\frozen_modules\_collections_abc.h _sitebuiltins $(IntDir)_sitebuiltins.g.h - $(IntDir)frozen_modules\_sitebuiltins.h + $(GeneratedFrozenModulesDir)Python\frozen_modules\_sitebuiltins.h genericpath $(IntDir)genericpath.g.h - $(IntDir)frozen_modules\genericpath.h + $(GeneratedFrozenModulesDir)Python\frozen_modules\genericpath.h ntpath $(IntDir)ntpath.g.h - $(IntDir)frozen_modules\ntpath.h + $(GeneratedFrozenModulesDir)Python\frozen_modules\ntpath.h posixpath $(IntDir)posixpath.g.h - $(IntDir)frozen_modules\posixpath.h + $(GeneratedFrozenModulesDir)Python\frozen_modules\posixpath.h os $(IntDir)os.g.h - $(IntDir)frozen_modules\os.h + $(GeneratedFrozenModulesDir)Python\frozen_modules\os.h site $(IntDir)site.g.h - $(IntDir)frozen_modules\site.h + $(GeneratedFrozenModulesDir)Python\frozen_modules\site.h stat $(IntDir)stat.g.h - $(IntDir)frozen_modules\stat.h + $(GeneratedFrozenModulesDir)Python\frozen_modules\stat.h importlib.util $(IntDir)importlib.util.g.h - $(IntDir)frozen_modules\importlib.util.h + $(GeneratedFrozenModulesDir)Python\frozen_modules\importlib.util.h importlib.machinery $(IntDir)importlib.machinery.g.h - $(IntDir)frozen_modules\importlib.machinery.h + $(GeneratedFrozenModulesDir)Python\frozen_modules\importlib.machinery.h runpy $(IntDir)runpy.g.h - $(IntDir)frozen_modules\runpy.h + $(GeneratedFrozenModulesDir)Python\frozen_modules\runpy.h __hello__ $(IntDir)__hello__.g.h - $(IntDir)frozen_modules\__hello__.h + $(GeneratedFrozenModulesDir)Python\frozen_modules\__hello__.h __phello__ $(IntDir)__phello__.g.h - $(IntDir)frozen_modules\__phello__.h + $(GeneratedFrozenModulesDir)Python\frozen_modules\__phello__.h __phello__.ham $(IntDir)__phello__.ham.g.h - $(IntDir)frozen_modules\__phello__.ham.h + $(GeneratedFrozenModulesDir)Python\frozen_modules\__phello__.ham.h __phello__.ham.eggs $(IntDir)__phello__.ham.eggs.g.h - $(IntDir)frozen_modules\__phello__.ham.eggs.h + $(GeneratedFrozenModulesDir)Python\frozen_modules\__phello__.ham.eggs.h __phello__.spam $(IntDir)__phello__.spam.g.h - $(IntDir)frozen_modules\__phello__.spam.h + $(GeneratedFrozenModulesDir)Python\frozen_modules\__phello__.spam.h frozen_only $(IntDir)frozen_only.g.h - $(IntDir)frozen_modules\frozen_only.h + $(GeneratedFrozenModulesDir)Python\frozen_modules\frozen_only.h @@ -385,34 +385,34 @@ getpath $(IntDir)getpath.g.h - $(IntDir)frozen_modules\getpath.h + $(GeneratedFrozenModulesDir)Python\frozen_modules\getpath.h - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -484,7 +484,7 @@ $(IntDir)\deepfreeze_mappings.txt Overwrite="true" Lines="@(FrozenModule->'%(FullPath):%(FrozenId)')" /> - + @@ -493,7 +493,7 @@ $(IntDir)\deepfreeze_mappings.txt - + diff --git a/PCbuild/pyproject.props b/PCbuild/pyproject.props index 68c0550f7603b7..66eb2e8410d206 100644 --- a/PCbuild/pyproject.props +++ b/PCbuild/pyproject.props @@ -12,6 +12,7 @@ $(IntDir.Replace(`\\`, `\`)) $(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)$(ArchName)_$(Configuration)\pythoncore\ + $(Py_IntDir)\frozen\ $(ProjectName) $(TargetName)$(PyDebugExt) false diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index cb7d35ba958a3b..dc2f39ef6b9644 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -111,6 +111,7 @@ + $(GeneratedFrozenModulesDir);%(AdditionalIncludeDirectories) PREFIX=NULL; EXEC_PREFIX=NULL; @@ -120,7 +121,6 @@ PLATLIBDIR="DLLs"; %(PreprocessorDefinitions) - $(IntDir);%(AdditionalIncludeDirectories) @@ -563,7 +563,7 @@ - $(IntDir);%(AdditionalIncludeDirectories) + $(IntDir);$(GeneratedFrozenModulesDir)Python;%(AdditionalIncludeDirectories) @@ -619,7 +619,7 @@ - + diff --git a/Tools/build/freeze_modules.py b/Tools/build/freeze_modules.py index 6a54f45bac3a86..a541b4b33c519b 100644 --- a/Tools/build/freeze_modules.py +++ b/Tools/build/freeze_modules.py @@ -658,7 +658,7 @@ def regen_pcbuild(modules): filterlines = [] corelines = [] deepfreezemappingsfile = f'$(IntDir)\\{DEEPFREEZE_MAPPING_FNAME}' - deepfreezerules = [f' '] + deepfreezerules = [f' '] deepfreezemappings = [] for src in _iter_sources(modules): pyfile = relpath_for_windows_display(src.pyfile, ROOT_DIR) @@ -667,15 +667,15 @@ def regen_pcbuild(modules): projlines.append(f' ') projlines.append(f' {src.frozenid}') projlines.append(f' $(IntDir){intfile}') - projlines.append(f' $(PySourcePath){header}') + projlines.append(f' $(GeneratedFrozenModulesDir){header}') projlines.append(f' ') filterlines.append(f' ') filterlines.append(' Python Files') filterlines.append(' ') - deepfreezemappings.append(f' \n') + deepfreezemappings.append(f' \n') - corelines.append(f' ') + corelines.append(f' ') print(f'# Updating {os.path.relpath(PCBUILD_PROJECT)}') with updating_file_with_tmpfile(PCBUILD_PROJECT) as (infile, outfile): From df09a4edf5009fd10c5a1c4387a1e6407c2070bf Mon Sep 17 00:00:00 2001 From: Itamar Ostricher Date: Wed, 20 Dec 2023 22:27:30 -0800 Subject: [PATCH 3/7] Remove unnecessary $(IntDir) additional include dir --- PCbuild/pythoncore.vcxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index dc2f39ef6b9644..be5b34220aa0bc 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -563,7 +563,7 @@ - $(IntDir);$(GeneratedFrozenModulesDir)Python;%(AdditionalIncludeDirectories) + $(GeneratedFrozenModulesDir)Python;%(AdditionalIncludeDirectories) From 1d4ce11ef91d641000edda90134be48bf843c7ea Mon Sep 17 00:00:00 2001 From: Itamar Ostricher Date: Sat, 23 Dec 2023 09:36:04 -0800 Subject: [PATCH 4/7] Add NEWS entry --- .../next/Build/2023-12-23-09-35-48.gh-issue-113258.GlsAyH.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Build/2023-12-23-09-35-48.gh-issue-113258.GlsAyH.rst diff --git a/Misc/NEWS.d/next/Build/2023-12-23-09-35-48.gh-issue-113258.GlsAyH.rst b/Misc/NEWS.d/next/Build/2023-12-23-09-35-48.gh-issue-113258.GlsAyH.rst new file mode 100644 index 00000000000000..e7256ea423b3e0 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2023-12-23-09-35-48.gh-issue-113258.GlsAyH.rst @@ -0,0 +1,2 @@ +Changed the Windows build to write out generated frozen modules into the +build tree instead of the source tree. From fdb24fbb5ec61e27190bf9457953cd51860b6b18 Mon Sep 17 00:00:00 2001 From: Itamar Ostricher Date: Sat, 23 Dec 2023 09:47:09 -0800 Subject: [PATCH 5/7] Put frozen dir under version+arch+config subdir --- PCbuild/pyproject.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PCbuild/pyproject.props b/PCbuild/pyproject.props index 66eb2e8410d206..594482f18b8337 100644 --- a/PCbuild/pyproject.props +++ b/PCbuild/pyproject.props @@ -12,7 +12,7 @@ $(IntDir.Replace(`\\`, `\`)) $(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)$(ArchName)_$(Configuration)\pythoncore\ - $(Py_IntDir)\frozen\ + $(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)$(ArchName)_$(Configuration)\frozen\ $(ProjectName) $(TargetName)$(PyDebugExt) false From 8898241d20b05c79404c9f1b1d6958cd47b203fb Mon Sep 17 00:00:00 2001 From: Itamar Ostricher Date: Sun, 24 Dec 2023 21:22:40 -0800 Subject: [PATCH 6/7] Use $(PreferredToolArchitecture) for generated frozen dir --- PCbuild/pyproject.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PCbuild/pyproject.props b/PCbuild/pyproject.props index 594482f18b8337..32d420c00206dc 100644 --- a/PCbuild/pyproject.props +++ b/PCbuild/pyproject.props @@ -12,7 +12,7 @@ $(IntDir.Replace(`\\`, `\`)) $(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)$(ArchName)_$(Configuration)\pythoncore\ - $(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)$(ArchName)_$(Configuration)\frozen\ + $(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)$(PreferredToolArchitecture)_$(Configuration)\frozen\ $(ProjectName) $(TargetName)$(PyDebugExt) false From 851fdce458edb879a2653013dcd7052988f3cc77 Mon Sep 17 00:00:00 2001 From: Itamar Ostricher Date: Mon, 25 Dec 2023 10:55:13 -0800 Subject: [PATCH 7/7] Drop arch from generated frozen modules dir --- PCbuild/pyproject.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PCbuild/pyproject.props b/PCbuild/pyproject.props index 32d420c00206dc..d69b43b0406ce0 100644 --- a/PCbuild/pyproject.props +++ b/PCbuild/pyproject.props @@ -12,7 +12,7 @@ $(IntDir.Replace(`\\`, `\`)) $(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)$(ArchName)_$(Configuration)\pythoncore\ - $(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)$(PreferredToolArchitecture)_$(Configuration)\frozen\ + $(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)_frozen_$(Configuration)\ $(ProjectName) $(TargetName)$(PyDebugExt) false