我正在编写一个小型的C函数,旨在加速我在Python中拥有的一个大型应用程序中的一些计算密集型部分。自然而然地,我编写了一个包装器,确保我的C代码可以与我的Python numpy数组无缝通信。一切都很好,我正在使用以下setup.py
from distutils.core import setup, Extension
import numpy
module1 = Extension('my_wrapper',
sources = ['my_c_file.c'],
include_dirs=[numpy.get_include()],
extra_compile_args = ['-fopenmp'],
extra_link_args = ['-lgomp'])
setup(name = 'my_wrapper',
version = '1.0',
description = 'Some description here',
ext_modules = [module1])
使用命令 python3 setup.py install
编译时,一切都正常运行,并且代码表现符合预期,但我收到了以下警告:
warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
#warning "Using deprecated NumPy API, disable it by " \
^
虽然这只是一个警告,但我仍然希望尽可能避免。有什么好的想法吗?
my_c_file.c
中尝试了#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
,但我不认为这有帮助。 - senior_mle