Thanks. It's true, my local build is a little bit outdated. I'm running
OpenBMC and it's slightly behind the latest upstream master. For now, it is
still compiling with Python 3.8.

However, there is the same underlying problem, even if I upgraded. It looks
like the version of Python on the build machine is wrongly leaking into the
build, and it's being used instead of the oe-core preferred version of
Python. Ideally, the locally-installed Python wouldn't influence the
outcome of the build, as oe-core has its own Python that it should prefer
to use instead, as it does for other packages. This is what "inherit
python3native" enables, right? Otherwise, the problem will happen again in
the future, whenever somebody wants to try out a new Python version on
their machine. The idea is to obtain some separation, for safety, and to
help ensure a clean reproducible build. It's a good practice, I think, to
minimize the opportunities for local variance to creep into the build.

As for "from fractions import gcd" becoming an error in 3.9, there was this
change: https://bugs.python.org/issue39350

It appears fractions.gcd was deprecated for a while. It was moved to
math.gcd a while ago, and deprecated, but not deleted entirely until Python
3.9. So, that's why it works in 3.8 (what my old oe-core build is running),
but not in 3.9 (what my local distribution is running).

Josh

Josh Lehan | Software Engineer | krel...@google.com | +1 650-733-8941



On Tue, Apr 13, 2021 at 1:08 PM Alexander Kanavin <alex.kana...@gmail.com>
wrote:

> Also note: oe-core master already has 3.9, so you need to find out why
> '3.8' shows up in install paths as well. Something doesn't compute here.
>
> Alex
>
> On Tue, 13 Apr 2021 at 22:07, Alexander Kanavin <alex.kana...@gmail.com>
> wrote:
>
>> I think you need to dig a little deeper. Why 'from fractions import gcd'
>> is a problem with host python3.9 but not a problem with native python 3.9?
>>
>> Alex
>>
>> On Tue, 13 Apr 2021 at 20:58, Josh Lehan via lists.openembedded.org
>> <krellan=google....@lists.openembedded.org> wrote:
>>
>>> Hi there, thanks. I'm not entirely sure what "python3native" does
>>> exactly, but this is my observation. The problem we are seeing is that,
>>> without "inherit python3native", the build machine's local Python version
>>> (whatever it happens to be) takes precedence over the Yocto-included Python
>>> version. In our case, the build machine is running Python 3.9, and
>>> evidently something changed between Python 3.8 and Python 3.9 to be
>>> incompatible with libxcb. Here's the error message:
>>>
>>> Failed to load the xcbgen Python package!
>>> Make sure that xcb/proto installed it on your Python path.
>>> If not, you will need to create a .pth file or define $PYTHONPATH
>>> to extend the path.
>>> Refer to the README file in xcb/proto for more info.
>>>
>>> Traceback (most recent call last):
>>>   File
>>> "/OpenBMC/build/tmp/work/x86_64-linux/libxcb-native/1.14-r0/build/src/../../libxcb-1.14/src/c_client.py",
>>> line 3338, in <module>
>>>     from xcbgen.state import Module
>>>   File
>>> "/OpenBMC/build/tmp/work/x86_64-linux/libxcb-native/1.14-r0/recipe-sysroot-native/usr/lib/pkgconfig/../../../usr/lib/python3.8/site-packages/xcbgen/state.py",
>>> line 7, in <module>
>>>     from xcbgen import matcher
>>>   File
>>> "/OpenBMC/build/tmp/work/x86_64-linux/libxcb-native/1.14-r0/recipe-sysroot-native/usr/lib/pkgconfig/../../../usr/lib/python3.8/site-packages/xcbgen/matcher.py",
>>> line 12, in <module>
>>>     from xcbgen.xtypes import *
>>>   File
>>> "/OpenBMC/build/tmp/work/x86_64-linux/libxcb-native/1.14-r0/recipe-sysroot-native/usr/lib/pkgconfig/../../../usr/lib/python3.8/site-packages/xcbgen/xtypes.py",
>>> line 5, in <module>
>>>     from xcbgen.align import Alignment, AlignmentLog
>>>   File
>>> "/OpenBMC/build/tmp/work/x86_64-linux/libxcb-native/1.14-r0/recipe-sysroot-native/usr/lib/pkgconfig/../../../usr/lib/python3.8/site-packages/xcbgen/align.py",
>>> line 5, in <module>
>>>     from fractions import gcd
>>> ImportError: cannot import name 'gcd' from 'fractions'
>>> (/usr/lib/python3.9/fractions.py)
>>>
>>> The above error text repeats for many of the files it tries to compile
>>> within libxcb.
>>>
>>> In general, it seems the safest approach is to standardize on a Python
>>> version that's known to work, without depending on whatever version of
>>> Python the developer has installed locally on their build machine (which
>>> can vary due to distribution, developer's preference, and so on).
>>>
>>> Josh
>>>
>>> Josh Lehan | Software Engineer | krel...@google.com | +1 650-733-8941
>>> <(650)%20733-8941>
>>>
>>>
>>>
>>> On Tue, Apr 13, 2021 at 2:45 AM Richard Purdie <
>>> richard.pur...@linuxfoundation.org> wrote:
>>>
>>>> On Tue, 2021-04-13 at 02:24 -0700, Josh Lehan via
>>>> lists.openembedded.org wrote:
>>>> > During compilation, the local Python environment leaks into
>>>> > the Bitbake build. Adding "inherit python3native" fixes this.
>>>> >
>>>> > Signed-off-by: Josh Lehan <krel...@google.com>
>>>> > ---
>>>> >  meta/recipes-graphics/xorg-lib/libxcb_1.14.bb | 1 +
>>>> >  1 file changed, 1 insertion(+)
>>>> >
>>>> > diff --git a/meta/recipes-graphics/xorg-lib/libxcb_1.14.bb
>>>> b/meta/recipes-graphics/xorg-lib/libxcb_1.14.bb
>>>> > index f0a223a19c..40c7b1cc3c 100644
>>>> > --- a/meta/recipes-graphics/xorg-lib/libxcb_1.14.bb
>>>> > +++ b/meta/recipes-graphics/xorg-lib/libxcb_1.14.bb
>>>> > @@ -24,6 +24,7 @@ PACKAGES_DYNAMIC = "^${PN}-.*"
>>>> >  FILES_${PN} = "${libdir}/libxcb.so.*"
>>>> >
>>>> >  inherit autotools pkgconfig features_check
>>>> > +inherit python3native
>>>> >
>>>>
>>>>
>>>> Could you provide a little more information about how this is breaking
>>>> things?
>>>>
>>>> Whilst python is used by the libxcb build, I believe it shouldn't
>>>> change the
>>>> output, it doesn't in our reproducibity tests.
>>>>
>>>> Adding a python-native dependency does slow the build down a bit so if
>>>> we
>>>> don't need it, it would be good to avoid it.
>>>>
>>>> Cheers,
>>>>
>>>> Richard
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>> 
>>>
>>>
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#150421): 
https://lists.openembedded.org/g/openembedded-core/message/150421
Mute This Topic: https://lists.openembedded.org/mt/82060718/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to