Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Freezing zipimport into _bootstrap_python #99582

Closed
kkpattern opened this issue Nov 18, 2022 · 3 comments
Closed

Freezing zipimport into _bootstrap_python #99582

kkpattern opened this issue Nov 18, 2022 · 3 comments
Labels
type-feature A feature request or enhancement

Comments

@kkpattern
Copy link
Contributor

kkpattern commented Nov 18, 2022

Feature or enhancement

Freezing zipimport module into _boostrap_python.

Pitch

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.

Previous discussion

https://discuss.python.org/t/how-about-freezing-zipimport-into-bootstrap-python/21203

Linked PRs

@kumaraditya303
Copy link
Contributor

What is the change in binary size after adding zipimport?

@kkpattern
Copy link
Contributor Author

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.

kumaraditya303 added a commit that referenced this issue Dec 10, 2022
@kumaraditya303
Copy link
Contributor

Since this only affects _bootstrap_python I am fine with it. Thanks for the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants