Re: [sage-support] Re: Best way to develop Sage packages?
Thanks for everyone's help. I decided to make it a package that can be installed like: sage -python setup.py install My setup.py is as follows (except I changed the name of the package). I arrived at its contents by trial and error, so if anyone could have a quick look at it to see if there is anything really silly, then that would be appreciated! -Emil -- import os from distutils.core import setup from distutils.extension import Extension from Cython.Distutils import build_ext if not os.environ.has_key('SAGE_ROOT'): print ERROR: The environment variable SAGE_ROOT must be defined. sys.exit(1) else: SAGE_ROOT = os.environ['SAGE_ROOT'] SAGE_LOCAL = SAGE_ROOT + '/local' SAGE_DEVEL = SAGE_ROOT + '/devel' setup( name='MyPackage', packages=['mypackage'], version='1.0', cmdclass = {'build_ext': build_ext}, ext_modules = [ Extension('mypackage.thing', sources=['mypackage/thing.pyx'], include_dirs = [SAGE_LOCAL + '/lib/python/site-packages/numpy/core/include', SAGE_LOCAL + '/include/csage', SAGE_DEVEL + '/sage/sage/ext', SAGE_DEVEL + '/sage'], library_dirs = [SAGE_LOCAL + '/lib']) ] ) -- 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 URL: http://www.sagemath.org
Re: [sage-support] Re: Best way to develop Sage packages?
On Monday, April 2, 2012 8:32:18 AM UTC-7, Emil wrote: Thanks for everyone's help. I decided to make it a package that can be installed like: sage -python setup.py install My setup.py is as follows (except I changed the name of the package). I arrived at its contents by trial and error, so if anyone could have a quick look at it to see if there is anything really silly, then that would be appreciated! -Emil -- import os from distutils.core import setup from distutils.extension import Extension from Cython.Distutils import build_ext if not os.environ.has_key('SAGE_ROOT'): Using if not 'SAGE_ROOT' in os.environ is better. has_key has been deprecated. print ERROR: The environment variable SAGE_ROOT must be defined. sys.exit(1) else: SAGE_ROOT = os.environ['SAGE_ROOT'] SAGE_LOCAL = SAGE_ROOT + '/local' It's better to use SAGE_LOCAL = os.path.join(SAGE_ROOT, 'local') I don't have comments about any of the rest of it. -- John -- 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 URL: http://www.sagemath.org
Re: [sage-support] Re: Best way to develop Sage packages?
Thanks! Actually, I have a little problem. In setup.py I have: Extension('thing', sources=['mypackage/thing.pyx'], include_dirs = [SAGE_LOCAL + '/lib/python/site-packages/numpy/core/include', SAGE_LOCAL + '/include/csage', SAGE_DEVEL + '/sage/sage/ext', SAGE_DEVEL + '/sage'], library_dirs = [SAGE_LOCAL + '/lib'] Now, thing.pyx has a class Thing, which in Sage is then called thing.Thing. However, I would like it to be called 'mypackage.thing.Thing'. Is this possible? (If in the above code I change the first argument of Extension to 'mypackage.thing', I am unable to import it at the sage: prompt - although thing.so gets put inside the site-packages/mypackage directory instead of in its parent.) Emil -- 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 URL: http://www.sagemath.org
Re: [sage-support] Re: Best way to develop Sage packages?
On Saturday, March 31, 2012 11:42:08 PM UTC+1, Emil wrote: not pollute the name space (It contains classes with quite generic names like Problem and Construction.) Whats wrong with the module foo having a foo.Problem class? How is your spkg going to add cython modules to module_list.py? You can monkey-patch it in the spkg-install script but thats just a bad idea. For starters, it is definitely going to break down the road. -- 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 URL: http://www.sagemath.org
Re: [sage-support] Re: Best way to develop Sage packages?
On Sat, Mar 31, 2012 at 3:42 PM, Emil emi...@gmail.com wrote: On 31 March 2012 12:47, Volker Braun vbraun.n...@gmail.com wrote: If it is of interest to an academic community then it probably should be part of Sage ;-) I'm not against it being incorporated into Sage at some point, but right now I'd rather keep it as a separate package that people can install, and import if they want to use it; but if they don't it will not pollute the name space (It contains classes with quite generic names like Problem and Construction.) From what I can tell, I can use Python distutils, and I can get the SAGE_ROOT from environment variables, so that I can set the include_dirs for the Cython compilation. Then I just give people a tar ball and tell them to run sage -python setup.py. That would work fine, or even a pointer to a repository that then can clone/contribute to. Does this sound a good strategy? Or would it be best to distribute an .spkg ? Can .spkg's install stuff into the site-packages directory outside the sage folder? Spks would work fine. IIRC, the default is to run setup.py if there's a setup.py in the sources (though note that all the code lives under a scr directory, and one needs a couple of metadata files. They're just bzipped tarballs, so the easiest way is to understand them unpack some and take a look. That being said, I would suggest contribute to the main library unless there's a strong reason not to. Also, is there any documentation on sage -pkg? Emil -- 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 URL: http://www.sagemath.org -- 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 URL: http://www.sagemath.org
Re: [sage-support] Re: Best way to develop Sage packages?
On Apr 1, 2012 7:18 PM, Keshav Kini keshav.k...@gmail.com wrote: Volker Braun vbraun.n...@gmail.com writes: How is your spkg going to add cython modules to module_list.py? You can monkey-patch it in the spkg-install script but thats just a bad idea. For starters, it is definitely going to break down the road. Correct me if I'm wrong, but random distutils-based packages can utilize Cython just as well as the Sage library distutils-based package, no? I seem to recall making such an SPKG once upon a time... In which case it wouldn't do anything to Sage's module_list.py, just have its own one. -Keshav Keshav, you are of course right. Psage is a large example of this, and there are probably thousands of others (every python library ever released that uses Cython). Join us in #sagemath on irc.freenode.net ! -- 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 URL: http://www.sagemath.org -- 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 URL: http://www.sagemath.org
Re: [sage-support] Re: Best way to develop Sage packages?
If it is of interest to an academic community then it probably should be part of Sage ;-) On Friday, March 30, 2012 11:04:00 PM UTC+1, Emil wrote: 3) probably shouldn't be made part of everyone's Sage, but it would be good if people could install it easily, as it will be of interest to a certain community. PS: For testing a single command I find the sage -b sage -c print 1+1 command line useful. Then edit and re-run the command to check that your edit worked as intended. For simple things attach()-ing is fine but once it gets to Cython and/or category code you'll run into its limitations. -- 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 URL: http://www.sagemath.org
Re: [sage-support] Re: Best way to develop Sage packages?
On 31 March 2012 12:47, Volker Braun vbraun.n...@gmail.com wrote: If it is of interest to an academic community then it probably should be part of Sage ;-) I'm not against it being incorporated into Sage at some point, but right now I'd rather keep it as a separate package that people can install, and import if they want to use it; but if they don't it will not pollute the name space (It contains classes with quite generic names like Problem and Construction.) From what I can tell, I can use Python distutils, and I can get the SAGE_ROOT from environment variables, so that I can set the include_dirs for the Cython compilation. Then I just give people a tar ball and tell them to run sage -python setup.py. Does this sound a good strategy? Or would it be best to distribute an .spkg ? Can .spkg's install stuff into the site-packages directory outside the sage folder? Also, is there any documentation on sage -pkg? Emil -- 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 URL: http://www.sagemath.org
Re: [sage-support] Re: Best way to develop Sage packages?
I think you should make it an spkg because that is how people using sage expect to install it. Note that the install script in an spkg can contain arbitrary bash code so it can do everything you want it to. -- 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 URL: http://www.sagemath.org
Re: [sage-support] Re: Best way to develop Sage packages?
Pedro, John - thanks for your replies! It is a shame that you can't recompile bits of Sage from within Sage, but I guess there are good reasons for this. My package has the following characteristics: 1) it uses lots of Sage things 2) it is a mixture of Cython and Python 3) probably shouldn't be made part of everyone's Sage, but it would be good if people could install it easily, as it will be of interest to a certain community. Because of (3), I would lean towards Pedro's idea of using site-packages, however, I have lines like this in my .pyx files: include ../ext/interrupt.pxi So I guess this means that I need to be part of the sage directory structure, rather than being in site-packages? Or could I use SAGE_ROOT or something to always guarantee to be able to find these files? Emil -- 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 URL: http://www.sagemath.org