From 97c9b8c2ac35901fc9fa7c8cfbda3c535d07ad7c Mon Sep 17 00:00:00 2001
From: "R.Ghetta" <8450123+rghe@users.noreply.github.com>
Date: Sat, 9 Sep 2023 18:23:02 +0200
Subject: [PATCH 01/18] fix windows command line limitations when freezing many
modules
---
Tools/build/deepfreeze.py | 16 ++++++++++++++--
Tools/build/freeze_modules.py | 11 ++++++++---
2 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/Tools/build/deepfreeze.py b/Tools/build/deepfreeze.py
index 996d5f65a923b2..51fef29ad70aad 100644
--- a/Tools/build/deepfreeze.py
+++ b/Tools/build/deepfreeze.py
@@ -491,7 +491,8 @@ def generate(args: list[str], output: TextIO) -> None:
parser = argparse.ArgumentParser()
parser.add_argument("-o", "--output", help="Defaults to deepfreeze.c", default="deepfreeze.c")
parser.add_argument("-v", "--verbose", action="store_true", help="Print diagnostics")
-parser.add_argument('args', nargs="+", help="Input file and module name (required) in file:modname format")
+parser.add_argument("-f", "--file", help="reads rule lines from a file")
+parser.add_argument('args', nargs="*", help="Input file and module name (required) in file:modname format")
@contextlib.contextmanager
def report_time(label: str):
@@ -509,9 +510,20 @@ def main() -> None:
args = parser.parse_args()
verbose = args.verbose
output = args.output
+
+ 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()]
+ elif args.args:
+ rules = args.args
+ else:
+ raise argparse.ArgumentError(None, "no rule(s) specified")
+
with open(output, "w", encoding="utf-8") as file:
with report_time("generate"):
- generate(args.args, file)
+ generate(rules, file)
if verbose:
print(f"Wrote {os.path.getsize(output)} bytes to {output}")
diff --git a/Tools/build/freeze_modules.py b/Tools/build/freeze_modules.py
index a07f4d9786ea65..3dcfcd5fde2043 100644
--- a/Tools/build/freeze_modules.py
+++ b/Tools/build/freeze_modules.py
@@ -21,12 +21,14 @@
# .gitattributes and .gitignore files needs to be updated.
FROZEN_MODULES_DIR = os.path.join(ROOT_DIR, 'Python', 'frozen_modules')
DEEPFROZEN_MODULES_DIR = os.path.join(ROOT_DIR, 'Python', 'deepfreeze')
+DEEPFREEZE_MAPPING_FNAME = 'deepfreeze_mappings.txt'
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')
+PCBUILD_MAPPINGS = os.path.join(ROOT_DIR, 'PCbuild', DEEPFREEZE_MAPPING_FNAME)
OS_PATH = 'ntpath' if os.name == 'nt' else 'posixpath'
@@ -645,7 +647,8 @@ def regen_pcbuild(modules):
projlines = []
filterlines = []
corelines = []
- deepfreezerules = ['\t']
+ deepfreezemappings = []
for src in _iter_sources(modules):
pyfile = relpath_for_windows_display(src.pyfile, ROOT_DIR)
header = relpath_for_windows_display(src.frozenfile, ROOT_DIR)
@@ -659,8 +662,7 @@ def regen_pcbuild(modules):
filterlines.append(f' ')
filterlines.append(' Python Files')
filterlines.append(' ')
- deepfreezerules.append(f'\t\t "$(PySourcePath){header}:{src.frozenid}" ^')
- deepfreezerules.append('\t\t "-o" "$(PySourcePath)Python\\deepfreeze\\deepfreeze.c"\'/>' )
+ deepfreezemappings.append(f'{src.frozenfile}:{src.frozenid}\n')
corelines.append(f' ')
@@ -685,6 +687,9 @@ def regen_pcbuild(modules):
PCBUILD_PROJECT,
)
outfile.writelines(lines)
+ print(f'# Updating {os.path.relpath(PCBUILD_MAPPINGS)}')
+ with open(PCBUILD_MAPPINGS, "wt") as outfile:
+ outfile.writelines(deepfreezemappings)
print(f'# Updating {os.path.relpath(PCBUILD_FILTERS)}')
with updating_file_with_tmpfile(PCBUILD_FILTERS) as (infile, outfile):
lines = infile.readlines()
From ddf90829a6b8efe3f23c20a16ec3b76dff6965ee Mon Sep 17 00:00:00 2001
From: "R.Ghetta" <8450123+rghe@users.noreply.github.com>
Date: Sun, 17 Sep 2023 17:10:38 +0200
Subject: [PATCH 02/18] fix spacing
---
Tools/build/deepfreeze.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Tools/build/deepfreeze.py b/Tools/build/deepfreeze.py
index 2cea907b4d554a..95eff8f80df6fa 100644
--- a/Tools/build/deepfreeze.py
+++ b/Tools/build/deepfreeze.py
@@ -510,7 +510,7 @@ def main() -> None:
args = parser.parse_args()
verbose = args.verbose
output = args.output
-
+
if args.file:
if verbose:
print(f"reading rules from {args.file}")
@@ -520,7 +520,7 @@ def main() -> None:
rules = args.args
else:
raise argparse.ArgumentError(None, "no rule(s) specified")
-
+
with open(output, "w", encoding="utf-8") as file:
with report_time("generate"):
generate(rules, file)
From 9058b8debb8dfc3ce17bef3e783b4e34940ae1e8 Mon Sep 17 00:00:00 2001
From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com>
Date: Sun, 17 Sep 2023 15:17:54 +0000
Subject: [PATCH 03/18] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20b?=
=?UTF-8?q?lurb=5Fit.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../next/Build/2023-09-17-15-17-53.gh-issue-109515.zpEECA.rst | 1 +
1 file changed, 1 insertion(+)
create mode 100644 Misc/NEWS.d/next/Build/2023-09-17-15-17-53.gh-issue-109515.zpEECA.rst
diff --git a/Misc/NEWS.d/next/Build/2023-09-17-15-17-53.gh-issue-109515.zpEECA.rst b/Misc/NEWS.d/next/Build/2023-09-17-15-17-53.gh-issue-109515.zpEECA.rst
new file mode 100644
index 00000000000000..19669a5a6d917c
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2023-09-17-15-17-53.gh-issue-109515.zpEECA.rst
@@ -0,0 +1 @@
+on windows, write modules to freeze into a file instead of the command line. Allow deepfreze.py to read module file names from a file with a new -f option
From e98c3d03ad41c969465bfac51f6a10ad6237b2f8 Mon Sep 17 00:00:00 2001
From: "R.Ghetta" <8450123+rghe@users.noreply.github.com>
Date: Sun, 17 Sep 2023 18:32:57 +0200
Subject: [PATCH 04/18] missing regen
---
PCbuild/_freeze_module.vcxproj | 26 +-------------------------
1 file changed, 1 insertion(+), 25 deletions(-)
diff --git a/PCbuild/_freeze_module.vcxproj b/PCbuild/_freeze_module.vcxproj
index bdcf29ba44dab5..9913b5d0c06eb4 100644
--- a/PCbuild/_freeze_module.vcxproj
+++ b/PCbuild/_freeze_module.vcxproj
@@ -406,31 +406,7 @@
DependsOnTargets="FindPythonForBuild"
Condition="$(Configuration) != 'PGUpdate'">
-
+
From 86d181845d286aece922a33f897e7b2d0189c5e1 Mon Sep 17 00:00:00 2001
From: "R.Ghetta" <8450123+rghe@users.noreply.github.com>
Date: Sun, 17 Sep 2023 18:47:57 +0200
Subject: [PATCH 05/18] add generated file
---
PCbuild/deepfreeze_mappings.txt | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
create mode 100644 PCbuild/deepfreeze_mappings.txt
diff --git a/PCbuild/deepfreeze_mappings.txt b/PCbuild/deepfreeze_mappings.txt
new file mode 100644
index 00000000000000..6578a884735296
--- /dev/null
+++ b/PCbuild/deepfreeze_mappings.txt
@@ -0,0 +1,23 @@
+/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/importlib._bootstrap.h:importlib._bootstrap
+/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/importlib._bootstrap_external.h:importlib._bootstrap_external
+/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/zipimport.h:zipimport
+/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/abc.h:abc
+/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/codecs.h:codecs
+/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/io.h:io
+/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/_collections_abc.h:_collections_abc
+/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/_sitebuiltins.h:_sitebuiltins
+/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/genericpath.h:genericpath
+/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/ntpath.h:ntpath
+/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/posixpath.h:posixpath
+/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/os.h:os
+/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/site.h:site
+/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/stat.h:stat
+/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/importlib.util.h:importlib.util
+/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/importlib.machinery.h:importlib.machinery
+/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/runpy.h:runpy
+/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/__hello__.h:__hello__
+/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/__phello__.h:__phello__
+/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/__phello__.ham.h:__phello__.ham
+/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/__phello__.ham.eggs.h:__phello__.ham.eggs
+/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/__phello__.spam.h:__phello__.spam
+/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/frozen_only.h:frozen_only
From ca98aa1093f0b132d27a9c6ca518d4cd5dad78ef Mon Sep 17 00:00:00 2001
From: "R.Ghetta" <8450123+rghe@users.noreply.github.com>
Date: Sun, 17 Sep 2023 19:16:42 +0200
Subject: [PATCH 06/18] add buildpath-dependent generated files to .gitignore
---
.gitignore | 1 +
PCbuild/deepfreeze_mappings.txt | 23 -----------------------
2 files changed, 1 insertion(+), 23 deletions(-)
delete mode 100644 PCbuild/deepfreeze_mappings.txt
diff --git a/.gitignore b/.gitignore
index dddf28da016192..4d1273d67ab4f0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -109,6 +109,7 @@ PCbuild/*-pgi
PCbuild/*-pgo
PCbuild/*.VC.db
PCbuild/*.VC.opendb
+PCbuild/deepfreeze_mappings.txt
PCbuild/amd64/
PCbuild/arm32/
PCbuild/arm64/
diff --git a/PCbuild/deepfreeze_mappings.txt b/PCbuild/deepfreeze_mappings.txt
deleted file mode 100644
index 6578a884735296..00000000000000
--- a/PCbuild/deepfreeze_mappings.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/importlib._bootstrap.h:importlib._bootstrap
-/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/importlib._bootstrap_external.h:importlib._bootstrap_external
-/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/zipimport.h:zipimport
-/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/abc.h:abc
-/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/codecs.h:codecs
-/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/io.h:io
-/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/_collections_abc.h:_collections_abc
-/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/_sitebuiltins.h:_sitebuiltins
-/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/genericpath.h:genericpath
-/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/ntpath.h:ntpath
-/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/posixpath.h:posixpath
-/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/os.h:os
-/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/site.h:site
-/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/stat.h:stat
-/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/importlib.util.h:importlib.util
-/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/importlib.machinery.h:importlib.machinery
-/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/runpy.h:runpy
-/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/__hello__.h:__hello__
-/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/__phello__.h:__phello__
-/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/__phello__.ham.h:__phello__.ham
-/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/__phello__.ham.eggs.h:__phello__.ham.eggs
-/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/__phello__.spam.h:__phello__.spam
-/opt/svil/python/cpython/rghe-cpython/Python/frozen_modules/frozen_only.h:frozen_only
From 5463e79b15f9176311f72a8d150f1fb9cc7b8516 Mon Sep 17 00:00:00 2001
From: "R.Ghetta" <8450123+rghe@users.noreply.github.com>
Date: Sun, 17 Sep 2023 20:05:15 +0200
Subject: [PATCH 07/18] try relative paths
---
PCbuild/deepfreeze_mappings.txt | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
create mode 100644 PCbuild/deepfreeze_mappings.txt
diff --git a/PCbuild/deepfreeze_mappings.txt b/PCbuild/deepfreeze_mappings.txt
new file mode 100644
index 00000000000000..0e459c22eb57b8
--- /dev/null
+++ b/PCbuild/deepfreeze_mappings.txt
@@ -0,0 +1,23 @@
+.\Python\frozen_modules\importlib._bootstrap.h:importlib._bootstrap
+.\Python\frozen_modules\importlib._bootstrap_external.h:importlib._bootstrap_external
+.\Python\frozen_modules\zipimport.h:zipimport
+.\Python\frozen_modules\abc.h:abc
+.\Python\frozen_modules\codecs.h:codecs
+.\Python\frozen_modules\io.h:io
+.\Python\frozen_modules\_collections_abc.h:_collections_abc
+.\Python\frozen_modules\_sitebuiltins.h:_sitebuiltins
+.\Python\frozen_modules\genericpath.h:genericpath
+.\Python\frozen_modules\ntpath.h:ntpath
+.\Python\frozen_modules\posixpath.h:posixpath
+.\Python\frozen_modules\os.h:os
+.\Python\frozen_modules\site.h:site
+.\Python\frozen_modules\stat.h:stat
+.\Python\frozen_modules\importlib.util.h:importlib.util
+.\Python\frozen_modules\importlib.machinery.h:importlib.machinery
+.\Python\frozen_modules\runpy.h:runpy
+.\Python\frozen_modules\__hello__.h:__hello__
+.\Python\frozen_modules\__phello__.h:__phello__
+.\Python\frozen_modules\__phello__.ham.h:__phello__.ham
+.\Python\frozen_modules\__phello__.ham.eggs.h:__phello__.ham.eggs
+.\Python\frozen_modules\__phello__.spam.h:__phello__.spam
+.\Python\frozen_modules\frozen_only.h:frozen_only
From 7456fe57b62721d13096dd5567e7596ddfa72027 Mon Sep 17 00:00:00 2001
From: "R.Ghetta" <8450123+rghe@users.noreply.github.com>
Date: Thu, 21 Sep 2023 21:50:16 +0200
Subject: [PATCH 08/18] fill mappings file with relative paths from vcxproj
---
PCbuild/_freeze_module.vcxproj | 40 ++++++++++++++++++++++++++++++++-
PCbuild/deepfreeze_mappings.txt | 23 -------------------
Tools/build/freeze_modules.py | 29 +++++++++++++++++++-----
3 files changed, 62 insertions(+), 30 deletions(-)
delete mode 100644 PCbuild/deepfreeze_mappings.txt
diff --git a/PCbuild/_freeze_module.vcxproj b/PCbuild/_freeze_module.vcxproj
index 9913b5d0c06eb4..61ba7663efb94d 100644
--- a/PCbuild/_freeze_module.vcxproj
+++ b/PCbuild/_freeze_module.vcxproj
@@ -405,7 +405,45 @@
AfterTargets="_RebuildFrozen"
DependsOnTargets="FindPythonForBuild"
Condition="$(Configuration) != 'PGUpdate'">
-
+
+
+
+$(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
+
+
+
+
+$(PySourcePath)PCbuild\deepfreeze_mappings.txt
+
+
+
+
+
diff --git a/PCbuild/deepfreeze_mappings.txt b/PCbuild/deepfreeze_mappings.txt
deleted file mode 100644
index 0e459c22eb57b8..00000000000000
--- a/PCbuild/deepfreeze_mappings.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-.\Python\frozen_modules\importlib._bootstrap.h:importlib._bootstrap
-.\Python\frozen_modules\importlib._bootstrap_external.h:importlib._bootstrap_external
-.\Python\frozen_modules\zipimport.h:zipimport
-.\Python\frozen_modules\abc.h:abc
-.\Python\frozen_modules\codecs.h:codecs
-.\Python\frozen_modules\io.h:io
-.\Python\frozen_modules\_collections_abc.h:_collections_abc
-.\Python\frozen_modules\_sitebuiltins.h:_sitebuiltins
-.\Python\frozen_modules\genericpath.h:genericpath
-.\Python\frozen_modules\ntpath.h:ntpath
-.\Python\frozen_modules\posixpath.h:posixpath
-.\Python\frozen_modules\os.h:os
-.\Python\frozen_modules\site.h:site
-.\Python\frozen_modules\stat.h:stat
-.\Python\frozen_modules\importlib.util.h:importlib.util
-.\Python\frozen_modules\importlib.machinery.h:importlib.machinery
-.\Python\frozen_modules\runpy.h:runpy
-.\Python\frozen_modules\__hello__.h:__hello__
-.\Python\frozen_modules\__phello__.h:__phello__
-.\Python\frozen_modules\__phello__.ham.h:__phello__.ham
-.\Python\frozen_modules\__phello__.ham.eggs.h:__phello__.ham.eggs
-.\Python\frozen_modules\__phello__.spam.h:__phello__.spam
-.\Python\frozen_modules\frozen_only.h:frozen_only
diff --git a/Tools/build/freeze_modules.py b/Tools/build/freeze_modules.py
index 3dcfcd5fde2043..aefc630e4f0c15 100644
--- a/Tools/build/freeze_modules.py
+++ b/Tools/build/freeze_modules.py
@@ -28,7 +28,6 @@
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')
-PCBUILD_MAPPINGS = os.path.join(ROOT_DIR, 'PCbuild', DEEPFREEZE_MAPPING_FNAME)
OS_PATH = 'ntpath' if os.name == 'nt' else 'posixpath'
@@ -647,7 +646,8 @@ def regen_pcbuild(modules):
projlines = []
filterlines = []
corelines = []
- deepfreezerules = [f'\t']
+ deepfreezemappingsfile = f'$(PySourcePath)PCbuild\\{DEEPFREEZE_MAPPING_FNAME}'
+ deepfreezerules = [f'\t']
deepfreezemappings = []
for src in _iter_sources(modules):
pyfile = relpath_for_windows_display(src.pyfile, ROOT_DIR)
@@ -662,7 +662,7 @@ def regen_pcbuild(modules):
filterlines.append(f' ')
filterlines.append(' Python Files')
filterlines.append(' ')
- deepfreezemappings.append(f'{src.frozenfile}:{src.frozenid}\n')
+ deepfreezemappings.append(f'$(PySourcePath)\\{header}:{src.frozenid}\n')
corelines.append(f' ')
@@ -677,6 +677,26 @@ def regen_pcbuild(modules):
PCBUILD_PROJECT,
)
outfile.writelines(lines)
+ with updating_file_with_tmpfile(PCBUILD_PROJECT) as (infile, outfile):
+ lines = infile.readlines()
+ lines = replace_block(
+ lines,
+ '',
+ '',
+ deepfreezemappings,
+ PCBUILD_PROJECT,
+ )
+ outfile.writelines(lines)
+ with updating_file_with_tmpfile(PCBUILD_PROJECT) as (infile, outfile):
+ lines = infile.readlines()
+ lines = replace_block(
+ lines,
+ '',
+ '',
+ [deepfreezemappingsfile, ],
+ PCBUILD_PROJECT,
+ )
+ outfile.writelines(lines)
with updating_file_with_tmpfile(PCBUILD_PROJECT) as (infile, outfile):
lines = infile.readlines()
lines = replace_block(
@@ -687,9 +707,6 @@ def regen_pcbuild(modules):
PCBUILD_PROJECT,
)
outfile.writelines(lines)
- print(f'# Updating {os.path.relpath(PCBUILD_MAPPINGS)}')
- with open(PCBUILD_MAPPINGS, "wt") as outfile:
- outfile.writelines(deepfreezemappings)
print(f'# Updating {os.path.relpath(PCBUILD_FILTERS)}')
with updating_file_with_tmpfile(PCBUILD_FILTERS) as (infile, outfile):
lines = infile.readlines()
From 031ea3e94f1e15d0fcc19ecfb91aa008b4ea738d Mon Sep 17 00:00:00 2001
From: "R.Ghetta" <8450123+rghe@users.noreply.github.com>
Date: Sat, 23 Sep 2023 16:29:05 +0200
Subject: [PATCH 09/18] Implement S.Dower review suggestions
---
...-09-17-15-17-53.gh-issue-109515.zpEECA.rst | 1 -
PCbuild/_freeze_module.vcxproj | 60 +++++++++----------
Tools/build/deepfreeze.py | 4 +-
Tools/build/freeze_modules.py | 4 +-
4 files changed, 34 insertions(+), 35 deletions(-)
delete mode 100644 Misc/NEWS.d/next/Build/2023-09-17-15-17-53.gh-issue-109515.zpEECA.rst
diff --git a/Misc/NEWS.d/next/Build/2023-09-17-15-17-53.gh-issue-109515.zpEECA.rst b/Misc/NEWS.d/next/Build/2023-09-17-15-17-53.gh-issue-109515.zpEECA.rst
deleted file mode 100644
index 19669a5a6d917c..00000000000000
--- a/Misc/NEWS.d/next/Build/2023-09-17-15-17-53.gh-issue-109515.zpEECA.rst
+++ /dev/null
@@ -1 +0,0 @@
-on windows, write modules to freeze into a file instead of the command line. Allow deepfreze.py to read module file names from a file with a new -f option
diff --git a/PCbuild/_freeze_module.vcxproj b/PCbuild/_freeze_module.vcxproj
index 61ba7663efb94d..9f2a252fd2cbfb 100644
--- a/PCbuild/_freeze_module.vcxproj
+++ b/PCbuild/_freeze_module.vcxproj
@@ -374,6 +374,33 @@
$(PySourcePath)Python\frozen_modules\getpath.h
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -406,45 +433,18 @@
DependsOnTargets="FindPythonForBuild"
Condition="$(Configuration) != 'PGUpdate'">
-
-
-$(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
-
-
-$(PySourcePath)PCbuild\deepfreeze_mappings.txt
+$(IntDir)\deepfreeze_mappings.txt
+ Lines="@(FrozenModule->'%(FullPath):%(FrozenId)')" />
-
+
diff --git a/Tools/build/deepfreeze.py b/Tools/build/deepfreeze.py
index 95eff8f80df6fa..328bc1aee68ddc 100644
--- a/Tools/build/deepfreeze.py
+++ b/Tools/build/deepfreeze.py
@@ -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:
diff --git a/Tools/build/freeze_modules.py b/Tools/build/freeze_modules.py
index aefc630e4f0c15..6fb8f75fde2d6a 100644
--- a/Tools/build/freeze_modules.py
+++ b/Tools/build/freeze_modules.py
@@ -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']
deepfreezemappings = []
for src in _iter_sources(modules):
@@ -662,7 +662,7 @@ def regen_pcbuild(modules):
filterlines.append(f' ')
filterlines.append(' Python Files')
filterlines.append(' ')
- deepfreezemappings.append(f'$(PySourcePath)\\{header}:{src.frozenid}\n')
+ deepfreezemappings.append(f'\t\n')
corelines.append(f' ')
From b78bb97dfa0875b1172159872530aac8adf61920 Mon Sep 17 00:00:00 2001
From: "R.Ghetta" <8450123+rghe@users.noreply.github.com>
Date: Sat, 23 Sep 2023 19:28:04 +0200
Subject: [PATCH 10/18] clean gitignore
---
.gitignore | 1 -
1 file changed, 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index 4d1273d67ab4f0..dddf28da016192 100644
--- a/.gitignore
+++ b/.gitignore
@@ -109,7 +109,6 @@ PCbuild/*-pgi
PCbuild/*-pgo
PCbuild/*.VC.db
PCbuild/*.VC.opendb
-PCbuild/deepfreeze_mappings.txt
PCbuild/amd64/
PCbuild/arm32/
PCbuild/arm64/
From d584d2d2d590ba145218a3f379ed1fa884b98d81 Mon Sep 17 00:00:00 2001
From: Riccardo Ghetta
Date: Tue, 26 Sep 2023 18:42:03 +0200
Subject: [PATCH 11/18] Update Tools/build/freeze_modules.py
Co-authored-by: Steve Dower
---
Tools/build/freeze_modules.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Tools/build/freeze_modules.py b/Tools/build/freeze_modules.py
index 6fb8f75fde2d6a..acbad6a2b3c6f1 100644
--- a/Tools/build/freeze_modules.py
+++ b/Tools/build/freeze_modules.py
@@ -662,7 +662,7 @@ def regen_pcbuild(modules):
filterlines.append(f' ')
filterlines.append(' Python Files')
filterlines.append(' ')
- deepfreezemappings.append(f'\t\n')
+ deepfreezemappings.append(f' \n')
corelines.append(f' ')
From 48112ab675747ffa0d0a71ffb1be7911f30cbaf8 Mon Sep 17 00:00:00 2001
From: Riccardo Ghetta
Date: Tue, 26 Sep 2023 19:28:38 +0200
Subject: [PATCH 12/18] Update Tools/build/deepfreeze.py
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
---
Tools/build/deepfreeze.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Tools/build/deepfreeze.py b/Tools/build/deepfreeze.py
index 328bc1aee68ddc..61bd7eedb976b3 100644
--- a/Tools/build/deepfreeze.py
+++ b/Tools/build/deepfreeze.py
@@ -513,7 +513,7 @@ def main() -> None:
if args.file:
if verbose:
- print(f"reading rules from {args.file}")
+ print(f"Reading targets from {args.file}")
with open(args.file, "rt", encoding="utf-8-sig") as fin:
rules = [x.strip() for x in fin]
elif args.args:
From 74a255a2e3683cb70c6eca84b0a66c2921a13894 Mon Sep 17 00:00:00 2001
From: Riccardo Ghetta
Date: Tue, 26 Sep 2023 19:30:04 +0200
Subject: [PATCH 13/18] Update Tools/build/deepfreeze.py
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
---
Tools/build/deepfreeze.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/Tools/build/deepfreeze.py b/Tools/build/deepfreeze.py
index 61bd7eedb976b3..b81ae924863c21 100644
--- a/Tools/build/deepfreeze.py
+++ b/Tools/build/deepfreeze.py
@@ -491,8 +491,10 @@ def generate(args: list[str], output: TextIO) -> None:
parser = argparse.ArgumentParser()
parser.add_argument("-o", "--output", help="Defaults to deepfreeze.c", default="deepfreeze.c")
parser.add_argument("-v", "--verbose", action="store_true", help="Print diagnostics")
-parser.add_argument("-f", "--file", help="reads rule lines from a file")
-parser.add_argument('args', nargs="*", help="Input file and module name (required) in file:modname format")
+group = parser.add_mutually_exclusive_group(required=True)
+group.add_argument("-f", "--file", help="reads rule lines from a file")
+group.add_argument('args', nargs="*", default=(),
+ help="Input file and module name (required) in file:modname format")
@contextlib.contextmanager
def report_time(label: str):
From ecc334f7395faab87397d6241558f8551ea4bad7 Mon Sep 17 00:00:00 2001
From: Riccardo Ghetta
Date: Tue, 26 Sep 2023 19:30:36 +0200
Subject: [PATCH 14/18] Update Tools/build/deepfreeze.py
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
---
Tools/build/deepfreeze.py | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/Tools/build/deepfreeze.py b/Tools/build/deepfreeze.py
index b81ae924863c21..c0365668650617 100644
--- a/Tools/build/deepfreeze.py
+++ b/Tools/build/deepfreeze.py
@@ -518,10 +518,8 @@ def main() -> None:
print(f"Reading targets from {args.file}")
with open(args.file, "rt", encoding="utf-8-sig") as fin:
rules = [x.strip() for x in fin]
- elif args.args:
+ else args.args:
rules = args.args
- else:
- raise argparse.ArgumentError(None, "no rule(s) specified")
with open(output, "w", encoding="utf-8") as file:
with report_time("generate"):
From bb42f3217a69e5ec7e2a5c70a3abd87e0c454b31 Mon Sep 17 00:00:00 2001
From: "R.Ghetta" <8450123+rghe@users.noreply.github.com>
Date: Tue, 26 Sep 2023 19:42:56 +0200
Subject: [PATCH 15/18] expand \t and align vcxfile by AA-Turner suggestion
---
PCbuild/_freeze_module.vcxproj | 48 +++++++++++++++++-----------------
Tools/build/freeze_modules.py | 2 +-
2 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/PCbuild/_freeze_module.vcxproj b/PCbuild/_freeze_module.vcxproj
index 9f2a252fd2cbfb..ec6b7043e1ab8e 100644
--- a/PCbuild/_freeze_module.vcxproj
+++ b/PCbuild/_freeze_module.vcxproj
@@ -376,29 +376,29 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -444,7 +444,7 @@ $(IntDir)\deepfreeze_mappings.txt
Overwrite="true"
Lines="@(FrozenModule->'%(FullPath):%(FrozenId)')" />
-
+
diff --git a/Tools/build/freeze_modules.py b/Tools/build/freeze_modules.py
index acbad6a2b3c6f1..f5b99d136fa73b 100644
--- a/Tools/build/freeze_modules.py
+++ b/Tools/build/freeze_modules.py
@@ -647,7 +647,7 @@ def regen_pcbuild(modules):
filterlines = []
corelines = []
deepfreezemappingsfile = f'$(IntDir)\\{DEEPFREEZE_MAPPING_FNAME}'
- deepfreezerules = [f'\t']
+ deepfreezerules = [f' ']
deepfreezemappings = []
for src in _iter_sources(modules):
pyfile = relpath_for_windows_display(src.pyfile, ROOT_DIR)
From 4cc3458bb5719c36b107e66b8fae52ebc4c67892 Mon Sep 17 00:00:00 2001
From: "R.Ghetta" <8450123+rghe@users.noreply.github.com>
Date: Tue, 26 Sep 2023 21:35:46 +0200
Subject: [PATCH 16/18] typo
---
Tools/build/deepfreeze.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Tools/build/deepfreeze.py b/Tools/build/deepfreeze.py
index c0365668650617..cd1b91c96b9528 100644
--- a/Tools/build/deepfreeze.py
+++ b/Tools/build/deepfreeze.py
@@ -518,7 +518,7 @@ def main() -> None:
print(f"Reading targets from {args.file}")
with open(args.file, "rt", encoding="utf-8-sig") as fin:
rules = [x.strip() for x in fin]
- else args.args:
+ else:
rules = args.args
with open(output, "w", encoding="utf-8") as file:
From 1c20fcd6452b6cbd894d344a1c6a3503ac7aebd8 Mon Sep 17 00:00:00 2001
From: "R.Ghetta" <8450123+rghe@users.noreply.github.com>
Date: Wed, 27 Sep 2023 20:52:38 +0200
Subject: [PATCH 17/18] reformat vcxproj
---
PCbuild/_freeze_module.vcxproj | 78 +++++++++++++++++-----------------
Tools/build/freeze_modules.py | 4 +-
2 files changed, 41 insertions(+), 41 deletions(-)
diff --git a/PCbuild/_freeze_module.vcxproj b/PCbuild/_freeze_module.vcxproj
index ec6b7043e1ab8e..63ab36680ef887 100644
--- a/PCbuild/_freeze_module.vcxproj
+++ b/PCbuild/_freeze_module.vcxproj
@@ -374,33 +374,33 @@
$(PySourcePath)Python\frozen_modules\getpath.h
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -432,19 +432,19 @@
AfterTargets="_RebuildFrozen"
DependsOnTargets="FindPythonForBuild"
Condition="$(Configuration) != 'PGUpdate'">
-
-
-
+
+
+
$(IntDir)\deepfreeze_mappings.txt
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/Tools/build/freeze_modules.py b/Tools/build/freeze_modules.py
index f5b99d136fa73b..c5a397129201b6 100644
--- a/Tools/build/freeze_modules.py
+++ b/Tools/build/freeze_modules.py
@@ -647,7 +647,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)
@@ -662,7 +662,7 @@ def regen_pcbuild(modules):
filterlines.append(f' ')
filterlines.append(' Python Files')
filterlines.append(' ')
- deepfreezemappings.append(f' \n')
+ deepfreezemappings.append(f' \n')
corelines.append(f' ')
From 5620f94e9ef63bb2c4c82ce19e6db1719787bb91 Mon Sep 17 00:00:00 2001
From: Riccardo Ghetta
Date: Wed, 27 Sep 2023 21:06:42 +0200
Subject: [PATCH 18/18] Update Tools/build/deepfreeze.py
Co-authored-by: Guido van Rossum
---
Tools/build/deepfreeze.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Tools/build/deepfreeze.py b/Tools/build/deepfreeze.py
index cd1b91c96b9528..27f76023e257c5 100644
--- a/Tools/build/deepfreeze.py
+++ b/Tools/build/deepfreeze.py
@@ -492,7 +492,7 @@ def generate(args: list[str], output: TextIO) -> None:
parser.add_argument("-o", "--output", help="Defaults to deepfreeze.c", default="deepfreeze.c")
parser.add_argument("-v", "--verbose", action="store_true", help="Print diagnostics")
group = parser.add_mutually_exclusive_group(required=True)
-group.add_argument("-f", "--file", help="reads rule lines from a file")
+group.add_argument("-f", "--file", help="read rule lines from a file")
group.add_argument('args', nargs="*", default=(),
help="Input file and module name (required) in file:modname format")