From my understanding Yocto trys to provide small images. As result kernel and python modules get packed into individual packages and you need to cherry pick the packages you need. That allows small images. Python itself packs for the module all of the following files and build output: - <module>.py - <module>.pyc - <module>.pyo Usually only the .pyc file is required to run applications. Deleting all the .py and .pyo files in /usr/lib/python2.7 (and propably all the other versions) reduces the size python requires significantly by around 50%. I would prefere having one of the following options to avoid having big images due of python overhead: - a configuration option to only pack the .pyc files (and not .pyo and .py) - to have only individual packages like python-<module>-pyc, python-<module>-pyo, python-<module>-py where only the -pyc files are installed by default (and the other packages can be cherry picked)
From reading the internets it appears that Python's "optimisation" is simply to take the .pyc and remove docstrings, line numbers and asserts. Code would have to be incredibly assert-heavy for this to be noticeable, and dropping line numbers/docstrings can be actively harmful. Globally deleting .pyo (or not generating them in the first place) seems reasonable to me. Offering an option for systems which are "finished" to solely ship the .pyc seems like a reasonable idea.
Please also reference http://stackoverflow.com/questions/8822335/what-does-python-file-extensions-pyc-pyd-pyo-stand-for for the differences Beside this, I think I saw a non-Yocto distribution in the past that did not ship the pyc and only compiled it on installation. Beside this, Ubuntu 13.10 does not install the .pyo files.
We now don't generate the pointless .pyo files by default. It would be fairly convenient to have an option to just ship .pyc for situations where the source isn't needed.
I'm looking to remove the .py files from the python_2.7.14.bb recipe from my image over at https://github.com/openbmc/openbmc (we're running into some flash space issues). I saw a potential mechanism to do this posted in http://lists.openembedded.org/pipermail/openembedded-core/2015-January/100453.html but I'm not having much luck getting it to work. Any pointers on how I could use a .bbappend to ensure that only the .pyc files from the python recipe get packaged into my rootfs?
Not sure if it's ideal, but I ended up just manually removing them via a bbappend. https://gerrit.openbmc-project.xyz/#/c/openbmc/meta-phosphor/+/12232/
Assigning to the listed Python maintainer. Still a good idea for resource-constrained systems.
In summary, pyo aren't built any more. The proposal here is to allow only pyc on target and to remove the py files. Whilst the manifest generation is much more modern, we still don't support that. The idea is valid but we're not sure it is that useful or a priority. There are risks that the pyc files might not be valid on target.
No one is working on this and it doesn't seem to be all that critical so moving to Low importance.