简体   繁体   English

将 numpy 的 arrayobject.h 包含到 bitbake 配方中 - 如何修复安装顺序?

[英]Include numpy's arrayobject.h into bitbake recipe - how to fix installation order?

My python package depends on ac extension that, in turn, makes use of numpy's arrayobject.h .我的 python 包依赖于 ac 扩展,而 ac 扩展又使用了 numpy 的arrayobject.h I built the image without the package and confirmed that this file exists: /usr/lib/python3.5/site-packages/numpy/core/include .我在没有包的情况下构建了映像并确认此文件存在: /usr/lib/python3.5/site-packages/numpy/core/include I also patched distutil's setup.py as follows:我还修补了 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',

Thus, the directory is hard coded but the fact that I have to catch the import exception indicates, that numpy is not available yet and hence the arrayobject.h is missing too.因此,该目录是硬编码的,但我必须捕获导入异常这一事实表明,numpy 尚不可用,因此也缺少arrayobject.h

So the question is: How do I ensure that numpy is there before bb works in this recipe?所以问题是:在 bb 在这个食谱中起作用之前,我如何确保 numpy 存在?

This is (the important part) the recipe.这是(重要的部分)食谱。 Note the DEPENDS (thought that was enough):注意DEPENDS (认为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 \
"

The simple answer is to specify the dependency on the native (target) numpy:简单的答案是指定对本机(目标)numpy 的依赖:

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

I have not yet confirmed that everything builds till the end but at least arrayobject.h seems to be available now.我还没有确认一切都构建到最后,但至少arrayobject.h现在似乎可用。

EDIT: Everything seems to work fine now.编辑:现在一切似乎都正常。 Adding python3-numpy-native also made the patch for numpy obsolete.添加python3-numpy-native也使 numpy 的补丁过时了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 致命错误:numpy/arrayobject.h:google colab 中没有这样的文件或目录#include“numpy/arrayobject.h” - fatal error: numpy/arrayobject.h: No such file or directory #include "numpy/arrayobject.h" in google colab 相当于使用#include <Numeric/arrayobject.h> 在Numpy - equivalent of using #include <Numeric/arrayobject.h> in Numpy 如何解决这个致命错误:numpy/arrayobject.h:没有这样的文件或目录? - How do I resolve this make fatal error: numpy/arrayobject.h: No such file or directory? Cython:“致命错误:numpy/arrayobject.h:没有这样的文件或目录” - Cython: "fatal error: numpy/arrayobject.h: No such file or directory" 如何使用C将数据从np.array获取到std :: vector <numpy/arrayobject.h> ? - How to get data from np.array to std::vector in c++ using <numpy/arrayobject.h>? 编译.pyx文件时缺少numpy / arrayobject.h - Missing numpy/arrayobject.h while compiling .pyx file cimport给出致命错误:找不到“ numpy / arrayobject.h”文件 - cimport gives fatal error: 'numpy/arrayobject.h' file not found 致命错误:numpy / arrayobject.h:没有这样的文件或目录 - fatal error: numpy/arrayobject.h: No such file or directory Cython:致命错误:未找到“numpy/arrayobject.h”文件,使用 numpy - Cython: fatal error: 'numpy/arrayobject.h' file not found, using numpy 包括<arrayobject.h>使用 cibuildwheels 在构建管道中编译 C python 扩展的标头路径 - Include <arrayobject.h> header path to compile C python extension in build pipeline using cibuildwheels
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM