为不可用的 python 应用程序创建食谱
Since influxdb-python
and pynmea2
不能作为标准 python 食谱使用,我首先使用它们为它们创建食谱devtool
.
Steps
-
use devtool
添加influxdb-python
devtool add influxdb-python https://github.com/influxdata/influxdb-python/archive/v5.2.0.tar.gz
-
use 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}
and RDEPENDS_${PN}
相应地根据你的食谱。我添加了所有requirements.txt
for influxdb-python
to RDEPENDS_${PN}
viz.
RDEPEND_${PN} += "${PYTHON_PN}-modules ${PYTHON_PN}-requests ${PYTHON_PN}-dateutil ${PYTHON_PN}-pytz ${PYTHON_PN}-six"
NOTE: 我还没有添加pandas
or numpy
因为它们与我的申请无关。
-
I added DEPENDS_${PN} = "${PYTHON_PN}-modules
also.
NOTE: 执行同样的操作pynmea2
但由于它没有任何requirements.txt
我添加了RDEPENDS_${PN} = "${PYTHON_PN}-modules"
所以所有主要的东西都可以在目标上使用。
配方结构
食谱的 GitHub 要点 https://gist.github.com/shantanoo-desai/fc00836d399f8592a30efe1ec9c56213
我跟着meta-python
文件夹的结构,其中每个食谱包含:
recipe.inc
recipe_version_number.bb
In the influxdb_python.inc
保留所有生成的东西devtool
viz.
# 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"
In the influxdb_python_5.2.0.bb
我添加了以下几行:
inherit setuptools3 pypi
require influxdb-python.inc
NOTE: 我补充了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"
For pynmea2_1.7.1.bb
:
inherit setuptools3 pypi
require pynmea2.inc
烘焙食谱
你可以用以下方法测试它们bitbake -k influxdb-python
and bitbake -k pynmea2
或与devtool build influxdb-python
and devtool build pynmea2
如果没有错误,那么您可以使用以下命令将其部署到目标上:
devtool deploy-target influxdb-python user@machineIP:dest_folder
Checks
您可以通过启动 python shell 来检查
# python3
>> import influxdb-python
>> import pyserial
如果导入抛出 no Missing Modules 错误,那么它就成功了!
最后步骤
NOTE: 如果您正在使用krogoth
或降低您将必须手动将您的食谱移动到您的元层
- 现在将这些食谱包含在您的
conf/local.conf
with IMAGE_INSTALL_append = " influxdb-python pynmea2"
and bitbake -k your-image-name
定制应用程序
尚未测试。
但我想我会简单地添加我的应用程序,如中提到的YoctoCookBook 存储库hello-world https://github.com/yoctocookbook/meta-custom/tree/master/recipes-python/python-helloworld和我的meta
layer.
NUGGETS
-
${PYTHON_PN}-modules
真的是救世主。我尝试手动添加运行时依赖项,每次将其部署到板上时,总会缺少一些依赖项。但添加modules
解决了实例中所有缺失的 deps 问题。
-
我不确定什么时候使用DEPENDS_${PN}
但我假设大多数 python 应用程序都依赖于基本的python-modules
因此我添加了它们。
-
不是 YOCTO 专家但这只是我过去两周的发现。 Yocto 中缺乏适当的 Python 示例。希望这对某人有帮助。