Bug 8671

Summary: python build tries to import target modules and fails
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Awais <awais_belal>
Component: devtools / tool chainAssignee: Alejandro Hernandez <alejandro.hernandez>
Status: VERIFIED FIXED QA Contact: Cristina Agurida <cristina-danielax.agurida>
Severity: normal    
Priority: Medium+ CC: bogdanx.a.voiculescu, meta.mr.watcher, meta.watcher
Version: unspecified   
Target Milestone: 2.0.1   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Awais 2015-11-10 08:50:25 UTC
The issue is seen on x86 type of machines passing -march=bdverX (X=3,4 etc) flags but in general this should cause a problem when freshly built target modules are tried for an import during the cross build process.
Aiding the PYTHONPATH (in PYTHON_FOR_BUILD) with CROSSPYTHONPATH which contains the native modules path resolves the issue.
The issue can be reproduced on qemux86-64 builds by adding
TUNE_CCARGS_pn-python=" -m64 -march=bdver4 -msse3 -mfpmath=sse"
to local.conf. Although the failure is shown in do_install this actually is a compilation issue and can be confirmed by running do_compile a second time.
An RFC patch (http://patchwork.openembedded.org/patch/106561/) was sent to OE-Core mailing list and then resent with RFC removed (http://patchwork.openembedded.org/patch/106627/) which I believe takes care of the issue correctly but both went un-answered.
Comment 1 Awais 2015-11-10 08:58:09 UTC
Just to add that this can be confirmed through dev-shell once the build fails.
bitbake -c devshell python
edit the (srcdir)/setup.py script to first import sys and the print sys.path which is the path python is going to use for imports. The path does not contain references to sysroot (native) python modules location and then the interpreter tries to import from target's build dir.
Comment 2 Alejandro Hernandez 2015-11-19 19:39:03 UTC
I can confirm this isn't working, I do find it interesting this is necessary, since when executing python-native from a devshell and printing sys.path, one can see that it DOES include CROSSPYTHONPATH, but when it is executed via the makefile to install sharedmods, it doesn't, causing the failure, so I am just wondering if there might be a better fix, in the meantime, the patch seems to work.
Comment 4 Cristina Agurida 2016-02-15 11:32:46 UTC
Verified on master: 36b43b233c841b3c09fc17e04686b4b758780963