将 numpy 的 arrayobject.h 包含到 bitbake 配方中 - 如何修复安装顺序?
Include numpy's arrayobject.h into bitbake recipe - how to fix installation order?
我的 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 \
"
简单的答案是指定对本机(目标)numpy 的依赖:
DEPENDS += " \
python3-numpy-native \
"
我还没有确认一切都会构建到最后,但至少 arrayobject.h
现在似乎可用。
编辑:现在似乎一切正常。添加 python3-numpy-native
也使 numpy 的补丁过时了。
我的 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 \
"
简单的答案是指定对本机(目标)numpy 的依赖:
DEPENDS += " \
python3-numpy-native \
"
我还没有确认一切都会构建到最后,但至少 arrayobject.h
现在似乎可用。
编辑:现在似乎一切正常。添加 python3-numpy-native
也使 numpy 的补丁过时了。