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.
diff --git a/PCbuild/_freeze_module.vcxproj b/PCbuild/_freeze_module.vcxproj
index f8c5fafa561efa..292bfa76519507 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
+ $(GeneratedFrozenModulesDir)Python\frozen_modules\importlib._bootstrap.h
importlib._bootstrap_external
$(IntDir)importlib._bootstrap_external.g.h
- $(PySourcePath)Python\frozen_modules\importlib._bootstrap_external.h
+ $(GeneratedFrozenModulesDir)Python\frozen_modules\importlib._bootstrap_external.h
zipimport
$(IntDir)zipimport.g.h
- $(PySourcePath)Python\frozen_modules\zipimport.h
+ $(GeneratedFrozenModulesDir)Python\frozen_modules\zipimport.h
abc
$(IntDir)abc.g.h
- $(PySourcePath)Python\frozen_modules\abc.h
+ $(GeneratedFrozenModulesDir)Python\frozen_modules\abc.h
codecs
$(IntDir)codecs.g.h
- $(PySourcePath)Python\frozen_modules\codecs.h
+ $(GeneratedFrozenModulesDir)Python\frozen_modules\codecs.h
io
$(IntDir)io.g.h
- $(PySourcePath)Python\frozen_modules\io.h
+ $(GeneratedFrozenModulesDir)Python\frozen_modules\io.h
_collections_abc
$(IntDir)_collections_abc.g.h
- $(PySourcePath)Python\frozen_modules\_collections_abc.h
+ $(GeneratedFrozenModulesDir)Python\frozen_modules\_collections_abc.h
_sitebuiltins
$(IntDir)_sitebuiltins.g.h
- $(PySourcePath)Python\frozen_modules\_sitebuiltins.h
+ $(GeneratedFrozenModulesDir)Python\frozen_modules\_sitebuiltins.h
genericpath
$(IntDir)genericpath.g.h
- $(PySourcePath)Python\frozen_modules\genericpath.h
+ $(GeneratedFrozenModulesDir)Python\frozen_modules\genericpath.h
ntpath
$(IntDir)ntpath.g.h
- $(PySourcePath)Python\frozen_modules\ntpath.h
+ $(GeneratedFrozenModulesDir)Python\frozen_modules\ntpath.h
posixpath
$(IntDir)posixpath.g.h
- $(PySourcePath)Python\frozen_modules\posixpath.h
+ $(GeneratedFrozenModulesDir)Python\frozen_modules\posixpath.h
os
$(IntDir)os.g.h
- $(PySourcePath)Python\frozen_modules\os.h
+ $(GeneratedFrozenModulesDir)Python\frozen_modules\os.h
site
$(IntDir)site.g.h
- $(PySourcePath)Python\frozen_modules\site.h
+ $(GeneratedFrozenModulesDir)Python\frozen_modules\site.h
stat
$(IntDir)stat.g.h
- $(PySourcePath)Python\frozen_modules\stat.h
+ $(GeneratedFrozenModulesDir)Python\frozen_modules\stat.h
importlib.util
$(IntDir)importlib.util.g.h
- $(PySourcePath)Python\frozen_modules\importlib.util.h
+ $(GeneratedFrozenModulesDir)Python\frozen_modules\importlib.util.h
importlib.machinery
$(IntDir)importlib.machinery.g.h
- $(PySourcePath)Python\frozen_modules\importlib.machinery.h
+ $(GeneratedFrozenModulesDir)Python\frozen_modules\importlib.machinery.h
runpy
$(IntDir)runpy.g.h
- $(PySourcePath)Python\frozen_modules\runpy.h
+ $(GeneratedFrozenModulesDir)Python\frozen_modules\runpy.h
__hello__
$(IntDir)__hello__.g.h
- $(PySourcePath)Python\frozen_modules\__hello__.h
+ $(GeneratedFrozenModulesDir)Python\frozen_modules\__hello__.h
__phello__
$(IntDir)__phello__.g.h
- $(PySourcePath)Python\frozen_modules\__phello__.h
+ $(GeneratedFrozenModulesDir)Python\frozen_modules\__phello__.h
__phello__.ham
$(IntDir)__phello__.ham.g.h
- $(PySourcePath)Python\frozen_modules\__phello__.ham.h
+ $(GeneratedFrozenModulesDir)Python\frozen_modules\__phello__.ham.h
__phello__.ham.eggs
$(IntDir)__phello__.ham.eggs.g.h
- $(PySourcePath)Python\frozen_modules\__phello__.ham.eggs.h
+ $(GeneratedFrozenModulesDir)Python\frozen_modules\__phello__.ham.eggs.h
__phello__.spam
$(IntDir)__phello__.spam.g.h
- $(PySourcePath)Python\frozen_modules\__phello__.spam.h
+ $(GeneratedFrozenModulesDir)Python\frozen_modules\__phello__.spam.h
frozen_only
$(IntDir)frozen_only.g.h
- $(PySourcePath)Python\frozen_modules\frozen_only.h
+ $(GeneratedFrozenModulesDir)Python\frozen_modules\frozen_only.h
@@ -385,34 +385,34 @@
getpath
$(IntDir)getpath.g.h
- $(PySourcePath)Python\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..d69b43b0406ce0 100644
--- a/PCbuild/pyproject.props
+++ b/PCbuild/pyproject.props
@@ -12,6 +12,7 @@
$(IntDir.Replace(`\\`, `\`))
$(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)$(ArchName)_$(Configuration)\pythoncore\
+ $(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)_frozen_$(Configuration)\
$(ProjectName)
$(TargetName)$(PyDebugExt)
false
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index c90ad1a3592f67..be5b34220aa0bc 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)
- $(PySourcePath);%(AdditionalIncludeDirectories)
@@ -562,7 +562,9 @@
-
+
+ $(GeneratedFrozenModulesDir)Python;%(AdditionalIncludeDirectories)
+
@@ -617,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):