Currently, _bootstrap_python is used to freeze modules during python building. When running _bootstrap_python, stdlib files can be found in the source directory. However, when embedding cpython into another program, other build systems may be used to build cpython. Furthermore, these build systems may build cpython out of the source tree, even in a sandbox directory. Now, in order for the _bootstrap_python to function, we need to distribute the stdlib into the build directory. In this situation, a zip file of stdlib is the preferable way to do it. Unfortunately, the zipimport is not frozen into _bootstrap_python, so we can’t use a zip stdlib.
If we freeze zipimport into _bootstrap_python it will ease the build process a lot. It’s a minor patch. We have tested it on Windows, Linux, and macOS. Admittedly, this change has no additional benefit to normal python building. But it doesn’t seem to be doing any harm.
On macOS, the size of _bootstrap_python on the main branch is 5014960 bytes. After adding zipimport it's 5031408 bytes. The size of the final python binary is identical.
kkpattern commentedNov 18, 2022
•
edited by bedevere-bot
Feature or enhancement
Freezing
zipimportmodule into_boostrap_python.Pitch
Currently,
_bootstrap_pythonis used to freeze modules during python building. When running_bootstrap_python, stdlib files can be found in the source directory. However, when embedding cpython into another program, other build systems may be used to build cpython. Furthermore, these build systems may build cpython out of the source tree, even in a sandbox directory. Now, in order for the_bootstrap_pythonto function, we need to distribute the stdlib into the build directory. In this situation, a zip file of stdlib is the preferable way to do it. Unfortunately, thezipimportis not frozen into _bootstrap_python, so we can’t use a zip stdlib.If we freeze
zipimportinto_bootstrap_pythonit will ease the build process a lot. It’s a minor patch. We have tested it on Windows, Linux, and macOS. Admittedly, this change has no additional benefit to normal python building. But it doesn’t seem to be doing any harm.Previous discussion
https://discuss.python.org/t/how-about-freezing-zipimport-into-bootstrap-python/21203
Linked PRs
The text was updated successfully, but these errors were encountered: