Bug 13208

Summary: Python2.7 check in oe-buildenv-internal is erroring
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Jaewon Lee <jaewon>
Component: deploymentAssignee: Richard Purdie <richard.purdie>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: Medium+ CC: akuster, randy.macleod
Version: 2.6.1   
Target Milestone: 2.8 M1   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know

Description Jaewon Lee 2019-02-28 00:49:45 UTC
python3_3.5.6 recipe in thud has the python3.5 wrapper set PYTHONHOME in this line:
create_wrapper ${D}${bindir}/python${PYTHON_MAJMIN} PYTHONHOME='${prefix}' TERMINFO_DIRS='${sysconfdir}/terminfo:/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo' PYTHONNOUSERSITE='1'

This causes an error during the python2 check in oe-buildenv-internal as the system will look in buildtools/sysroots/ for the python2 libraries when only python3 libraries are there.

steps to reproduce: build an esdk using thud branch on upstream, extract and use command devtool command.

error that is seen is: 
ImportError: No module named site
OpenEmbedded requires 'python' to be python v2 (>= 2.7.3), not python v3.
Please upgrade your python v2
Comment 1 Armin Kuster 2019-03-07 16:13:40 UTC
with backport
Comment 2 Richard Purdie 2019-03-07 16:23:22 UTC
I think we need to create our own equivalent variable to PYTHONHOME (OEPYTHON3HOME) which we can set in the wrapper which would then not affect any python2. We'd need to patch this into python and it wouldn't be an upstreamable patch but would solve this problem and yet still allow relocation (which is why we need it).
Comment 3 Jaewon Lee 2019-03-07 20:18:48 UTC
I agree that would be ideal, but how is this breaking relocation? just so I know how this variable is being used during relocation
Comment 4 Armin Kuster 2019-03-09 20:34:09 UTC
merge of patch on hold for now.
Comment 5 Richard Purdie 2019-04-04 15:36:37 UTC
In Python/pythonrun.c there is:

char *
Py_GetPythonHome(void)
{
    char *home = default_home;
    if (home == NULL && !Py_IgnoreEnvironmentFlag)
        home = Py_GETENV("PYTHONHOME");
    return home;
}

We probably need to patch this to first check OEPYTHON3HOME and then fall back to checking PYTHONHOME, then we use the OEPYTHON3HOME to set the override in our wrapper.