Contribute

In the open source spirit, everybody is welcome to take part in the SageManifolds project. There are many ways to contribute:

Sharing a notebook

If you would like to share a notebook for the examples or gallery pages, please send it (in Jupyter format) to this address.

Reviewing SageManifolds code

If you know about Python (*), please consider reviewing SageManifolds code under development for the next version of SageMath. Such a code is available as opened pull requests listed at this GitHub page (**). Please follow the reviewer guidelines.

(*) Even if you are not a Python guru, you can significantly contribute to a pull request review by checking the mathematical correctness and documentation quality of the proposed changes.

(**) Before February 2023, the SageMath development infrastructure was based on a Trac server; since then, it has been migrated to GitHub (cf. the migration page and this video).

Writing code

Given the open-source nature of SageMath, it is quite easy to improve some parts of SageManifolds or to implement new functionalities. You may first have a look at these lecture notes, which describe some details of the implementation. The main steps for downloading and modifying the source code, as well as submitting your work for integration in SageMath, are summarized below. For more details see the official Sage Developer Guide, in particular the Development Walk-trhough section.

1. Starting from the latest sources

To write some code, you need to edit the Python source files. They are available from the SageMath github repository.

To download and install the latest development version of SageMath, proceed as follows. If you don't have one already, create a (free) account at github.com, if you don't have any yet, and fork the repository sagemath/sage under USERNAME/sage, where USERNAME is your GitHub account name. Next type the following commands in a terminal from, let us say, your home directory (not the root directory of your current stable SageMath install if any):

git clone https://github.com/USERNAME/sage.git     (download SageMath sources into a new directory, named sage)
cd sage
git remote add upstream https://github.com/sagemath/sage.git
git pull upstream develop     (downloads the latest development sources)

2. Building SageMath from source

The package/environment manager Conda is used to manage dependencies when building SageMath. If Conda is not already installed on your computer, either download the Miniforge installer from here or run in a terminal

curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"

Then run the installer via

bash Miniforge3-$(uname)-$(uname -m).sh

Answer yes to the question Proceed with initialization?
Close the terminal and reopen a new one to activate Conda (in the "base" environment).

Go back to the sage directory created by the git clone command above (hereafter named SAGE_ROOT) and create a new Conda environment named sage-dev from the file environment-PYTHON_VERSION-OS.yml in that directory, where PYTHON_VERSION is the version number of Python on your computer (e.g. 3.14) and OS is the name of your operating system (e.g. linux):

conda env create --file environment-3.14-linux.yml --name sage-dev

Then run the following commands:

conda activate sage-dev     (activates the environment sage-dev)
pip install --no-build-isolation --editable .     (builds SageMath)
pip install jupyterlab
pip install notebook     (the classic (legacy) jupyter notebook)

At this stage, you should have a working version of the development version of SageMath, which you can run in Jupyterlab by typing

./sage -n jupyterlab

3. Coding your changes

Create a new git branch to store your changes:

git checkout -b my_changes     (creates the git branch my_changes and makes it the current branch)

The SageManifolds code lies in two subdirectories:

  • src/sage/tensor/modules/ for the pure algebraic part (tensors on free modules)
  • src/sage/manifolds/ for the topological and differential parts
Edit or add some source files in these directories. It is mandatory to follow the programming rules exposed in the Sage Developer’s Guide; in particular read carefully the section Writing Code for Sage.

4. Running doctests

Doctests are testable examples that are embedded in docstrings of Python classes and functions (more generally in comments part of Python source files). They are automatically tested via the command sage -t. So after your changes, you should run

./sage -t --long src/sage/manifolds/

Note that -t can be replaced by -tp to run doctests in parallel (cf. ./sage -t --help for the full list of options controlling doctest runs). You should also check that all the new functions that you have introduced have doctests:

./sage -coverage src/sage/manifolds/

5. Generating and checking the documentation

Please take time to document your changes as much as possible, especially by providing examples of use in the docstrings following these rules. If you have added new source files, you may have to edit some rst files in SAGE_ROOT/src/doc/en/reference/manifolds/, so that the new files are taken into account in the documentation. Note that bibliographic references shall be put in the master file SAGE_ROOT/src/doc/en/reference/references/index.rst. To generate the documentation from the docstrings in Python source files, run (from the SAGE_ROOT directory)

./sage -docbuild reference/manifolds html

(if you get an error, you may need to regenerate the whole reference manual by make doc-clean && make doc). The generated documentation lies in

SAGE_ROOT/local/share/doc/sage/html/en/reference/manifolds/index.html

This is actually the manifolds section of the whole SageMath reference manual, which is at SAGE_ROOT/local/share/doc/sage/html/en/reference/index.html.

6. Sharing your changes

When you are ready to share your changes, create a new commit on your local git branch my_changes:

git commit -a -m "Short description of your changes"
Then push the branch to your fork USERNAME/sage on GitHub (i.e. to the remote labelled origin):
git push --set-upstream origin my_changes
This will create the new branch my_changes in the GitHub repository USERNAME/sage and will set it to the be the upstream of the local branch my_changes (thanks to the --set-upstream option). In the returned message on your terminal, you will get some url link for opening a pull request on the develop branch of sagemath/sage. When filling the pull request form, please select c: manifolds and s: needs review in the Labels menu (c: stands for component and s: for status). If the reviewer is asking for some modifications and you implement them in the local branch my_changes, it will suffice to run
git push
to push the modifications to the remote branch my_changes of USERNAME/sage (no need to specify --set-upstream).

That's it! Thank you for contributing to the project!