mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
bpo-45949: Pure Python freeze module for cross builds (GH-29899)
This commit is contained in:
parent
a62be77266
commit
eb483c46d6
9 changed files with 205 additions and 115 deletions
|
|
@ -393,13 +393,14 @@ def generate(self, name: str, obj: object) -> str:
|
|||
}
|
||||
"""
|
||||
|
||||
FROZEN_COMMENT = "/* Auto-generated by Programs/_freeze_module.c */"
|
||||
FROZEN_COMMENT_C = "/* Auto-generated by Programs/_freeze_module.c */"
|
||||
FROZEN_COMMENT_PY = "/* Auto-generated by Programs/_freeze_module.py */"
|
||||
|
||||
FROZEN_DATA_LINE = r"\s*(\d+,\s*)+\s*"
|
||||
|
||||
|
||||
def is_frozen_header(source: str) -> bool:
|
||||
return source.startswith(FROZEN_COMMENT)
|
||||
return source.startswith((FROZEN_COMMENT_C, FROZEN_COMMENT_PY))
|
||||
|
||||
|
||||
def decode_frozen_data(source: str) -> types.CodeType:
|
||||
|
|
|
|||
|
|
@ -264,6 +264,10 @@ def ispkg(self):
|
|||
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}',
|
||||
'',
|
||||
])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue