[yocto] BKM for Importing Python Modules

Aaron_Wright at selinc.com Aaron_Wright at selinc.com
Wed Nov 29 16:09:04 PST 2017


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?

python do_stuff() {
    import cryptography # <-- this fails

    # Other stuff...
}

python () {
    if (not bb.data.inherits_class("native", d) and
        not bb.data.inherits_class("cross", d)):

        d.appendVar("PACKAGEFUNCS", " do_stuff")
        d.appendVarFlag(
            "do_package", 
            "depends", 
            " python-cryptography-native:do_populate_sysroot")
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20171129/31e5c2c9/attachment.html>


More information about the yocto mailing list