Re: source-less python


Aurum Nitrogen
 

Hi, 
So after a little bit of research, I've implemented this feature in poky.
The way buildroot works, is that it doesn't create any .pyc files during the build process of single packages but has a post rootfs hook that (If that's what the user has configured) compiles the .py files into .pyc files and removes the .py files.
The compilation to .pyc files is done using a small script that uses python's py_compile module.
 
I have attached the diff to poky for implementation of this feature and the pycompile.py script.
I would love to get your input on this.

Another thing I noticed while doing this research was that the python recipe has a variable called INCLUDE_PYCS that decides if to include the .pyc files in the package. This is nice but why not implement this in the rest of the python package recipes? It can be added to setuptools3.bbclass or something like that. What do you think?

Thanks a lot,

John

‫בתאריך יום ה׳, 23 ביוני 2022 ב-19:10 מאת ‪Ross Burton‬‏ <‪Ross.Burton@...‬‏>:‬

On 23 Jun 2022, at 23:40, Aurum Nitrogen via lists.yoctoproject.org <aurumnitrogen=gmail.com@...> wrote:
>
> Hi,
> I was wondering if there has been talk about support for source-less python on an image. Installing py and pyc files doubles the size of python on the rootfs. I can imagine this being implemented as an image feature.
> I know that in buildroot it is supported.
> Was this discussed and decided against? Is this an open issue?


There’s an open issue: https://bugzilla.yoctoproject.org/show_bug.cgi?id=6434

The easiest implementation would be a rootfs-time postprocessing step where you compile every .py file, and then delete the .py.  Is this what buildroot does?

This does break feeds, but the alternative (of changing how packaging is done) would be a lot more invasive.

Ross
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

Join {yocto@lists.yoctoproject.org to automatically receive all group messages.