<div dir="ltr">Python functions in classes are executed by the Python that is executing bitbake, which doesn't have access to the modules in the native sysroot (and won't, as any compiled modules in there are linked against the native python, not the host python).<div><br></div><div>You can solve this by either mandating python-cryptography on the host, or writing a standalone script that is executed using nativepython (which is the python built by python-native).</div><div><br></div><div>Ross</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 30 November 2017 at 00:09, <span dir="ltr"><<a href="mailto:Aaron_Wright@selinc.com" target="_blank">Aaron_Wright@selinc.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><font size="2" face="sans-serif">I have a python function that I've added
to PACKAGEFUNCS in a bbclass, and I want to use python-cryptography in
that function. However, sys.path doesn't seem setup to allow this import.
I'm curious to know the best known method for using python modules that
are outside of  <LAYER>/lib directory. Should I just append
STAGING_LIBDIR_NATIVE to sys.path?</font>
<br>
<br><font size="2" face="sans-serif">python do_stuff() {</font>
<br><font size="2" face="sans-serif">Â Â import cryptography #
<-- this fails</font>
<br>
<br><font size="2" face="sans-serif">Â Â # Other stuff...</font>
<br><font size="2" face="sans-serif">}</font>
<br>
<br><font size="2" face="sans-serif">python () {</font>
<br><font size="2" face="sans-serif">Â Â if (not bb.data.inherits_class("<wbr>native",
d) and</font>
<br><font size="2" face="sans-serif">Â Â Â Â not bb.data.inherits_class("cross"<wbr>,
d)):</font>
<br>
<br><font size="2" face="sans-serif">Â Â Â Â d.appendVar("PACKAGEFUNCS",
" do_stuff")</font>
<br><font size="2" face="sans-serif">Â Â Â Â d.appendVarFlag(</font>
<br><font size="2" face="sans-serif">Â Â Â Â Â Â
"do_package", </font>
<br><font size="2" face="sans-serif">Â Â Â Â Â Â
"depends", </font>
<br><font size="2" face="sans-serif">Â Â Â Â Â Â
" python-cryptography-native:do_<wbr>populate_sysroot")</font>
<br><font size="2" face="sans-serif">}</font><br>--<br>
______________________________<wbr>_________________<br>
yocto mailing list<br>
<a href="mailto:yocto@yoctoproject.org">yocto@yoctoproject.org</a><br>
<a href="https://lists.yoctoproject.org/listinfo/yocto" rel="noreferrer" target="_blank">https://lists.yoctoproject.<wbr>org/listinfo/yocto</a><br>
<br></blockquote></div><br></div>