Development in Sage - My process
In the git development process, I was having frequent (re)compilation of the Sage library. This is not pleasant since the desktop I work on is not that powerful and it takes ages to do any quick development process. I started a thread in sage-devel (see https://groups.google.com/d/topic/sage-devel/WpDnmLZJKDE/discussion
) in order to look for ways to reduce (re)compilation. Thanks to +Nathann Cohen
I have come across some ways to achieve potentially minimum recompilations.Initial Steps
1. Set up Sage by downloading a development version, by having an account on trac.sagemath.org
, and by having ssh-keys set up. I won't go into the details here, but I will assume that after you are set up, you are mildly familiar with git, and you are inside SAGE_ROOT. The following command should show "origin" as a remote branch:
$ git branch -r | grep origin
origin/HEAD -> origin/master
1. Set up a develop branch that tracks the develop branch of origin
$ git checkout --track origin/develop -b develop
2. Enable "SAGE_INSTALL_CCACHE": In your ~/.bashrc, set the following
3. Enable simultaneous compilations: Before compiling or building the documentation, set the following MAKE variable in your terminal (assuming you are running Linux)
$ export MAKE="make -j$(grep -c bogomips /proc/cpuinfo)"
4. Upgrade Sage to the latest develop version
$ git checkout develop
$ ./sage -upgrade develop
5. Install git-trac-command. I will assume that ~/bin is in our PATH
$ cd .. # Assuming we were in SAGE_ROOT, I go one directory above SAGE_ROOT
$ git clone https://github.com/sagemath/git-trac-command.git
$ ln -s "$PWD"/git-trac-command/bin/git-trac ~/bin
$ cd - # We go back to inside SAGE_ROOT
$ git remote add trac ssh://email@example.com/sage.git
$ git trac config --user=Myself --pass=s3kr1tDevelopment with up-to-date develop branch - existing ticket
Suppose you want to test an existing branch in a trac ticket #12345. Now, your develop is up-to-date, but the branch in the trac ticket may not be based on the latest develop version of Sage. So, it is better to "pull" the branch in order to check out the changes. Hopefully, the patch does not depend on changes in packages/spkg.
1. Pull the remote trac ticket
$ git checkout develop -b ticket/12345
$ git trac pull 12345
$ git diff develop # check changes against the latest develop branch
2. Recompile sage and do your tests, etc. It won't take long to recompile.
$ ./sage -b
3. If you are the author of the branch, you can push new changes easily:
$ # edit files and make git commits
$ git trac push 12345
4. (Todo:) How to push changes if you are not the original authorDevelopment with non up-to-date develop branch
-----------------------------------------------This is not a recommended method: use at your own discretion
Suppose your develop branch is not up to date, and the ticket you want to check out is on a newer development branch of Sage. In this case, you can still check out the ticket and test the changes it has made. It might be "good enough" for making a basic review of the ticket. However, this requires that you know well enough that the changes in the ticket do not depend on Sage features that have been introduced after your current develop branch. Moreover, a full review of the ticket will probably require you to upgrade to the newest develop code and test that it hasn't broken the existing code.
1. Fetch the branch in the ticket. Suppose the branch is u/username/patch . Note down the SHA hashes of the commits in that branch.
$ git fetch trac u/username/patch
2. Cherry-pick the commits you want. Look at the manual of git cherry-pick to see how to provide ranges of commits.
$ git cherry-pick <hash>
3. Recompile sage, and do tests, etc.
$ ./sage -b
In many cases this method will not work because the changes in the ticket may be extensive and may involve a long trail of patches, some of which are merges of the develop branch on to the ticket. So, you have to be extra careful when doing this. However, if this procedure is successful, then it will save a lot of time that would be otherwise spent in recompiling Sage or upgrading Sage (especially if the changes in the ticket are trivial).Development with new ticket
Suppose there is a new ticket; new in the sense that there are no existing patches in the ticket. In this case, we can simply do a checkout of the ticket and let the "git trac" command handle creation of a new branch.
$ git trac checkout 12345 # will create a branch based off our develop
$ # edit edit, and commit
$ git trac push # push our changes to the ticket
Feedback is welcome on other ways to reduce compilation during development!