Ask Your Question
2

Writing portable Sage module

asked 2010-12-12 15:43:36 -0600

jvkersch gravatar image

updated 2011-04-28 12:13:26 -0600

Kelvin Li gravatar image

I've been working on a bit of code that is of interest to a bunch of people but far too specific to even be considered for inclusion in Sage. Is it possible to package my code as an spkg, put the binary on a server somewhere, and then have interested parties install it by typing ./sage -t url-to-package? Or should I just stick to distributing my .sage files as tarball?

Sorry if this is already in the developer manual! However, when I checked, most of the instructions dealt with preparing an spkg and submitting it to the trac server, which is not what I want to do.

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
3

answered 2010-12-13 01:50:24 -0600

If your code is in Python, you can create an egg and announce the URL. Then interested people only need to run

easy_install <the_url_to_the_egg>

in a Sage shell (which you get with ./sage -sh) or in a %sh cell in the notebook.

Here are some instructions on creating Python eggs.

edit flag offensive delete link more

Comments

This seems doable too -- my code is valid Python. Are there any "sage eggs" that I could take apart to see how its done and where the relevant files end up?

jvkersch gravatar imagejvkersch ( 2010-12-14 04:32:21 -0600 )edit
2

answered 2010-12-12 18:01:28 -0600

Eviatar Bach gravatar image

Perhaps you could submit it for inclusion as an optional package: http://sagemath.org/packages/optional/? This would reach a large audience.

edit flag offensive delete link more

Comments

I agree that this would be a good idea. It doesn't seem as if the optional packages are reviewed, so that's a good point. I unpacked some of the packages, and it looks like something I could put together.

jvkersch gravatar imagejvkersch ( 2010-12-14 04:29:35 -0600 )edit
1

answered 2010-12-21 20:55:49 -0600

Jason Grout gravatar image

updated 2010-12-21 20:57:38 -0600

I've published a small library of code that people can easily use just by loading it. I tried to make the library so that it can also be downloaded into a directory and imported as a normal python module. See https://github.com/jasongrout/minimum_rank for my code. To load the code into a Sage worksheet or session, I just include

URL='http://github.com/jasongrout/minimum_rank/raw/minimum_rank_1_0_0/' 
files=['Zq_c.pyx','Zq.py','zero_forcing_64.pyx','zero_forcing_wavefront.pyx','minrank.py']
for f in files: load(URL+f)

in the top cell (note that this loads the files straight from the github page). This will automatically compile the Cython files as well. This can be done, but the entire directory could also be downloaded and used by just importing the module into the namespace. A third way I distribute this library is by attaching the files to a Sage worksheet, and then loading the files using the DATA path instead of the github path above.

My purpose in doing this is that many of the people in my target audience will not have the ability to install spkgs (for example, on sagenb.org). This approach allows them to use the library by just including a few lines at the top of their worksheet.

edit flag offensive delete link more

Comments

Cool; I didn't think about the fact that non-standard extensions aren't readily accessible from within the notebook.

jvkersch gravatar imagejvkersch ( 2010-12-28 17:22:54 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2010-12-12 15:43:36 -0600

Seen: 506 times

Last updated: Dec 21 '10