为不可用的python应用程序创建配方
自从
influxdb-python
和
pynmea2
不能作为标准的python食谱使用,我首先使用
devtool
.
步骤
-
使用
开发工具
添加
流入xdb python
devtool add influxdb-python https://github.com/influxdata/influxdb-python/archive/v5.2.0.tar.gz
-
使用
开发工具
添加
品名A2
devtool add pynmea2 https://github.com/Knio/pynmea2/archive/1.7.1.tar.gz
上述步骤创建文件夹
workspace
在你的
$BUILD_DIR
并为回购协议创建自动生成的配方。
-
编辑食谱
devtool edit-recipe influxdb-python
-
添加或检查
DEPEND_${PN}
和
RDEPENDS_${PN}
根据你的食谱。我把所有的
requirements.txt
对于
流入xdb python
到
订单号PN
即
RDEPEND_${PN} += "${PYTHON_PN}-modules ${PYTHON_PN}-requests ${PYTHON_PN}-dateutil ${PYTHON_PN}-pytz ${PYTHON_PN}-six"
注释
:我没有添加
pandas
或
numpy
因为它们与我的申请无关。
-
我添加了
DEPENDS_${PN} = "${PYTHON_PN}-modules
也。
注释
:对
品名A2
但是因为它没有
要求.txt
我添加了
RDEPENDS_${PN} = "${PYTHON_PN}-modules"
所以所有主要的事情都可以在目标上实现。
配方结构
GitHub Gist for Recipes
我跟着
meta-python
文件夹的结构,其中每个配方包括:
-
recipe.inc
-
recipe_version_number.bb
在
influxdb_python.inc
保留从中生成的所有内容
开发工具
即
# Recipe created by recipetool
# This is the basis of a recipe and may need further editing in order to be fully functional.
# (Feel free to remove these comments when editing.)
#
# WARNING: the following LICENSE and LIC_FILES_CHKSUM values are best guesses - it is
# your responsibility to verify that the values are complete and correct.
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=046523829184aac3703a4c60c0ae2104"
HOMEPAGE = "https://github.com/influxdb/influxdb-python"
SUMMARY = "InfluxDB client"
SRC_URI = "https://github.com/influxdata/influxdb-python/archive/v${PV}.tar.gz"
SRC_URI[md5sum] = "105d88695151e241523b31dd1375096e"
SRC_URI[sha256sum] = "620de85bcca5207b06ec1565884b6d10b4be01d579a78e08b1e922f453fdac05"
DEPENDS_${PN} = "${PYTHON_PN}-modules"
RDEPENDS_${PN} = "${PYTHON_PN}-modules ${PYTHON_PN}-requests ${PYTHON_PN}-dateutil ${PYTHON_PN}-pytz ${PYTHON_PN}-six"
在
influxdb_python_5.2.0.bb
我添加了以下行:
inherit setuptools3 pypi
require influxdb-python.inc
注释
:我添加了
setuptools3
因为我想在上面运行我的应用程序
python3.5
. 用于2.7号蟒蛇
setuptools
.
同样,我也为
pynmea2.inc
:
# Recipe created by recipetool
# This is the basis of a recipe and may need further editing in order to be fully functional.
# (Feel free to remove these comments when editing.)
#
# WARNING: the following LICENSE and LIC_FILES_CHKSUM values are best guesses - it is
# your responsibility to verify that the values are complete and correct.
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=bb5e173bc54080cb25079199959ba6b6"
HOMEPAGE = "https://github.com/Knio/pynmea2"
SUMMARY = "Python library for the NMEA 0183 protcol"
SRC_URI = "https://github.com/Knio/pynmea2/archive/${PV}.tar.gz"
SRC_URI[md5sum] = "a90baf61f4e676bef76099e4bd7c0581"
SRC_URI[sha256sum] = "8f8f68623bd2d5dab7f04a9c31813a3f4aa15467db0373cbce6b9b0ae44ca48e"
#DEPENDS_${PN} = "${PYTHON_PN}-datetime ${PYTHON_PN}-threading ${PYTHON_PN}-io"
DEPENDS_${PN} = "${PYTHON_PN}-modules"
# WARNING: the following rdepends are determined through basic analysis of the
# python sources, and might not be 100% accurate.
RDEPENDS_${PN} = "${PYTHON_PN}-modules"
为了
pynmea2_1.7.1.bb
:
inherit setuptools3 pypi
require pynmea2.inc
烘烤食谱
你可以用
bitbake -k influxdb-python
和
bitbake -k pynmea2
或与
devtool build influxdb-python
和
devtool build pynmea2
如果没有错误,则可以使用以下方法在目标上部署它:
devtool deploy-target influxdb-python user@machineIP:dest_folder
检查
你可以通过发射巨蟒壳来检查
# python3
>> import influxdb-python
>> import pyserial
如果导入没有抛出丢失的模块错误,那么它是成功的!!
最后步骤
注释
:如果使用
krogoth
或者降低你将不得不手动移动你的食谱到你的元层。
-
现在把这些食谱包括在你的
conf/local.conf
具有
IMAGE_INSTALL_append = " influxdb-python pynmea2"
和
bitbake -k your-image-name
自定义应用程序
尚未测试。
但我想我会简单地添加我的应用程序,如中所述
YoctoCookBook Repository for
hello-world
与我的
meta
层。
金块
-
${PYTHON_PN}-modules
真的是救世主。我尝试手动添加运行时deps,每次我在板上部署它时,总会缺少一些依赖项。但添加
modules
解决了实例中所有缺失的DEPS问题。
-
我不确定什么时候用
DEPENDS_${PN}
但我认为大多数Python应用程序都依赖于
python-modules
所以我加了它们。
-
不是Yocto专家
但这只是我最近两周的发现。在yocto中没有合适的Python示例。希望这能帮助别人。