将numpy的arrayobject.h包含在Bitbake配方中-如何确定安装顺序?

问题描述 投票:0回答:1

我的python包依赖于c扩展名,该扩展名又使用了numpy的arrayobject.h。我构建了不带软件包的映像,并确认此文件存在:/usr/lib/python3.5/site-packages/numpy/core/include。我还修补了distutil的setup.py,如下所示:

diff --git a/setup.py b/setup.py
index 99dcc2a..ecb2675 100644
--- a/setup.py
+++ b/setup.py
@@ -11,8 +11,12 @@ building_wheel = bool(sys.argv[1].strip() == 'bdist_wheel')


 def get_numpy_include():
-    import numpy
-    return numpy.get_include()
+    try:
+        import numpy
+        return numpy.get_include()
+
+    except ImportError:
+        return '/usr/lib/python3.5/site-packages/numpy/core/include'


 def get_build_include(lib_name):
@@ -106,6 +110,7 @@ setup(
             name='ringnes.ringbuffer_base',
             sources=sources,
             libraries=clibraries,
+            include_dirs=[get_numpy_include()],
             define_macros=[(sensor_type, 0)]),
         Extension(
             name='ringnes.mseed_ext',

因此,该目录是硬编码的,但是我必须捕获导入异常的事实表明,numpy尚不可用,因此arrayobject.h也丢失了。

所以问题是:在bb在此食谱中起作用之前,如何确保存在numpy?

这是(重要的部分)食谱。注意DEPENDS(这已经足够了):

inherit setuptools3

# Experimenting with CFLAGS
# TARGET_CFLAGS_append = " -I/usr/lib/python3.5/site-packages/numpy/core/include"

LAYERDEPENDS += " \ 
    meta-openembedded \
    meta-python \
"

DEPENDS += " \ 
    python3-numpy \
"

RDEPENDS_${PN} += " \
    python3-numpy \
    python3-scipy \
    python3-cryptography \
    python3-smbus \
    python3-psutil \
    python3-hbmqtt \
"

RRECOMMENDS_${PN} += " \
    python3-wifi \
"
python numpy yocto bitbake
1个回答
0
投票

简单的答案是指定对本机(目标)numpy的依赖项:

DEPENDS += " \ 
    python3-numpy-native \
"

我尚未确认一切都将构建到最后,但至少arrayobject.h现在似乎可以使用。

编辑:现在一切似乎都正常。添加python3-numpy-native也使numpy的补丁已过时。

© www.soinside.com 2019 - 2024. All rights reserved.