【发布时间】:2018-10-10 22:32:23
【问题描述】:
我正在编写一个小型 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 " \
^
虽然这只是一个警告,但如果可以的话,我仍然想避免这种情况。关于如何做到这一点的任何想法?
【问题讨论】:
-
您是否尝试过警告中所说的内容?
-
@user2357112 我在
my_c_file.c中尝试了#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION,但我认为没有帮助
标签: python c python-3.x numpy