Yocto recipe python whl package

筅森魡賤 提交于 2020-06-23 11:54:47

问题


I am writing a custom yocto recipe that should install a python package from a .whl file.

I tried it using a recipe that contains:

inherit pypi setuptools
PYPI_SRC_URI="http://ci.tensorflow.org/view/Nightly/job/nightly-pi-zero/lastSuccessfulBuild/artifact/output-artifacts/tensorflow-1.5.0rc1-cp27-none-any.whl“

But it does not work that way, it states, that a setup.py file is missing and when trying to write a custom do_compile task that runs pip install <PATH-TO-WHL> it says, that pip is an unkown command.

When installing .whl files directly onto the target system one would type the following:

pip install <path-to-whl-file>

Thanks for your help!


回答1:


.whl package is just a .zip file with python sources, and precompiled binaries for certain platform.

So, you can do something like this:

COMPATIBLE_HOST = "i686.*-mingw.*"                                                                  

SRC_URI = "https://files.pythonhosted.org/packages/d8/9d/7a8cad803ef73f47134ae5c3804e20b54149ce62a7d1337204f3cf2d1fa1/MarkupSafe-1.1.1-cp35-cp35m-win32.whl;downloadfilename=MarkupSafe-1.1.1-cp35-cp35m-win32.zip;subdir=${BP}"

SRC_URI[md5sum] = "a948c70a1241389d7120db90d69079ca"                                                
SRC_URI[sha256sum] = "6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1"             

inherit nativesdk python3-dir                                                                       

LICENSE = "BSD-3-Clause"                                                                            

PV = "1.1.1"                                                                                        
PN = "nativesdk-python3-markupsafe"                                                                 

LIC_FILES_CHKSUM = "file:///${S}/MarkupSafe-1.1.1.dist-info/LICENSE.rst;md5=ffeffa59c90c9c4a033c7574f8f3fb75"

do_unpack[depends] += "unzip-native:do_populate_sysroot"                                            

PROVIDES += "nativesdk-python3-markupsafe"                                                          
DEPENDS += "nativesdk-python3"                                                                      

FILES_${PN} += "\                                                                                   
    ${libdir}/${PYTHON_DIR}/site-packages/* \                                                       
"                                                                                                   

do_install() {                                                                                      
    install -d ${D}${libdir}/${PYTHON_DIR}/site-packages/MarkupSafe-1.1.1.dist-info                 
    install -d ${D}${libdir}/${PYTHON_DIR}/site-packages/markupsafe                                 

    install -m 644 ${S}/markupsafe/* ${D}${libdir}/${PYTHON_DIR}/site-packages/markupsafe/          
    install -m 644 ${S}/MarkupSafe-1.1.1.dist-info/* ${D}${libdir}/${PYTHON_DIR}/site-packages/MarkupSafe-1.1.1.dist-info/
}

I haven't tested it, yet, but it already forms proper nativesdk package. Note downloadfilename= parameter to the SRC_URI - without it, .whl file would not be extracted.




回答2:


First check whether pip is installed in your system or not. If not install pip first. (How do I install pip on Windows? ). If already installed please provide full path to pip command or set path for pip and try.



来源:https://stackoverflow.com/questions/48660051/yocto-recipe-python-whl-package

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!