설치시 numpy의 arrayobject.h
은 …/site-packages/numpy/core/include/numpy/arrayobject.h
에 있습니다.distutils가 정확한 위치에 numpy 헤더 파일을 찾도록하십시오.
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
ext_modules = [Extension("hello", ["hello.pyx"])]
setup(
name = 'Hello world app',
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules
)
내가 python setup.py build_ext --inplace
빌드하려고, 사이 썬이해야 할 시도합니다
cimport numpy as np
def say_hello_to(name):
print("Hello %s!" % name)
나는 또한합니다 (Cython user guide에서 복사) setup.py
는 다음의 distutils이 : 나는 NumPy와 사용 사소한 사이 썬 스크립트를 작성 다음과 같습니다 :
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd \
-fno-common -dynamic -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DMACOSX \
-I/usr/include/ffi -DENABLE_DTRACE -arch i386 -arch ppc -pipe \
-I/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 \
-c hello.c -o build/temp.macosx-10.5-i386-2.5/hello.o
예 : arrayobject.h
을 찾지 못했습니다. 어떻게 distutils가 numpy include 파일의 정확한 위치를 사용하게 할 수 있습니까? (사용자가 $ CFLAGS를 정의하지 않고)?
ipython 노트북에서'%% cython' 마법을 사용할 때도 같은 문제가 있습니다. 쉬운 수정이 있는지 궁금합니다. – pbreach
'-numpy'가 아닌 예를 들어 본 사람은 누구입니까? 'numpy.get_include'의 정의는 [여기] (https://github.com/numpy/numpy/blob/56678fe56dce97871bb49febf0b2c0206541eada/numpy/lib/utils.py#L18)입니다. –
'Extension' 호출 안에'include_dirs' 행을 이동 시켜서 cython 0.24와 함께 작동 시키도록했습니다. –