我正在处理从 github (https://github.com/braisCB/WMM) 获取的代码,该代码使用 cython 在 python 上运行 cpp 代码。例如,一段代码是
import numpy
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
import sys
# from Cython.Build import cythonize
ext_modules = [
Extension(
name="wmm2D_cython",
sources=["wrappers/wmm2D_cython.pyx", "wrappers/wmm2D_c.cpp"],
compiler_directives={'language_level' : sys.version_info[0]},
include_dirs = [numpy.get_include()],
extra_compile_args=['-std=c++14'],
language="c++",
),
Extension(
name="wmm2D_cartesian_cython",
sources=["wrappers/wmm2D_cartesian_cython.pyx", "wrappers/wmm2D_cartesian_c.cpp"],
compiler_directives={'language_level' : sys.version_info[0]},
include_dirs = [numpy.get_include()],
extra_compile_args=['-std=c++14'],
language="c++",
)]
setup(
name = 'mm',
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules
)
在我写的shell中
python setup.py build_ext --inplace
运行它。但是我有以下错误。用英语写成:
C:\Users\raydu\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\extension.py:134: UserWarning: Unknown Extension options: 'compiler_directives'
warnings.warn(msg)
cl : Command line warning D9002 : option '-std=c++14' unknown ignored
C:\Users\raydu\Documents\Deformable models\WMM\src\2D\../TYPES/utils.h(31): error C2131: expression did not evaluate to a constant
C:\Users\raydu\Documents\Deformable models\WMM\src\2D\../TYPES/utils.h(31): note: see usage 'gamma' of
C:\Users\raydu\Documents\Deformable models\WMM\src\2D\../TYPES/utils.h(31): error C2131: expression did not evaluate to a constant
你有解决这些问题的想法吗? (特别是关于 compiler_directives 和 std=c++14)