You need include_dirs = numpy_include_dirs in your Extension(...) declaration in module_list.py.
- Robert On Jul 15, 2009, at 11:23 AM, Ethan Van Andel wrote: > > I want to include some of my cython code as a sage module. I followed > the directions for adding the .pyx file to the sage library at > http://www.sagemath.org/doc/developer/coding_in_other.html. > However, when I run "sage -b" I get this: > ---------------------------------------------------------- > sage: Building and installing modified Sage library files. > > > Installing c_lib > scons: `install' is up to date. > Updating Cython code.... > Building modified file sage/my_stuff/interpolators.pyx. > python `which cython` --embed-positions --incref-local-binop -I/home/ > evlutte/opt/sage-3.2.3/devel/sage-main -o sage/my_stuff/ > interpolators.c sage/my_stuff/interpolators.pyx > sage/my_stuff/interpolators.pyx --> /home/evlutte/opt/sage-3.2.3/ > local//lib/python/site-packages//sage/my_stuff/interpolators.pyx > Time to execute 1 commands: 1.00808811188 seconds > Finished compiling Cython code (time = 1.51264286041 seconds) > running install > running build > running build_py > package init file 'sage/my_stuff/__init__.py' not found (or not a > regular file) > package init file 'sage/my_stuff/__init__.py' not found (or not a > regular file) > running build_ext > building 'sage.my_stuff.interpolators' extension > gcc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict- > prototypes -fPIC -I/home/evlutte/opt/sage-3.2.3/local//include -I/ > home/ > evlutte/opt/sage-3.2.3/local//include/csage -I/home/evlutte/opt/ > sage-3.2.3/devel//sage/sage/ext -I/home/evlutte/opt/sage-3.2.3/local/ > include/python2.6 -c sage/my_stuff/interpolators.c -o build/ > temp.linux- > i686-2.6/sage/my_stuff/interpolators.o -w > sage/my_stuff/interpolators.c:139:31: error: numpy/arrayobject.h: No > such file or directory > sage/my_stuff/inte ... > > and lots more error stuff > > Below are the contents of "interpolators.pyx" Can anyone tell me what > I'm doing wrong? > > > include "../ext/interrupt.pxi" > include '../ext/cdefs.pxi' > include '../ext/stdsage.pxi' > > import numpy as np > cimport numpy as np > > from math import pi > cdef double TWOPI = 2*pi > > class PSpline(): > def __init__(self,pts,shift = (0,0), int reverse = 0): > self.pts = pts > self.shift = shift > self.reverse = reverse > cdef int N = len(pts) > self.N = N > > def value(self,float t0): > if self.reverse == 1: > t0 = TWOPI-t0 > while t0 >= TWOPI: > t0 -= TWOPI > t1 = (t0 * self.N/(TWOPI)) > pt1 = self.pts[int(t1)] > pt2 = self.pts[(int(t1) + 1)%self.N] > return np.complex(self.shift[0] + pt1[0] + (pt2[0] - pt1[0])* > (t1-int(t1)),self.shift[1] + pt1[1] + (pt2[1] - pt1[1])*(t1-int(t1))) > > def derivative(self,float t): > if self.reverse == 1: > t0 = TWOPI-t0 > while t0 >= TWOPI: > t0 -= TWOPI > t1 = (t0 * self.N/(TWOPI)) > pt1 = self.pts[int(t1)] > pt2 = self.pts[(int(t1) + 1)%self.N] > return np.complex((pt2[0] - pt1[0])*self.N/(TWOPI),(pt2[1] - > pt1[1])*self.N/(TWOPI)) > class CCSpline(): > def __init__(self,cps): > cdef int N,i,k,B > B = len(cps) > N = len(cps[0]) > self.avec = np.zeros([B,N],dtype = np.complex128) > self.bvec = np.zeros([B,N],dtype = np.complex128) > self.cvec = np.zeros([B,N],dtype = np.complex128) > self.dvec = np.zeros([B,N],dtype = np.complex128) > for k in range(B): > pts = cps[k] > yvec = np.zeros(N,dtype = np.complex128) > for i in xrange(N): > yvec[i] = 3*(pts[(i-1)%N]-2*pts[i]+pts[(i+1)%N]) > bmat = np.zeros([N,N],dtype = np.complex128) > for i in xrange(N): > bmat[i,i] = 4 > bmat[(i-1)%N,i] = 1 > bmat[(i+1)%N,i] = 1 > bvec = (np.linalg.solve(bmat,yvec)) > > cvec = np.zeros(N,dtype = np.complex128) > for i in range(N): > cvec[i] = pts[(i+1)%N] - pts[i] - 1./3.*bvec[(i+1)%N] > - 2./3. * bvec[i] > dvec = pts > avec = range(N) > for i in range(N): > avec[i] = 1./3.*(bvec[(i+1)%N] - bvec[i]) > self.avec[k] = avec > self.bvec[k] = bvec > self.cvec[k] = cvec > self.dvec[k] = dvec > self.N = N > > def value(self,t0,k=0): > cdef float t = (t0/TWOPI*self.N)%self.N > cdef int j = int(t) > return self.avec[k,j]*(t-j)**3+self.bvec[k,j]*(t-j) > **2+self.cvec[k,j]*(t-j)+self.dvec[k,j] > > def derivative(self,t0,k=0): > cdef float t = (t0/TWOPI*self.N)%self.N > cdef int j = int(t) > return 3*self.avec[k,j]*(t-j)**2+2*self.bvec[k,j]*(t-j) > +self.cvec[k,j] > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---