如何将Python包预安装到OpenWRT自定义镜像中?

发布于 2025-01-10 07:04:17 字数 576 浏览 1 评论 0原文

我正在开发路由器,需要预安装 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

無心 2025-01-17 07:04:17

您应该遵循 Openwrt 的官方 python 包

添加 python 的 include makefile

include ../pypi.mk
include $(INCLUDE_DIR)/package.mk
include ../python3-package.mk

有一些用于 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

include ../pypi.mk
include $(INCLUDE_DIR)/package.mk
include ../python3-package.mk

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文