构建python包

时间:2013-04-18 18:31:35

标签: python openembedded bitbake

我正在点击几个python库并在添加第二个时发出此警告:

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
}

1 个答案:

答案 0 :(得分:5)

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

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

原始版本的配方出现了另一个问题,它安装的文件只包含.egg目录。我无法import生成的包。

事实证明,使用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*
}
相关问题