如何将Python包预安装到OpenWRT自定义镜像中?
我正在开发路由器,需要预安装 Python 模块 snmp_passpersist 。
原始源码是用python2编码的,所以我修改它以适应python3,并且需要预先安装到产品映像中。
我知道如何通过 pip 和原始源附带的 setup.py 将 Python 模块安装到正在运行的实时环境中,但现在我位于 OpenWRT 的 buildroot 环境中。
我通读了OpenWRT的自定义包概述,但它是针对C语言的和二进制可执行文件。
看起来应该使用Python模块/包而不是cp命令来完成更多步骤,例如将*.py文件编译为*.pyc,并制作一个包含大量包的egg文件 也许只需将egg文件
复制到目标lib文件夹中就可以了,但我担心PIP环境中不会有版本信息。
我想知道正确/正式的方式。
I'm developing a router and need a Python module snmp_passpersist to be pre-installed.
The original source is coded in python2, so I modified it as to adapt to python3, and need to pre-install into the product image.
I know how to install a Python module onto a running live environment by means of pip and a setup.py that come with original source, but now I'm in the buildroot env of OpenWRT.
I read through the customizing package overview of OpenWRT, but it is for C language and binary executables.
It looks like that some more steps should be done with a Python module/package instead of a cp
command, e.g. compiling *.py file into *.pyc, and making a egg file with a lot of package info, etc.
Maybe it works to copy simply the egg file into the target lib folder, but I worry about there will be no version information in the PIP environment.
I want to know the correct/formal way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该遵循 Openwrt 的官方 python 包
添加 python 的 include makefile
有一些用于 makefile 的内置命令,例如:
$(eval $(call Py3Package,python3-curl))
构建了 python 包,您可以在自定义图像中获取它
例如: https://github.com/openwrt/packages/blob/openwrt-21.02/lang/python/python-curl/Makefile
You should follow an official python package from Openwrt
Add the include makefile for python
There is some built-in command for the makefile, ex:
$(eval $(call Py3Package,python3-curl))
Pre-built the python package and you can get this in a custom image
Ex: https://github.com/openwrt/packages/blob/openwrt-21.02/lang/python/python-curl/Makefile