[U-Boot] [PATCH] libfdt: fix build with Python 3

Stefano Babic sbabic at denx.de
Wed Apr 5 17:26:32 UTC 2017


Hi Stefan,

On 04/04/2017 20:44, Stefan Agner wrote:
> On 2017-04-04 01:53, Stefano Babic wrote:
>> Hi Stefan,
>>
>> On 03/04/2017 23:02, Stefan Agner wrote:
>>
>>> But then, I don't expect that "/usr/bin/env python" is looking at
>>> PYTHON.
>>>
>>> As far as I understand env, it just looks up the current environment to
>>> run its COMMAND argument.
>>
>> Agree, this is also mz understanding.
>>
>>> It is helpful as a shebang, but it does not
>>> seem to make any difference to calling "python" directly (since that
>>> also just looks up the current environment PATH and executes the first
>>> python it finds...
>>
>> Agree - so that is disturbing is the fix calls to "python" inside
>> Makefile. That means it remains to change:
>>
>> tools/_libfdt.so: $(patsubst %.o,%.c,$(LIBFDT_OBJS)) tools/libfdt_wrap.c
>> 	LDFLAGS="$(HOSTLDFLAGS)" CFLAGS= python $(srctree)/lib/libfdt/setup.py
>>
>> to:
>>
>> tools/_libfdt.so: $(patsubst %.o,%.c,$(LIBFDT_OBJS)) tools/libfdt_wrap.c
>> 	LDFLAGS="$(HOSTLDFLAGS)" CFLAGS= ${PYTHON} $(srctree)/lib/libfdt/setup.py
>>
> 
> On my host
> 
> $ echo Python is \"$PYTHON\"
> Python is ""
> 

Sent a patch today, easier to test.

The thing is that PYTHON is set into the main Makefile as "python", and
this should not break your build. At least, I hope so...

> Wouldn't that break regular builds? Probably wouldn't since shebang
> kicks in, but is that really what we want?

The main Makefile already sets most tools to default if they are not
current set. This should ensure that the normal build works, but should
even allow to override it from command line - or adding EXTRA_OEMAKE in
recipe.

> 
> What I thought OE was doing is adding the native/x86_64 sysroots in your
> path at the beginning,

Right.

> which should already make sure that a regular
> "python" call executes OE python... 

"nativepython" should have a symbolic link to "python", but what I noted
is some mix between distro and SDK.

> But maybe there is more to it,
> especially since setup.py even compiles things...

Right. I have seen in some recipes that /usr/bin/env is replaced, for
example:

meta/recipes-support/createrepo/createrepo_0.4.11.bb:		sed -i -e
's|^#!.*/usr/bin/env python|#! /usr/bin/env nativepython|' $i

There are a few of recipes doing this.

> 
> Maybe we need to peek into distutils/setuptools class to understand how
> that works for regular Python modules:
> https://github.com/openembedded/openembedded/blob/master/classes/setuptools.bbclass
> https://github.com/openembedded/openembedded/blob/master/classes/distutils.bbclass

But there are for building python-modules, and we are just simply want
to build u-boot. Then, if I understand your concept, we need to build a
python module outside u-boot, and built before u-boot (ok, I am just
thinking about Yocto build..), as nativesdk-pythonsetuppy or whatever,
and this is just called when u-boot is built. But this makes things much
more complicated...

Stefano

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================


More information about the U-Boot mailing list