On Jul 25, 2009, at 12:44 AM, Jason Grout wrote: > Hi all, > > I have a directory with several python and cython files that import > and > cimport Sage objects and use them. I can't figure out how to build > the > Cython files that reference Sage objects when these files are not > in the > Sage source tree. What I'd love is to be able to write code like one > could write in %cython blocks in the notebook, but in .pyx files in a > directory outside of the Sage source tree. > > I've created a small test directory with a few files at: > > http://sage.math.washington.edu/home/jason/testme/ > > (or a compressed version at > http://sage.math.washington.edu/home/jason/testme.tar.gz) > > What I'd like to do is something like this: > > sage: import testme > sage: a=testme.TestPython('python name') > sage: a.run() > sage: a.runcython() > sage: b=testme.TestCython('cython name') > sage: b.run() > > > The best I've been able to do thus far is to: > > > 1. comment out all references to Integer in the pyx/pxd files > 2. change sage_malloc/free to stdlib.malloc/free > 3. move the __init__.py[c] files to another place > 4. compile the cython module with: > > sage -python setup.py build_ext --inplace > > 5. move the __init__.py file back > > And then things seem to work (but I can't access Sage things from the > cython file). And it seems really odd that I have to delete the > __init__.py file in order to compile the cython file. > > I also messed around with trying stuff from sage.misc.cython, thinking > that the right includes and setup.py incantations were there > somewhere, > but I couldn't ever get anything to work. > > Can someone help?
In setup.py, you can set your include_dirs options to include the Sage source tree. Also, if you have a .spyx file outside of the sage tree, you can do "sage -cython foo.spyx" and it will make a .c file including all the sage stuff as needed. - Robert --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---
