python - 构建 python 包

标签 python openembedded bitbake

我正在对几个 python 库进行 bitbaking,并在添加第二个库时收到此警告:

WARNING: The recipe is trying to install files into a shared area when those files already exist. Those files are:
   /home/ilya/beaglebone-dany/build/tmp/sysroots/beaglebone/usr/lib/python2.7/site-packages/site.py
   /home/ilya/beaglebone-dany/build/tmp/sysroots/beaglebone/usr/lib/python2.7/site-packages/site.pyo

这两个库都使用inherit distutils。所以就 bitbake 而言这是可以的,但是当我尝试通过 opkg 安装第二个包时,我收到了这个错误:

# opkg install http://yocto.local:8080/python-requests_1.2.0-r0_armv7a-vfp-neon.ipk
Downloading http://yocto.local:8080/python-requests_1.2.0-r0_armv7a-vfp-neon.ipk.
Installing python-requests (1.2.0-r0) to root...
Configuring python-requests.

# opkg install http://yocto.local:8000/python-mylib_0.0.1-r0_armv7a-vfp-neon.ipk
Downloading http://yocto.local:8080/python-mylib_0.0.1-r0_armv7a-vfp-neon.ipk.
Installing python-mylib (0.0.1-r0) to root...
Collected errors:
 * check_data_file_clashes: Package mylib-python wants to install file /usr/lib/python2.7/site-packages/site.py
        But that file is already provided by package  * python-requests
 * check_data_file_clashes: Package mylib-python wants to install file /usr/lib/python2.7/site-packages/site.pyo
        But that file is already provided by package  * python-requests
 * opkg_install_cmd: Cannot install package mylib-python.

两个食谱看起来都是这样的:

DESCRIPTION = "Requests: HTTP for Humans"
HOMEPAGE = "http://docs.python-requests.org/en/latest/"
SECTION = "devel/python"
LICENSE = "Apache-2.0"

DEPENDS = "python"
RDEPENDS_${PN} = "python-core"
PR = "r0"

SRC_URI = "git://github.com/kennethreitz/requests;protocol=git"

S = "${WORKDIR}/git/"

inherit distutils

#NOTE: I'm not 100% sure whether I still need to export these?
export BUILD_SYS
export HOST_SYS
export STAGING_INCDIR
export STAGING_LIBDIR

BBCLASSEXTEND = "native"

我从 pycurl recipe 复制了这个,其中也有我删除的这些行:

do_install_append() {
    rm -rf ${D}${datadir}/share
}

最佳答案

要摆脱冲突的 /usr/lib/python2.7/site-packages/site.py,需要通过这样做来避免传送此文件:

do_install_append() {
  rm -f ${D}${libdir}/python*/site-packages/site.py*
}

原始版本的食谱还有另一个问题,它安装的文件只包含 .egg 目录。我无法导入生成的包。

事实证明,使用 inherit setuptools 而不是 inherit distutils 是可行的。

我不是 Python 专家,但所有 setuptools class就是这样:

inherit distutils

DEPENDS += "python-setuptools-native"

DISTUTILS_INSTALL_ARGS = "--root=${D} \
    --single-version-externally-managed \
    --prefix=${prefix} \
    --install-lib=${PYTHON_SITEPACKAGES_DIR} \
    --install-data=${datadir}"

事实证明,某些模块(例如 PyBBIO )不识别 --single-version-externally-managed,因此您必须使用 inherit distutils你确实得到了一个工作包。

下面是 python-requests 包的完整配方,如果您打算使用它,它应该很快就会在上游可用。

DESCRIPTION = "Requests: HTTP for Humans"
HOMEPAGE = "http://docs.python-requests.org/en/latest/"
SECTION = "devel/python"
LICENSE = "Apache-2.0"

#DEPENDS = "python-core"
RDEPENDS_${PN} = "python"
PR = "r0"

SRC_URI = "git://github.com/kennethreitz/requests;protocol=git"

S = "${WORKDIR}/git/"

inherit setuptools

# need to export these variables for python-config to work
export BUILD_SYS
export HOST_SYS
export STAGING_INCDIR
export STAGING_LIBDIR

BBCLASSEXTEND = "native"

do_install_append() {
  rm -f ${D}${libdir}/python*/site-packages/site.py*
}

关于python - 构建 python 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16090550/

相关文章:

linux - init-ifupdown 的 Yocto Poky-Pyro bbappend 文件没有替换/etc/network/interfaces

python - 如何在Elasticsearch查询中添加max_result_window

python - 将类型为 "object"的数据帧列转换为 set()

c++ - 基于cmake的Bitbake配方:缺少sysroot?

c - 为 ARM 编译 Kernel-aodv 时出错

qt - Yocto:如何删除图层而不重建所有图层

python - 使用包含多种类型的 numpy 数组创建 Pandas DataFrame

python - 将多维数组的每个子数组的最后一项放入列表

linux - 我怎样才能覆盖另一个 .bbappend

datastore - bitbake: d.getVar ("X", True) True 是什么意思?