You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Provide pure-Python implementation of Programs/_freeze_module for cross building #90107
As of today 3.11-dev requires Programs/_freeze_module to compile Python code to byte code. The dependency on an extra and special tool makes cross building more complicated. The _freeze_module is trivial and can be easily implemented in pure Python code. The re-introduction of _bootstrap_python helper would allow us to use a pure Python freeze_module for all modules except two importlib bootstrap modules. I have a proof of concept implementation that works for me.
use user-provider Python interpreter (./configure --with-build-python) to generate all Python/frozen_modules/*.h with new freezemodule.py tool.
When cross building the user must already provide a Python interpreter with same version and bytecode version as the build target. Users would no longer need to provide a _freeze_module binary with ./configure --with-freeze-module.
In his code review Eric made a point that the relationship of variables and their impact on normal and cross builds are not obvious. I'm going to introduce new variables for freezing and freezing dependencies. Bonus: Cross builds no longer build non-functional _bootstrap_python and Programs/_freeze_module.
Activity
tiran commentedon Dec 1, 2021
As of today 3.11-dev requires Programs/_freeze_module to compile Python code to byte code. The dependency on an extra and special tool makes cross building more complicated. The _freeze_module is trivial and can be easily implemented in pure Python code. The re-introduction of _bootstrap_python helper would allow us to use a pure Python freeze_module for all modules except two importlib bootstrap modules. I have a proof of concept implementation that works for me.
Proposal for standard builds:
Proposal for cross builds:
When cross building the user must already provide a Python interpreter with same version and bytecode version as the build target. Users would no longer need to provide a _freeze_module binary with ./configure --with-freeze-module.
ericsnowcurrently commentedon Dec 1, 2021
IIRC, Programs/_freeze_module.c was originally a C implementation of the basic functionality in Tools/freeze/freeze.py.
ericsnowcurrently commentedon Dec 1, 2021
Ideally we would not have two scripts that do the same thing.
tiran commentedon Dec 9, 2021
Eric, could you review my PR, please? It simplifies cross building to other platforms.
I took a look at Tools/freeze/freeze.py. The freeze tool creates different output than Program/_freeze_module.c.
tiran commentedon Dec 11, 2021
In his code review Eric made a point that the relationship of variables and their impact on normal and cross builds are not obvious. I'm going to introduce new variables for freezing and freezing dependencies. Bonus: Cross builds no longer build non-functional _bootstrap_python and Programs/_freeze_module.
Normal build:
PYTHON_FOR_FREEZE=./_bootstrap_python
FREEZE_MODULE_BOOTSTRAP=./Programs/_freeze_module
FREEZE_MODULE_BOOTSTRAP_DEPS=Programs/_freeze_module
FREEZE_MODULE=$(PYTHON_FOR_FREEZE) $(srcdir)/Programs/_freeze_module.py
FREEZE_MODULE_DEPS=_bootstrap_python $(srcdir)/Programs/_freeze_module.py
Cross build:
PYTHON_FOR_FREEZE=/path/to/build/python
FREEZE_MODULE_BOOTSTRAP=$(PYTHON_FOR_FREEZE) $(srcdir)/Programs/_freeze_module.py
FREEZE_MODULE_BOOTSTRAP_DEPS=$(srcdir)/Programs/_freeze_module.py
FREEZE_MODULE=$(FREEZE_MODULE_BOOTSTRAP)
FREEZE_MODULE_DEPS=$(FREEZE_MODULE_BOOTSTRAP_DEPS)
tiran commentedon Dec 13, 2021
New changeset eb483c4 by Christian Heimes in branch 'main':
bpo-45949: Pure Python freeze module for cross builds (GH-29899)
eb483c4
tiran commentedon Dec 13, 2021
Thanks for your review, Eric!
ericsnowcurrently commentedon Dec 13, 2021
You're welcome! Thanks for doing the work!