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
add the '--enable-sourceless-distribution' option to configure #71039
Comments
Add a COMPILEALL_FLAGS Makefile variable to allow setting this flag to have legacy locations for byte-code files and save space on mobile devices. Patch attached. |
The python '-E' option was needed on 3.4 when this patch was first implemented and is not needed anymore at the current tip (changeset 2ef61a4747eb, Apr 27 2016). New patch. |
See msg 269359 in bpo-22724. |
Install byte-code files to their legacy locations and names to save space (default are the PEP-3147 locations and names) when configure is run with '--enable-legacy-pyc-files'. The patch does not prevent ensurepip to use PEP-3147 locations and names when it is run at the end of the installation. As many tests use the linecache module, it makes sense to skip the installation of the test suite aas well since the patch removes all *.py files (except those installed by ensurepip in site-packages). This can be done when bpo-27640 is resolved by using '--disable-test-suite'. The size of the standard library [1] [2]: [1] without the extension modules |
hmm, I really don't buy the space-saving argument. you are saving some space with shorter path names, nothing more. so why do you introduce this option? |
No, compileall is run with '-b', so there are no PEP-3147 __pycache__ directories, and with an installation of 53M where the test suite is excluded, that saves 30M (see my previous msg). IMHO this option is very useful on mobile devices and embedded systems where space is sparse. |
I can also say that in the Buildroot project, we have patches to get rid of the PEP-3147 stuff. Indeed, the PEP-3147 forces one to have both the .py *and* the .pyc file for a given module. If you have only the .pyc file, Python does not recognize it and it cannot be imported. By removing the PEP-3147 functionality, we are able to keep only the .pyc files on the target, therefore dividing roughly by two the size of the Python installation. |
I think a proposal to add an option like this requires more discussion, probably a PEP. |
but these are rebuilt when you start the interpreter, aren't they? |
No, if you remove PEP-3147 (like the Buildroot patch does), and install only the .pyc files, you have a smaller Python installation, and nothing gets "re-generated", since what you already have are the .pyc files. The .py files are not even installed on the target system. |
No. Quoting PEP-3147:
|
Our official position (so far, mobile is a new use case since the last time it was discussed) is that we don't go out of our way to support sourceless distribution, and in general we discourage it. That is, it is left to the packager of a sourceless program to deal with removing the source and putting the .pyc files in the right place for python to find them. So, yes, this requires at *least* a discussion on python-ideas, and possibly a PEP. If this is adopted '--enable-legacy-pyc' would be the wrong name for the option, since it is in fact forcing legacy pyc...and if the only reason is to reduce space by omitting the source, then it should also not install the source so the name is wrong :) But, this conversation should continue on python-ideas. I'm -1 myself, for the record. |
About doko's note and your response: unless this patch does not install the source (I haven't looked), the __pycache__ files *will* be rebuilt at interpreter start, according to the text you quoted. |
Also, has anyone tried bundling the std lib into a zlib? I know that option has been around for a long time but I don't know if it still works or is even being used. Presumably, that would be another way to save space and file system entries. |
I miss your point, msg271515 said earlier "the patch removes all *.py files". |
Right, and since the source files are removed, the __pycache__ files are *not* built. Hence my negative answer to Matthias. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: