我有一个简单的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
以上内容是通过以下方法生成的:
pip3 install pynmea2 pyserial influxdb
在OpenEmbedded Layers Index
中,我已经找到了Python3的pyserial
包。这意味着我可能需要做pip3 install pynmea2 influxdb
。
如何在编写我的应用程序的配方时考虑到上面提到的pip依赖关系?
对于编写python应用程序的配方,我没有找到任何教程。(相反,Node
应用程序确实对yocto wiki页面有一些指导。
在检查meta-python
层中的一些菜谱时,我发现了一些.inc
文件,但不确定如何处理。
发布于 2018-10-04 01:16:58
为不可用的python应用程序创建累赘
由于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
,并为repos创建自动生成的菜谱。
devtool edit-recipe influxdb-python
DEPEND_${PN}
和RDEPENDS_${PN}
。我将所有requirements.txt
for influxdb-python
添加到RDEPENDS_${PN}
viz中。
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"
在influxdb_python_5.2.0.bb
中,我添加了以下几行:
inherit setuptools3 pypi
require influxdb-python.inc
注意到:我添加了
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"
对于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
检查
您可以通过触发python外壳来进行检查。
# python3
>> import influxdb-python
>> import pyserial
如果导入是抛出没有丢失模块错误,那么它就是成功的!!
最后步骤
devtool undeploy-target recipe_name [address of target]
devtool finish recipe_name ../meta-custom
注意:如果您正在使用
krogoth
或更低的值,则必须手动将菜谱移动到元层。
IMAGE_INSTALL_append = " influxdb-python pynmea2"
和bitbake -k your-image-name
一起包含在您的IMAGE_INSTALL_append = " influxdb-python pynmea2"
和bitbake -k your-image-name
中自定义应用
还没测试过。
但我想我会简单地添加我的应用程序,就像在hello-world
中提到的那样,我的meta
层。
鸡块
${PYTHON_PN}-modules
是真正的救世主。我尝试手动添加运行时dep,每次我在板上部署它时,总是缺少一些依赖项。但是添加modules
解决了一个实例中所有缺失的deps问题。DEPENDS_${PN}
,但我假设大多数python应用程序依赖于基本的python-modules
,因此我添加了它们。https://stackoverflow.com/questions/50436413
复制相似问题