Re: Writing do_compile in python and importing modules

Quentin Schulz


On Tue, Dec 10, 2019 at 11:15:01AM +0000, Ross Burton wrote:
On 09/12/2019 16:30, Patrick Doyle wrote:
But then I started wondering if I could change do_compile to python,
have it import assemble-tsk-blob, and get the best of both worlds --
the ability to test assemble-tsk-blob outside of bitbake, and the
efficiency of including its core operation directly within
do_compile() and not requring that I spin up another python instance.
Every layer can have a lib/ folder which is on the Python search path
(you'll see lots of recipes use oe.*, which is meta/lib/oe/) so you can just
put Python modules in there.
I'm currently having issues with that on Thud though.

We have a few python scripts in there and changes to those are not
reflected in Yocto and do not trigger a rebuild.

We have a meta/lib/mypython/ directory where python scripts are.

We have a mypython.bbclass which `import mypython.functions`, which
declares some python functions which calls the functions in
meta/lib/mypython/ appropriately. Changes to this class are
obviously triggering a rebuild of recipes inheriting this class.

This we import also does `import mypython.custom`
containing some class and array of objects of that class.
Changes to at least meta/lib/mypython/ (maybe even
meta/lib/mypython/ but can't confirm yet) are not triggering
a rebuild.

From my experience, the python calls are actually stored as plaintext in
the taskhash and not resolved at parse time, making Yocto unaware of any
change in tasks that should trigger a rebuild.
We're adding those files to filechecksums vardeps of all tasks in the
That's the work-around I've found but I don't like it that much, so if
this meta/lib/ is actually well supported, I'd be very happy to fix my
stuff the correct way :)


Join to automatically receive all group messages.