[Python-checkins] gh-97669: Create Tools/build/ directory (#97963)

vstinner webhook-mailer at python.org
Mon Oct 17 06:01:15 EDT 2022


https://github.com/python/cpython/commit/1863302d61a7a5dd8b8d345a00f0ee242c7c10bf
commit: 1863302d61a7a5dd8b8d345a00f0ee242c7c10bf
branch: main
author: Victor Stinner <vstinner at python.org>
committer: vstinner <vstinner at python.org>
date: 2022-10-17T12:01:00+02:00
summary:

gh-97669: Create Tools/build/ directory (#97963)

Create Tools/build/ directory. Move the following scripts from
Tools/scripts/ to Tools/build/:

* check_extension_modules.py
* deepfreeze.py
* freeze_modules.py
* generate_global_objects.py
* generate_levenshtein_examples.py
* generate_opcode_h.py
* generate_re_casefix.py
* generate_sre_constants.py
* generate_stdlib_module_names.py
* generate_token.py
* parse_html5_entities.py
* smelly.py
* stable_abi.py
* umarshal.py
* update_file.py
* verify_ensurepip_wheels.py

Update references to these scripts.

files:
A Tools/build/check_extension_modules.py
A Tools/build/deepfreeze.py
A Tools/build/freeze_modules.py
A Tools/build/generate_global_objects.py
A Tools/build/generate_levenshtein_examples.py
A Tools/build/generate_opcode_h.py
A Tools/build/generate_re_casefix.py
A Tools/build/generate_sre_constants.py
A Tools/build/generate_stdlib_module_names.py
A Tools/build/generate_token.py
A Tools/build/parse_html5_entities.py
A Tools/build/smelly.py
A Tools/build/stable_abi.py
A Tools/build/umarshal.py
A Tools/build/update_file.py
A Tools/build/verify_ensurepip_wheels.py
D Tools/scripts/check_extension_modules.py
D Tools/scripts/deepfreeze.py
D Tools/scripts/freeze_modules.py
D Tools/scripts/generate_global_objects.py
D Tools/scripts/generate_levenshtein_examples.py
D Tools/scripts/generate_opcode_h.py
D Tools/scripts/generate_re_casefix.py
D Tools/scripts/generate_sre_constants.py
D Tools/scripts/generate_stdlib_module_names.py
D Tools/scripts/generate_token.py
D Tools/scripts/parse_html5_entities.py
D Tools/scripts/smelly.py
D Tools/scripts/stable_abi.py
D Tools/scripts/umarshal.py
D Tools/scripts/update_file.py
D Tools/scripts/verify_ensurepip_wheels.py
M .github/CODEOWNERS
M .github/workflows/verify-ensurepip-wheels.yml
M .gitignore
M Doc/library/token-list.inc
M Include/internal/pycore_global_strings.h
M Include/internal/pycore_opcode.h
M Include/internal/pycore_runtime_init_generated.h
M Include/internal/pycore_token.h
M Include/opcode.h
M Lib/html/entities.py
M Lib/token.py
M Makefile.pre.in
M Misc/stable_abi.toml
M Modules/_sre/sre_constants.h
M Modules/_sre/sre_targets.h
M PC/python3dll.c
M PCbuild/_freeze_module.vcxproj
M PCbuild/regen.targets
M Parser/token.c
M Programs/_bootstrap_python.c
M Programs/_freeze_module.c
M Python/deepfreeze/README.txt
M Python/frozen.c
M Python/frozen_modules/README.txt
M Python/stdlib_module_names.h

diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 585589d6ce3b..2fd933a22f3c 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -55,7 +55,7 @@ Python/traceback.c            @iritkatriel
 /Lib/html/                    @ezio-melotti
 /Lib/_markupbase.py           @ezio-melotti
 /Lib/test/test_html*.py       @ezio-melotti
-/Tools/scripts/*html5*        @ezio-melotti
+/Tools/build/parse_html5_entities.py   @ezio-melotti
 
 # Import (including importlib).
 # Ignoring importlib.h so as to not get flagged on
diff --git a/.github/workflows/verify-ensurepip-wheels.yml b/.github/workflows/verify-ensurepip-wheels.yml
index 9f4754f912b0..969515ed287b 100644
--- a/.github/workflows/verify-ensurepip-wheels.yml
+++ b/.github/workflows/verify-ensurepip-wheels.yml
@@ -6,12 +6,12 @@ on:
     paths:
       - 'Lib/ensurepip/_bundled/**'
       - '.github/workflows/verify-ensurepip-wheels.yml'
-      - 'Tools/scripts/verify_ensurepip_wheels.py'
+      - 'Tools/build/verify_ensurepip_wheels.py'
   pull_request:
     paths:
       - 'Lib/ensurepip/_bundled/**'
       - '.github/workflows/verify-ensurepip-wheels.yml'
-      - 'Tools/scripts/verify_ensurepip_wheels.py'
+      - 'Tools/build/verify_ensurepip_wheels.py'
 
 permissions:
   contents: read
@@ -29,4 +29,4 @@ jobs:
         with:
           python-version: '3'
       - name: Compare checksums of bundled pip and setuptools to ones published on PyPI
-        run: ./Tools/scripts/verify_ensurepip_wheels.py
+        run: ./Tools/build/verify_ensurepip_wheels.py
diff --git a/.gitignore b/.gitignore
index 924c136ba9aa..6934faa91e98 100644
--- a/.gitignore
+++ b/.gitignore
@@ -143,7 +143,7 @@ Tools/ssl/win32
 Tools/freeze/test/outdir
 
 # The frozen modules are always generated by the build so we don't
-# keep them in the repo.  Also see Tools/scripts/freeze_modules.py.
+# keep them in the repo.  Also see Tools/build/freeze_modules.py.
 Python/frozen_modules/*.h
 # The manifest can be generated at any time with "make regen-frozen".
 Python/frozen_modules/MANIFEST
diff --git a/Doc/library/token-list.inc b/Doc/library/token-list.inc
index 1a99f0518d1b..2739d5bfc1df 100644
--- a/Doc/library/token-list.inc
+++ b/Doc/library/token-list.inc
@@ -1,4 +1,4 @@
-.. Auto-generated by Tools/scripts/generate_token.py
+.. Auto-generated by Tools/build/generate_token.py
 .. data:: ENDMARKER
 
 .. data:: NAME
diff --git a/Include/internal/pycore_global_strings.h b/Include/internal/pycore_global_strings.h
index f646979910c8..811cfc147fcf 100644
--- a/Include/internal/pycore_global_strings.h
+++ b/Include/internal/pycore_global_strings.h
@@ -8,7 +8,7 @@ extern "C" {
 #  error "this header requires Py_BUILD_CORE define"
 #endif
 
-// The data structure & init here are inspired by Tools/scripts/deepfreeze.py.
+// The data structure & init here are inspired by Tools/build/deepfreeze.py.
 
 // All field names generated by ASCII_STR() have a common prefix,
 // to help avoid collisions with keywords, etc.
@@ -25,7 +25,7 @@ extern "C" {
 
 // XXX Order by frequency of use?
 
-/* The following is auto-generated by Tools/scripts/generate_global_objects.py. */
+/* The following is auto-generated by Tools/build/generate_global_objects.py. */
 struct _Py_global_strings {
     struct {
         STRUCT_FOR_STR(anon_dictcomp, "<dictcomp>")
diff --git a/Include/internal/pycore_opcode.h b/Include/internal/pycore_opcode.h
index 15925511cc1f..c8ef5dd73525 100644
--- a/Include/internal/pycore_opcode.h
+++ b/Include/internal/pycore_opcode.h
@@ -1,4 +1,4 @@
-// Auto-generated by Tools/scripts/generate_opcode_h.py from Lib/opcode.py
+// Auto-generated by Tools/build/generate_opcode_h.py from Lib/opcode.py
 
 #ifndef Py_INTERNAL_OPCODE_H
 #define Py_INTERNAL_OPCODE_H
diff --git a/Include/internal/pycore_runtime_init_generated.h b/Include/internal/pycore_runtime_init_generated.h
index bd1fedebd65c..8ce95884ccdd 100644
--- a/Include/internal/pycore_runtime_init_generated.h
+++ b/Include/internal/pycore_runtime_init_generated.h
@@ -8,7 +8,7 @@ extern "C" {
 #  error "this header requires Py_BUILD_CORE define"
 #endif
 
-/* The following is auto-generated by Tools/scripts/generate_global_objects.py. */
+/* The following is auto-generated by Tools/build/generate_global_objects.py. */
 #define _Py_global_objects_INIT { \
     .singletons = { \
         .small_ints = { \
diff --git a/Include/internal/pycore_token.h b/Include/internal/pycore_token.h
index f9b8240e2168..95459ab9f7d0 100644
--- a/Include/internal/pycore_token.h
+++ b/Include/internal/pycore_token.h
@@ -1,4 +1,4 @@
-/* Auto-generated by Tools/scripts/generate_token.py */
+/* Auto-generated by Tools/build/generate_token.py */
 
 /* Token types */
 #ifndef Py_INTERNAL_TOKEN_H
diff --git a/Include/opcode.h b/Include/opcode.h
index 42825df6217b..0871eb1bfe0a 100644
--- a/Include/opcode.h
+++ b/Include/opcode.h
@@ -1,4 +1,4 @@
-// Auto-generated by Tools/scripts/generate_opcode_h.py from Lib/opcode.py
+// Auto-generated by Tools/build/generate_opcode_h.py from Lib/opcode.py
 
 #ifndef Py_OPCODE_H
 #define Py_OPCODE_H
diff --git a/Lib/html/entities.py b/Lib/html/entities.py
index cc59bc314499..eb6dc1219058 100644
--- a/Lib/html/entities.py
+++ b/Lib/html/entities.py
@@ -261,7 +261,7 @@
 
 
 # HTML5 named character references
-# Generated by 'Tools/scripts/parse_html5_entities.py'
+# Generated by Tools/build/parse_html5_entities.py
 # from https://html.spec.whatwg.org/entities.json and
 # https://html.spec.whatwg.org/multipage/named-characters.html.
 # Map HTML5 named character references to the equivalent Unicode character(s).
diff --git a/Lib/token.py b/Lib/token.py
index 9d0c0bf0fb03..95b107c6643b 100644
--- a/Lib/token.py
+++ b/Lib/token.py
@@ -1,5 +1,5 @@
 """Token constants."""
-# Auto-generated by Tools/scripts/generate_token.py
+# Auto-generated by Tools/build/generate_token.py
 
 __all__ = ['tok_name', 'ISTERMINAL', 'ISNONTERMINAL', 'ISEOF']
 
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 7e2567173bc2..5b4bf15eb8aa 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -285,7 +285,7 @@ BUILDPYTHON=	python$(BUILDEXE)
 HOSTRUNNER= @HOSTRUNNER@
 
 PYTHON_FOR_REGEN?=@PYTHON_FOR_REGEN@
-UPDATE_FILE=$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/update_file.py
+UPDATE_FILE=$(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/update_file.py
 PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@
 # Single-platform builds depend on $(BUILDPYTHON). Cross builds use an
 # external "build Python" and have an empty PYTHON_FOR_BUILD_DEPS.
@@ -705,7 +705,7 @@ coverage-report: regen-token regen-frozen
 .PHONY=clinic
 clinic: check-clean-src $(srcdir)/Modules/_blake2/blake2s_impl.c
 	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/clinic/clinic.py --make --srcdir $(srcdir)
-	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_global_objects.py
+	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/generate_global_objects.py
 
 # Build the interpreter
 $(BUILDPYTHON):	Programs/python.o $(LINK_PYTHON_DEPS)
@@ -907,7 +907,7 @@ sharedmods: $(SHAREDMODS) pybuilddir.txt
 
 # dependency on BUILDPYTHON ensures that the target is run last
 checksharedmods: sharedmods $(PYTHON_FOR_BUILD_DEPS) $(BUILDPYTHON)
-	@$(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/Tools/scripts/check_extension_modules.py
+	@$(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/Tools/build/check_extension_modules.py
 
 rundsymutil: sharedmods $(PYTHON_FOR_BUILD_DEPS) $(BUILDPYTHON)
 	@if [ ! -z $(DSYMUTIL) ] ; then \
@@ -961,13 +961,13 @@ regen-test-frozenmain: $(BUILDPYTHON)
 .PHONY: regen-test-levenshtein
 regen-test-levenshtein:
 	# Regenerate Lib/test/levenshtein_examples.json
-	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_levenshtein_examples.py Lib/test/levenshtein_examples.json
+	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/generate_levenshtein_examples.py Lib/test/levenshtein_examples.json
 
 .PHONY: regen-re
 regen-re: $(BUILDPYTHON)
 	# Regenerate Lib/re/_casefix.py
-	# using Tools/scripts/generate_re_casefix.py
-	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/generate_re_casefix.py $(srcdir)/Lib/re/_casefix.py
+	# using Tools/build/generate_re_casefix.py
+	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/build/generate_re_casefix.py $(srcdir)/Lib/re/_casefix.py
 
 Programs/_testembed: Programs/_testembed.o $(LINK_PYTHON_DEPS)
 	$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/_testembed.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS)
@@ -1013,7 +1013,7 @@ _bootstrap_python: $(LIBRARY_OBJS_OMIT_FROZEN) Programs/_bootstrap_python.o Modu
 # 2) deepfreeze modules with external build Python.
 #
 
-# FROZEN_FILES_* are auto-generated by Tools/scripts/freeze_modules.py.
+# FROZEN_FILES_* are auto-generated by Tools/build/freeze_modules.py.
 FROZEN_FILES_IN = \
 		Lib/importlib/_bootstrap.py \
 		Lib/importlib/_bootstrap_external.py \
@@ -1149,11 +1149,11 @@ Python/frozen_modules/frozen_only.h: Tools/freeze/flag.py $(FREEZE_MODULE_DEPS)
 
 # END: freezing modules
 
-Tools/scripts/freeze_modules.py: $(FREEZE_MODULE)
+Tools/build/freeze_modules.py: $(FREEZE_MODULE)
 
 .PHONY: regen-frozen
-regen-frozen: Tools/scripts/freeze_modules.py $(FROZEN_FILES_IN)
-	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/freeze_modules.py
+regen-frozen: Tools/build/freeze_modules.py $(FROZEN_FILES_IN)
+	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/freeze_modules.py
 	@echo "The Makefile was updated, you may need to re-run make."
 
 ############################################################################
@@ -1162,11 +1162,11 @@ regen-frozen: Tools/scripts/freeze_modules.py $(FROZEN_FILES_IN)
 .PHONY: regen-deepfreeze
 regen-deepfreeze: $(DEEPFREEZE_OBJS)
 
-DEEPFREEZE_DEPS=$(srcdir)/Tools/scripts/deepfreeze.py $(FREEZE_MODULE_DEPS) $(FROZEN_FILES_OUT)
+DEEPFREEZE_DEPS=$(srcdir)/Tools/build/deepfreeze.py $(FREEZE_MODULE_DEPS) $(FROZEN_FILES_OUT)
 
 # BEGIN: deepfreeze modules
 Python/deepfreeze/deepfreeze.c: $(DEEPFREEZE_DEPS)
-	$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py \
+	$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/build/deepfreeze.py \
 	Python/frozen_modules/importlib._bootstrap.h:importlib._bootstrap \
 	Python/frozen_modules/importlib._bootstrap_external.h:importlib._bootstrap_external \
 	Python/frozen_modules/zipimport.h:zipimport \
@@ -1203,8 +1203,8 @@ regen-importlib: regen-frozen
 # Global objects
 
 .PHONY: regen-global-objects
-regen-global-objects: $(srcdir)/Tools/scripts/generate_global_objects.py
-	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_global_objects.py
+regen-global-objects: $(srcdir)/Tools/build/generate_global_objects.py
+	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/generate_global_objects.py
 	@echo "Note: Global objects can be added or removed by other tools (e.g. deepfreeze), "
 	@echo "      so be sure to re-run regen-global-objects after those tools."
 
@@ -1220,7 +1220,7 @@ check-abidump: all
 	abidiff $(srcdir)/Doc/data/python$(LDVERSION).abi "libpython$(LDVERSION).so" --drop-private-types --no-architecture --no-added-syms
 
 regen-limited-abi: all
-	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/stable_abi.py --generate-all $(srcdir)/Misc/stable_abi.toml
+	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/build/stable_abi.py --generate-all $(srcdir)/Misc/stable_abi.toml
 
 ############################################################################
 # Regenerate all generated files
@@ -1331,8 +1331,8 @@ regen-ast:
 .PHONY: regen-opcode
 regen-opcode:
 	# Regenerate Include/opcode.h from Lib/opcode.py
-	# using Tools/scripts/generate_opcode_h.py
-	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_opcode_h.py \
+	# using Tools/build/generate_opcode_h.py
+	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/generate_opcode_h.py \
 		$(srcdir)/Lib/opcode.py \
 		$(srcdir)/Include/opcode.h.new \
 		$(srcdir)/Include/internal/pycore_opcode.h.new
@@ -1342,23 +1342,23 @@ regen-opcode:
 .PHONY: regen-token
 regen-token:
 	# Regenerate Doc/library/token-list.inc from Grammar/Tokens
-	# using Tools/scripts/generate_token.py
-	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_token.py rst \
+	# using Tools/build/generate_token.py
+	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/generate_token.py rst \
 		$(srcdir)/Grammar/Tokens \
 		$(srcdir)/Doc/library/token-list.inc
 	# Regenerate Include/internal/pycore_token.h from Grammar/Tokens
-	# using Tools/scripts/generate_token.py
-	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_token.py h \
+	# using Tools/build/generate_token.py
+	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/generate_token.py h \
 		$(srcdir)/Grammar/Tokens \
 		$(srcdir)/Include/internal/pycore_token.h
 	# Regenerate Parser/token.c from Grammar/Tokens
-	# using Tools/scripts/generate_token.py
-	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_token.py c \
+	# using Tools/build/generate_token.py
+	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/generate_token.py c \
 		$(srcdir)/Grammar/Tokens \
 		$(srcdir)/Parser/token.c
 	# Regenerate Lib/token.py from Grammar/Tokens
-	# using Tools/scripts/generate_token.py
-	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_token.py py \
+	# using Tools/build/generate_token.py
+	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/generate_token.py py \
 		$(srcdir)/Grammar/Tokens \
 		$(srcdir)/Lib/token.py
 
@@ -1375,16 +1375,16 @@ regen-keyword:
 .PHONY: regen-stdlib-module-names
 regen-stdlib-module-names: all Programs/_testembed
 	# Regenerate Python/stdlib_module_names.h
-	# using Tools/scripts/generate_stdlib_module_names.py
+	# using Tools/build/generate_stdlib_module_names.py
 	$(RUNSHARED) ./$(BUILDPYTHON) \
-		$(srcdir)/Tools/scripts/generate_stdlib_module_names.py \
+		$(srcdir)/Tools/build/generate_stdlib_module_names.py \
 		> $(srcdir)/Python/stdlib_module_names.h.new
 	$(UPDATE_FILE) $(srcdir)/Python/stdlib_module_names.h $(srcdir)/Python/stdlib_module_names.h.new
 
 regen-sre:
 	# Regenerate Modules/_sre/sre_constants.h and Modules/_sre/sre_targets.h
-	# from Lib/re/_constants.py using Tools/scripts/generate_sre_constants.py
-	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_sre_constants.py \
+	# from Lib/re/_constants.py using Tools/build/generate_sre_constants.py
+	$(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/generate_sre_constants.py \
 		$(srcdir)/Lib/re/_constants.py \
 		$(srcdir)/Modules/_sre/sre_constants.h \
 		$(srcdir)/Modules/_sre/sre_targets.h
@@ -2511,7 +2511,7 @@ distclean: clobber docclean
 
 # Check that all symbols exported by libpython start with "Py" or "_Py"
 smelly: all
-	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/smelly.py
+	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/build/smelly.py
 
 # Find files with funny names
 funny:
@@ -2549,7 +2549,7 @@ patchcheck: all
 	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/patchcheck/patchcheck.py
 
 check-limited-abi: all
-	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/stable_abi.py --all $(srcdir)/Misc/stable_abi.toml
+	$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/build/stable_abi.py --all $(srcdir)/Misc/stable_abi.toml
 
 .PHONY: update-config
 update-config:
diff --git a/Misc/stable_abi.toml b/Misc/stable_abi.toml
index a8920d999e81..e78646fdea59 100644
--- a/Misc/stable_abi.toml
+++ b/Misc/stable_abi.toml
@@ -2,7 +2,7 @@
 # Please append new items at the end.
 
 # The syntax of this file is not fixed.
-# It is designed to be read only by Tools/stable_abi.py, which can change
+# It is designed to be read only by Tools/build/stable_abi.py, which can change
 # without notice.
 
 # For the history of the stable ABI prior to this file,
diff --git a/Modules/_sre/sre_constants.h b/Modules/_sre/sre_constants.h
index c63351473686..f030815c6c00 100644
--- a/Modules/_sre/sre_constants.h
+++ b/Modules/_sre/sre_constants.h
@@ -3,7 +3,7 @@
  *
  * regular expression matching engine
  *
- * Auto-generated by Tools/scripts/generate_sre_constants.py from
+ * Auto-generated by Tools/build/generate_sre_constants.py from
  * Lib/re/_constants.py.
  *
  * Copyright (c) 1997-2001 by Secret Labs AB.  All rights reserved.
diff --git a/Modules/_sre/sre_targets.h b/Modules/_sre/sre_targets.h
index 25b6edd436bb..62761a0000d8 100644
--- a/Modules/_sre/sre_targets.h
+++ b/Modules/_sre/sre_targets.h
@@ -3,7 +3,7 @@
  *
  * regular expression matching engine
  *
- * Auto-generated by Tools/scripts/generate_sre_constants.py from
+ * Auto-generated by Tools/build/generate_sre_constants.py from
  * Lib/re/_constants.py.
  *
  * Copyright (c) 1997-2001 by Secret Labs AB.  All rights reserved.
diff --git a/PC/python3dll.c b/PC/python3dll.c
index 89bbd05932b8..c1b88c66903b 100755
--- a/PC/python3dll.c
+++ b/PC/python3dll.c
@@ -1,7 +1,7 @@
 
 /* Re-export stable Python ABI */
 
-/* Generated by Tools/scripts/stable_abi.py */
+/* Generated by Tools/build/stable_abi.py */
 
 #ifdef _M_IX86
 #define DECORATE "_"
diff --git a/PCbuild/_freeze_module.vcxproj b/PCbuild/_freeze_module.vcxproj
index 39939a7ba983..49e5cc89a261 100644
--- a/PCbuild/_freeze_module.vcxproj
+++ b/PCbuild/_freeze_module.vcxproj
@@ -395,7 +395,7 @@
           DependsOnTargets="FindPythonForBuild"
           Condition="$(Configuration) != 'PGUpdate'">
     <!-- BEGIN deepfreeze rule -->
-	<Exec Command='$(PythonForBuild) "$(PySourcePath)Tools\scripts\deepfreeze.py" ^
+	<Exec Command='$(PythonForBuild) "$(PySourcePath)Tools\build\deepfreeze.py" ^
 		 "$(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" ^
diff --git a/PCbuild/regen.targets b/PCbuild/regen.targets
index 3938b66678ee..aeb7e2e185d9 100644
--- a/PCbuild/regen.targets
+++ b/PCbuild/regen.targets
@@ -13,7 +13,7 @@
     <_ASTOutputs Include="$(PySourcePath)Python\Python-ast.c">
       <Argument>-C</Argument>
     </_ASTOutputs>
-    <_OpcodeSources Include="$(PySourcePath)Tools\scripts\generate_opcode_h.py;$(PySourcePath)Lib\opcode.py" />
+    <_OpcodeSources Include="$(PySourcePath)Tools\build\generate_opcode_h.py;$(PySourcePath)Lib\opcode.py" />
     <_OpcodeOutputs Include="$(PySourcePath)Include\opcode.h;$(PySourcePath)Include\internal\pycore_opcode.h;$(PySourcePath)Python\opcode_targets.h" />
     <_TokenSources Include="$(PySourcePath)Grammar\Tokens" />
     <_TokenOutputs Include="$(PySourcePath)Doc\library\token-list.inc">
@@ -59,7 +59,7 @@
           Inputs="@(_OpcodeSources)" Outputs="@(_OpcodeOutputs)"
           DependsOnTargets="FindPythonForBuild">
     <Message Text="Regenerate @(_OpcodeOutputs->'%(Filename)%(Extension)',' ')" Importance="high" />
-    <Exec Command="$(PythonForBuild) Tools\scripts\generate_opcode_h.py Lib\opcode.py Include\opcode.h Include\internal\pycore_opcode.h"
+    <Exec Command="$(PythonForBuild) Tools\build\generate_opcode_h.py Lib\opcode.py Include\opcode.h Include\internal\pycore_opcode.h"
           WorkingDirectory="$(PySourcePath)" />
     <Exec Command="$(PythonForBuild) Python\makeopcodetargets.py Python\opcode_targets.h"
           WorkingDirectory="$(PySourcePath)" />
@@ -69,7 +69,7 @@
           Inputs="@(_TokenSources)" Outputs="@(_TokenOutputs)"
           DependsOnTargets="FindPythonForBuild">
     <Message Text="Regenerate @(_TokenOutputs->'%(Filename)%(Extension)',' ')" Importance="high" />
-    <Exec Command="$(PythonForBuild) Tools\scripts\generate_token.py %(_TokenOutputs.Format) Grammar\Tokens "%(_TokenOutputs.Identity)""
+    <Exec Command="$(PythonForBuild) Tools\build\generate_token.py %(_TokenOutputs.Format) Grammar\Tokens "%(_TokenOutputs.Identity)""
           WorkingDirectory="$(PySourcePath)" />
     <Touch Files="@(_TokenOutputs)" />
   </Target>
@@ -85,7 +85,7 @@
   <Target Name="_RegenGlobalObjects"
           DependsOnTargets="FindPythonForBuild">
     <Message Text="Regenerate Global Objects" Importance="high" />
-    <Exec Command="$(PythonForBuild) Tools\scripts\generate_global_objects.py"
+    <Exec Command="$(PythonForBuild) Tools\build\generate_global_objects.py"
           WorkingDirectory="$(PySourcePath)" />
   </Target>
 
diff --git a/Parser/token.c b/Parser/token.c
index fa03fbc450b2..6299ad2f5631 100644
--- a/Parser/token.c
+++ b/Parser/token.c
@@ -1,4 +1,4 @@
-/* Auto-generated by Tools/scripts/generate_token.py */
+/* Auto-generated by Tools/build/generate_token.py */
 
 #include "Python.h"
 #include "pycore_token.h"
diff --git a/Programs/_bootstrap_python.c b/Programs/_bootstrap_python.c
index 6ecbf0c72b5f..bbac0c4e1a8a 100644
--- a/Programs/_bootstrap_python.c
+++ b/Programs/_bootstrap_python.c
@@ -2,7 +2,7 @@
 /* Frozen modules bootstrap
  *
  * Limited and restricted Python interpreter to run
- * "Tools/scripts/deepfreeze.py" on systems with no or older Python
+ * "Tools/build/deepfreeze.py" on systems with no or older Python
  * interpreter.
  */
 
diff --git a/Programs/_freeze_module.c b/Programs/_freeze_module.c
index 3d27b79c237c..d6d737d48d60 100644
--- a/Programs/_freeze_module.c
+++ b/Programs/_freeze_module.c
@@ -2,7 +2,7 @@
    modules into frozen modules (like Lib/importlib/_bootstrap.py
    into Python/importlib.h).
 
-   This is used directly by Tools/scripts/freeze_modules.py, and indirectly by "make regen-frozen".
+   This is used directly by Tools/build/freeze_modules.py, and indirectly by "make regen-frozen".
 
    See Python/frozen.c for more info.
 
diff --git a/Python/deepfreeze/README.txt b/Python/deepfreeze/README.txt
index da55d4e7c746..276ab51143ab 100644
--- a/Python/deepfreeze/README.txt
+++ b/Python/deepfreeze/README.txt
@@ -3,4 +3,4 @@ modules.  Python/frozen.c depends on these files.
 
 None of these files are committed into the repo.
 
-See Tools/scripts/freeze_modules.py for more info.
+See Tools/build/freeze_modules.py for more info.
diff --git a/Python/frozen.c b/Python/frozen.c
index 8a2a7243537c..48b429519b66 100644
--- a/Python/frozen.c
+++ b/Python/frozen.c
@@ -8,7 +8,7 @@
  * These files must be regenerated any time the corresponding .pyc
  * file would change (including with changes to the compiler, bytecode
  * format, marshal format).  This can be done with "make regen-frozen".
- * That make target just runs Tools/scripts/freeze_modules.py.
+ * That make target just runs Tools/build/freeze_modules.py.
  *
  * The freeze_modules.py script also determines which modules get
  * frozen.  Update the list at the top of the script to add, remove,
diff --git a/Python/frozen_modules/README.txt b/Python/frozen_modules/README.txt
index 444167cc496a..795bb0efad34 100644
--- a/Python/frozen_modules/README.txt
+++ b/Python/frozen_modules/README.txt
@@ -4,4 +4,4 @@ modules.  Python/frozen.c depends on these files.
 Note that, other than the required frozen modules, none of these files
 are committed into the repo.
 
-See Tools/scripts/freeze_modules.py for more info.
+See Tools/build/freeze_modules.py for more info.
diff --git a/Python/stdlib_module_names.h b/Python/stdlib_module_names.h
index b28156608d1b..12827e775754 100644
--- a/Python/stdlib_module_names.h
+++ b/Python/stdlib_module_names.h
@@ -1,4 +1,4 @@
-// Auto-generated by Tools/scripts/generate_stdlib_module_names.py.
+// Auto-generated by Tools/build/generate_stdlib_module_names.py.
 // List used to create sys.stdlib_module_names.
 
 static const char* _Py_stdlib_module_names[] = {
diff --git a/Tools/scripts/check_extension_modules.py b/Tools/build/check_extension_modules.py
similarity index 100%
rename from Tools/scripts/check_extension_modules.py
rename to Tools/build/check_extension_modules.py
diff --git a/Tools/scripts/deepfreeze.py b/Tools/build/deepfreeze.py
similarity index 100%
rename from Tools/scripts/deepfreeze.py
rename to Tools/build/deepfreeze.py
diff --git a/Tools/scripts/freeze_modules.py b/Tools/build/freeze_modules.py
similarity index 99%
rename from Tools/scripts/freeze_modules.py
rename to Tools/build/freeze_modules.py
index aa1e4fe2ea0f..810224b28f2f 100644
--- a/Tools/scripts/freeze_modules.py
+++ b/Tools/build/freeze_modules.py
@@ -581,7 +581,7 @@ def regen_makefile(modules):
     frozenfiles = []
     rules = ['']
     deepfreezerules = ["Python/deepfreeze/deepfreeze.c: $(DEEPFREEZE_DEPS)",
-                       "\t$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py \\"]
+                       "\t$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/build/deepfreeze.py \\"]
     for src in _iter_sources(modules):
         frozen_header = relpath_for_posix_display(src.frozenfile, ROOT_DIR)
         frozenfiles.append(f'\t\t{frozen_header} \\')
@@ -646,7 +646,7 @@ def regen_pcbuild(modules):
     projlines = []
     filterlines = []
     corelines = []
-    deepfreezerules = ['\t<Exec Command=\'$(PythonForBuild) "$(PySourcePath)Tools\\scripts\\deepfreeze.py" ^']
+    deepfreezerules = ['\t<Exec Command=\'$(PythonForBuild) "$(PySourcePath)Tools\\build\\deepfreeze.py" ^']
     for src in _iter_sources(modules):
         pyfile = relpath_for_windows_display(src.pyfile, ROOT_DIR)
         header = relpath_for_windows_display(src.frozenfile, ROOT_DIR)
diff --git a/Tools/scripts/generate_global_objects.py b/Tools/build/generate_global_objects.py
similarity index 99%
rename from Tools/scripts/generate_global_objects.py
rename to Tools/build/generate_global_objects.py
index 0432bf50cf94..dd67cfedaddd 100644
--- a/Tools/scripts/generate_global_objects.py
+++ b/Tools/build/generate_global_objects.py
@@ -3,6 +3,7 @@
 import os.path
 import re
 
+SCRIPT_NAME = 'Tools/build/generate_global_objects.py'
 __file__ = os.path.abspath(__file__)
 ROOT = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
 INTERNAL = os.path.join(ROOT, 'Include', 'internal')
@@ -213,7 +214,7 @@ def open_for_changes(filename, orig):
 #######################################
 # the global objects
 
-START = '/* The following is auto-generated by Tools/scripts/generate_global_objects.py. */'
+START = f'/* The following is auto-generated by {SCRIPT_NAME}. */'
 END = '/* End auto-generated code */'
 
 
diff --git a/Tools/scripts/generate_levenshtein_examples.py b/Tools/build/generate_levenshtein_examples.py
similarity index 100%
rename from Tools/scripts/generate_levenshtein_examples.py
rename to Tools/build/generate_levenshtein_examples.py
diff --git a/Tools/scripts/generate_opcode_h.py b/Tools/build/generate_opcode_h.py
similarity index 99%
rename from Tools/scripts/generate_opcode_h.py
rename to Tools/build/generate_opcode_h.py
index 9ff264af9cdc..372221a14d07 100644
--- a/Tools/scripts/generate_opcode_h.py
+++ b/Tools/build/generate_opcode_h.py
@@ -3,7 +3,7 @@
 import sys
 import tokenize
 
-SCRIPT_NAME = "Tools/scripts/generate_opcode_h.py"
+SCRIPT_NAME = "Tools/build/generate_opcode_h.py"
 PYTHON_OPCODE = "Lib/opcode.py"
 
 header = f"""
diff --git a/Tools/scripts/generate_re_casefix.py b/Tools/build/generate_re_casefix.py
similarity index 95%
rename from Tools/scripts/generate_re_casefix.py
rename to Tools/build/generate_re_casefix.py
index 625b0658d97d..b57ac07426c2 100755
--- a/Tools/scripts/generate_re_casefix.py
+++ b/Tools/build/generate_re_casefix.py
@@ -5,6 +5,8 @@
 import sys
 import unicodedata
 
+SCRIPT_NAME = 'Tools/build/generate_re_casefix.py'
+
 def update_file(file, content):
     try:
         with open(file, 'r', encoding='utf-8') as fobj:
@@ -16,8 +18,8 @@ def update_file(file, content):
         fobj.write(content)
     return True
 
-re_casefix_template = """\
-# Auto-generated by Tools/scripts/generate_re_casefix.py.
+re_casefix_template = f"""\
+# Auto-generated by {SCRIPT_NAME}.
 
 # Maps the code of lowercased character to codes of different lowercased
 # characters which have the same uppercase.
diff --git a/Tools/scripts/generate_sre_constants.py b/Tools/build/generate_sre_constants.py
similarity index 94%
rename from Tools/scripts/generate_sre_constants.py
rename to Tools/build/generate_sre_constants.py
index 72715076d29a..abea069c8bc0 100755
--- a/Tools/scripts/generate_sre_constants.py
+++ b/Tools/build/generate_sre_constants.py
@@ -1,6 +1,8 @@
 #! /usr/bin/env python3
 # This script generates Modules/_sre/sre_constants.h from Lib/re/_constants.py.
 
+SCRIPT_NAME = 'Tools/build/generate_sre_constants.py'
+
 
 def update_file(file, content):
     try:
@@ -13,13 +15,13 @@ def update_file(file, content):
         fobj.write(content)
     return True
 
-sre_constants_header = """\
+sre_constants_header = f"""\
 /*
  * Secret Labs' Regular Expression Engine
  *
  * regular expression matching engine
  *
- * Auto-generated by Tools/scripts/generate_sre_constants.py from
+ * Auto-generated by {SCRIPT_NAME} from
  * Lib/re/_constants.py.
  *
  * Copyright (c) 1997-2001 by Secret Labs AB.  All rights reserved.
diff --git a/Tools/scripts/generate_stdlib_module_names.py b/Tools/build/generate_stdlib_module_names.py
similarity index 96%
rename from Tools/scripts/generate_stdlib_module_names.py
rename to Tools/build/generate_stdlib_module_names.py
index 92100bd06509..e4f09f88d0a3 100644
--- a/Tools/scripts/generate_stdlib_module_names.py
+++ b/Tools/build/generate_stdlib_module_names.py
@@ -10,6 +10,8 @@
 from check_extension_modules import ModuleChecker
 
 
+SCRIPT_NAME = 'Tools/build/generate_stdlib_module_names.py'
+
 SRC_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
 STDLIB_PATH = os.path.join(SRC_DIR, 'Lib')
 
@@ -112,7 +114,7 @@ def list_modules():
 
 
 def write_modules(fp, names):
-    print("// Auto-generated by Tools/scripts/generate_stdlib_module_names.py.",
+    print(f"// Auto-generated by {SCRIPT_NAME}.",
           file=fp)
     print("// List used to create sys.stdlib_module_names.", file=fp)
     print(file=fp)
diff --git a/Tools/scripts/generate_token.py b/Tools/build/generate_token.py
similarity index 94%
rename from Tools/scripts/generate_token.py
rename to Tools/build/generate_token.py
index d8be8b93de14..fc12835b7762 100755
--- a/Tools/scripts/generate_token.py
+++ b/Tools/build/generate_token.py
@@ -7,6 +7,8 @@
 #   Lib/token.py
 
 
+SCRIPT_NAME = 'Tools/build/generate_token.py'
+AUTO_GENERATED_BY_SCRIPT = f'Auto-generated by {SCRIPT_NAME}'
 NT_OFFSET = 256
 
 def load_tokens(path):
@@ -47,8 +49,10 @@ def update_file(file, content):
     return True
 
 
-token_h_template = """\
-/* Auto-generated by Tools/scripts/generate_token.py */
+token_h_template = f"""\
+/* {AUTO_GENERATED_BY_SCRIPT} */
+"""
+token_h_template += """\
 
 /* Token types */
 #ifndef Py_INTERNAL_TOKEN_H
@@ -105,8 +109,10 @@ def make_h(infile, outfile='Include/internal/pycore_token.h'):
         print("%s regenerated from %s" % (outfile, infile))
 
 
-token_c_template = """\
-/* Auto-generated by Tools/scripts/generate_token.py */
+token_c_template = f"""\
+/* {AUTO_GENERATED_BY_SCRIPT} */
+"""
+token_c_template += """\
 
 #include "Python.h"
 #include "pycore_token.h"
@@ -189,8 +195,8 @@ def make_c(infile, outfile='Parser/token.c'):
         print("%s regenerated from %s" % (outfile, infile))
 
 
-token_inc_template = """\
-.. Auto-generated by Tools/scripts/generate_token.py
+token_inc_template = f"""\
+.. {AUTO_GENERATED_BY_SCRIPT}
 %s
 .. data:: N_TOKENS
 
@@ -213,10 +219,11 @@ def make_rst(infile, outfile='Doc/library/token-list.inc'):
         print("%s regenerated from %s" % (outfile, infile))
 
 
-token_py_template = '''\
+token_py_template = f'''\
 """Token constants."""
-# Auto-generated by Tools/scripts/generate_token.py
-
+# {AUTO_GENERATED_BY_SCRIPT}
+'''
+token_py_template += '''
 __all__ = ['tok_name', 'ISTERMINAL', 'ISNONTERMINAL', 'ISEOF']
 
 %s
diff --git a/Tools/scripts/parse_html5_entities.py b/Tools/build/parse_html5_entities.py
similarity index 97%
rename from Tools/scripts/parse_html5_entities.py
rename to Tools/build/parse_html5_entities.py
index 1e5bdad21655..d2bf29091030 100755
--- a/Tools/scripts/parse_html5_entities.py
+++ b/Tools/build/parse_html5_entities.py
@@ -18,6 +18,7 @@
 from urllib.request import urlopen
 from html.entities import html5
 
+SCRIPT_NAME = 'Tools/build/parse_html5_entities.py'
 PAGE_URL = 'https://html.spec.whatwg.org/multipage/named-characters.html'
 ENTITIES_URL = 'https://html.spec.whatwg.org/entities.json'
 HTML5_SECTION_START = '# HTML5 named character references'
@@ -69,7 +70,7 @@ def write_items(entities, file=sys.stdout):
     keys = sorted(entities.keys())
     keys = sorted(keys, key=str.lower)
     print(HTML5_SECTION_START, file=file)
-    print(f'# Generated by {sys.argv[0]!r}\n'
+    print(f'# Generated by {SCRIPT_NAME}\n'
           f'# from {ENTITIES_URL} and\n'
           f'# {PAGE_URL}.\n'
           f'# Map HTML5 named character references to the '
diff --git a/Tools/scripts/smelly.py b/Tools/build/smelly.py
similarity index 100%
rename from Tools/scripts/smelly.py
rename to Tools/build/smelly.py
diff --git a/Tools/scripts/stable_abi.py b/Tools/build/stable_abi.py
old mode 100755
new mode 100644
similarity index 99%
rename from Tools/scripts/stable_abi.py
rename to Tools/build/stable_abi.py
index d557e102ea8e..88db93e935e9
--- a/Tools/scripts/stable_abi.py
+++ b/Tools/build/stable_abi.py
@@ -24,6 +24,7 @@
 import re
 import csv
 
+SCRIPT_NAME = 'Tools/build/stable_abi.py'
 MISSING = object()
 
 EXCLUDED_HEADERS = {
@@ -182,11 +183,12 @@ def _decorator(func):
 def gen_python3dll(manifest, args, outfile):
     """Generate/check the source for the Windows stable ABI library"""
     write = partial(print, file=outfile)
-    write(textwrap.dedent(r"""
+    content = f"""
         /* Re-export stable Python ABI */
 
-        /* Generated by Tools/scripts/stable_abi.py */
-
+        /* Generated by {SCRIPT_NAME} */
+    """
+    content += r"""
         #ifdef _M_IX86
         #define DECORATE "_"
         #else
@@ -197,7 +199,8 @@ def gen_python3dll(manifest, args, outfile):
             __pragma(comment(linker, "/EXPORT:" DECORATE #name "=" PYTHON_DLL_NAME "." #name))
         #define EXPORT_DATA(name) \
             __pragma(comment(linker, "/EXPORT:" DECORATE #name "=" PYTHON_DLL_NAME "." #name ",DATA"))
-    """))
+    """
+    write(textwrap.dedent(content))
 
     def sort_key(item):
         return item.name.lower()
diff --git a/Tools/scripts/umarshal.py b/Tools/build/umarshal.py
similarity index 100%
rename from Tools/scripts/umarshal.py
rename to Tools/build/umarshal.py
diff --git a/Tools/scripts/update_file.py b/Tools/build/update_file.py
similarity index 100%
rename from Tools/scripts/update_file.py
rename to Tools/build/update_file.py
diff --git a/Tools/scripts/verify_ensurepip_wheels.py b/Tools/build/verify_ensurepip_wheels.py
similarity index 100%
rename from Tools/scripts/verify_ensurepip_wheels.py
rename to Tools/build/verify_ensurepip_wheels.py



More information about the Python-checkins mailing list