问题描述
我正在编写一个自定义的 yocto recipe
,它应该从 .whl
文件安装一个 python 包.
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"
但它不能那样工作,它指出,缺少 setup.py
文件,并且在尝试编写运行 的自定义
它说,pip 是一个未知的命令.do_compile
任务时pip install
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.
当将 .whl
文件直接安装到目标系统上时,可以输入以下内容:
When installing .whl
files directly onto the target system one would type the following:
pip install <path-to-whl-file>
感谢您的帮助!
推荐答案
.whl 包只是一个带有 python 源代码的 .zip 文件,以及针对特定平台的预编译二进制文件.
.whl package is just a .zip file with python sources, and precompiled binaries for certain platform.
所以,你可以这样做:
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/
}
我还没有测试过,但它已经形成了合适的 nativesdk 包.注意 SRC_URI 的 downloadfilename= 参数 - 没有它,.whl 文件将不会被提取.
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.
这篇关于Yocto 食谱 python whl 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!