[yocto] Reducing the size of the image by optimizing python
Mike Looijmans
mike.looijmans at topicproducts.com
Mon Oct 21 04:50:25 PDT 2019
> Optimising to just pyc files is an optimisation further than most
> people find they need and will be much harder to do.
It's actually quite simple, just add a bbappend to the python recipe that puts
all .py files into the "dbg" or newly created "src" package. Or simply delete
all .py files in a do_install_append.
Here's an example of the "src" approach:
https://github.com/OpenPLi/openpli-oe-core/blob/develop/meta-openpli/recipes-devtools/python/python_2.7.13.bbappend
Simply doing this in the bbappend might also work (untested):
do_install_append() {
find ${D}${libdir}/python${PYTHON_MAJMIN}/ -name '*.py' -remove
}
Removing the ".py" files roughly cuts the disk space in half.
The "src" approach works on any package, and has the advantage that you can
still install the source files for debugging and development.
Met vriendelijke groet / kind regards,
Mike Looijmans
System Expert
TOPIC Embedded Products B.V.
Materiaalweg 4, 5681 RJ Best
Postbus 440, 5680 AK Best
The Netherlands
T: +31 (0) 499 33 69 69
E: {E-mail
W: www.topicproducts.com
Please consider the environment before printing this e-mail
More information about the yocto
mailing list