bpo-47146: Avoid Using make Recursively (gh-32206)

https://bugs.python.org/issue47146
This commit is contained in:
Eric Snow 2022-03-30 19:24:02 -06:00 committed by GitHub
parent f3d5715492
commit db4dada510
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 10 deletions

View File

@ -1136,10 +1136,7 @@ regen-frozen: Tools/scripts/freeze_modules.py $(FROZEN_FILES_IN)
# Deepfreeze targets
.PHONY: regen-deepfreeze
regen-deepfreeze:
@# Possibly generate globals first, to make sure _bootstrap_python builds.
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_global_objects.py
$(MAKE) $(DEEPFREEZE_OBJS)
regen-deepfreeze: $(DEEPFREEZE_OBJS)
DEEPFREEZE_DEPS=$(srcdir)/Tools/scripts/deepfreeze.py $(FREEZE_MODULE_DEPS) $(FROZEN_FILES_OUT)
@ -1180,13 +1177,25 @@ regen-importlib: regen-frozen
############################################################################
# Global objects
.PHONY: regen-global-objects
regen-global-objects: regen-deepfreeze
@# We already ran in once, before deepfreezing, to make sure
@# _bootstrap_python builds. Now we run it again to catch any
@# remaining globals, including those added by deepfreeze.
GLOBAL_OBJECTS_TARGETS = \
$(srcdir)/Include/internal/pycore_global_objects.h \
$(srcdir)/Include/internal/pycore_global_strings.h
# The global objects will get regenerated as soon these files
# are required, including as a prerequisite for regen-deepfreeze.
$(GLOBAL_OBJECTS_TARGETS): generate-global-objects
.PHONY: generate-global-objects
generate-global-objects: $(srcdir)/Tools/scripts/generate_global_objects.py
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_global_objects.py
.PHONY: generate-global-objects-after-deepfreeze
generate-global-objects-after-deepfreeze: regen-deepfreeze $(srcdir)/Tools/scripts/generate_global_objects.py
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_global_objects.py
.PHONY: regen-global-objects
regen-global-objects: regen-deepfreeze generate-global-objects-after-deepfreeze
############################################################################
# ABI

View File

@ -115,7 +115,12 @@ def iter_global_strings():
id_regex = re.compile(r'\b_Py_ID\((\w+)\)')
str_regex = re.compile(r'\b_Py_DECLARE_STR\((\w+), "(.*?)"\)')
for filename in iter_files():
with open(filename, encoding='utf-8') as infile:
try:
infile = open(filename, encoding='utf-8')
except FileNotFoundError:
# The file must have been a temporary file.
continue
with infile:
for lno, line in enumerate(infile, 1):
for m in id_regex.finditer(line):
identifier, = m.groups()