Sha*_*sai 6 embedded-linux python-3.x yocto
我有一个简单的python应用程序,它可以:
包装要求:
certifi==2018.4.16
chardet==3.0.4
idna==2.6
influxdb==5.0.0
pynmea2==1.12.0
pyserial==3.4
python-dateutil==2.7.3
pytz==2018.4
requests==2.18.4
six==1.11.0
urllib3==1.22
Run Code Online (Sandbox Code Playgroud)
上面是通过使用以下命令生成的:
pip3 install pynmea2 pyserial influxdb
在OpenEmbedded Layers Index
我已经找到pyserial
的Python3包中。这暗示着我可能需要做的事情pip3 install pynmea2 influxdb
。
在考虑所有上述pip依赖关系的情况下,如何继续编写应用程序的配方?
我没有找到有关编写python应用程序食谱的任何教程。(相反,Node
应用程序确实在yocto的Wiki页面上有一些指导。
在检查meta-python
层中的一些配方后,我发现了一些.inc
文件,但不确定如何处理
由于influxdb-python
和pynmea2
不能作为标准python食谱使用,因此我首先使用为其创建了食谱devtool
。
用于devtool
添加influxdb-python
devtool add influxdb-python https://github.com/influxdata/influxdb-python/archive/v5.2.0.tar.gz
用于devtool
添加pynmea2
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
的influxdb-python
对RDEPENDS_${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
也加了。
注意:执行相同的操作,
pynmea2
但是由于没有requirements.txt
添加任何内容,RDEPENDS_${PN} = "${PYTHON_PN}-modules"
因此目标上所有主要功能均可用。
我遵循meta-python
文件夹的结构,其中每个配方均由以下组成:
recipe.inc
recipe_version_number.bb
在influxdb_python.inc
保持从产生的一切东西,devtool
即
# 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"
Run Code Online (Sandbox Code Playgroud)
在中,influxdb_python_5.2.0.bb
我添加了以下几行:
inherit setuptools3 pypi
require influxdb-python.inc
Run Code Online (Sandbox Code Playgroud)
注意:添加是
setuptools3
因为我希望运行我的应用程序python3.5
。对于python2.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"
Run Code Online (Sandbox Code Playgroud)
对于pynmea2_1.7.1.bb
:
inherit setuptools3 pypi
require pynmea2.inc
Run Code Online (Sandbox Code Playgroud)
您可以使用bitbake -k influxdb-python
和bitbake -k pynmea2
或使用
devtool build influxdb-python
和测试它们
devtool build pynmea2
如果没有错误,则可以使用以下命令将其部署在目标上:
devtool deploy-target influxdb-python user@machineIP:dest_folder
Run Code Online (Sandbox Code Playgroud)
您可以通过触发python shell进行检查
# python3
>> import influxdb-python
>> import pyserial
Run Code Online (Sandbox Code Playgroud)
如果导入没有抛出缺少的模块错误,则说明成功!
您可以取消部署模块: devtool undeploy-target recipe_name [address of target]
将食谱发送到您的自定义元层 devtool finish recipe_name ../meta-custom
注意:如果您使用
krogoth
或降低您的配方,则必须手动将配方移至元层
conf/local.conf
与IMAGE_INSTALL_append = " influxdb-python pynmea2"
和bitbake -k your-image-name
尚未测试。
但是我想我会像在YoctoCookBook信息库中hello-world
提到的那样,将我的应用程序简单地添加到我的meta
图层中。
${PYTHON_PN}-modules
真的是救星。我尝试手动添加运行时部门,每次将其部署在板上时,总是会丢失一些依赖项。但是modules
在实例中添加已解决的所有缺少的dep问题。
我不确定何时使用,DEPENDS_${PN}
但我认为大多数python应用程序都依赖于基本应用程序,python-modules
因此我添加了它们。
这不是YOCTO专家,但这只是我最近2周的发现。Yocto中缺少适当的Python示例。希望这对某人有帮助。