bpo-45949: Pure Python freeze module for cross builds (GH-29899)

This commit is contained in:
Christian Heimes 2021-12-13 21:48:46 +02:00 committed by GitHub
parent a62be77266
commit eb483c46d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 205 additions and 115 deletions

View file

@ -264,6 +264,10 @@ class FrozenSource(namedtuple('FrozenSource', 'id pyfile frozenfile deepfreezefi
else:
return os.path.basename(self.pyfile) == '__init__.py'
@property
def isbootstrap(self):
return self.id in BOOTSTRAP
def resolve_frozen_file(frozenid, destdir):
"""Return the filename corresponding to the given frozen ID.
@ -476,7 +480,7 @@ def regen_frozen(modules):
indent = ' '
lastsection = None
for mod in modules:
if mod.frozenid in BOOTSTRAP:
if mod.isbootstrap:
lines = bootstraplines
elif mod.section == TESTS_SECTION:
lines = testlines
@ -585,10 +589,17 @@ def regen_makefile(modules):
pyfile = relpath_for_posix_display(src.pyfile, ROOT_DIR)
pyfiles.append(f'\t\t{pyfile} \\')
freeze = (f'$(FREEZE_MODULE) {src.frozenid} '
f'$(srcdir)/{pyfile} {frozen_header}')
if src.isbootstrap:
freezecmd = '$(FREEZE_MODULE_BOOTSTRAP)'
freezedep = '$(FREEZE_MODULE_BOOTSTRAP_DEPS)'
else:
freezecmd = '$(FREEZE_MODULE)'
freezedep = '$(FREEZE_MODULE_DEPS)'
freeze = (f'{freezecmd} {src.frozenid} '
f'$(srcdir)/{pyfile} {frozen_header}')
rules.extend([
f'{frozen_header}: $(FREEZE_MODULE) {pyfile}',
f'{frozen_header}: {pyfile} {freezedep}',
f'\t{freeze}',
'',
])