Then download the Cython tarball. Before you build Cython make sure you setup compile flags for 32bitness and make sure python 2.6 gets used i.e.
export CFLAGS="-m32 -march=i386"
export PYTHON="python26"
then run python26 setup.py install in the Cython directory. I had to do some other hacking of -m32 and -march=i386 on to things, but I think doing it this way should work. That should build and install Cython.
Put the following example in a file called demo.pyx:
cdef extern from "math.h":
double sin(double)
cdef double f(double x):
return sin(x)
print f(2.0)
Then make the following Makefile. Make sure you have tabs!
demo: demo.pyx
cython demo.pyx --embed
gcc -g -pthread -m32 -march=i386 demo.c -L/usr/lib -lm -lpython2.6 -o ./demo -I/usr/include/python2.6
Then just type make and it should build a binary called demo.
No comments:
Post a Comment