passagemath is open source mathematical software in Python, released under the GNU General Public Licence GPLv2+.
It is a fork of SageMath, which has been developed 2005-2025 under the motto "Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, and MATLAB".
The passagemath fork was created in October 2024 with the following goals:
- providing modularized installation with pip, thus completing a major project started in 2020 in the Sage codebase,
- establishing first-class membership in the scientific Python ecosystem,
- giving clear attribution of upstream projects,
- providing independently usable Python interfaces to upstream libraries,
- providing platform portability and integration testing services to upstream projects,
- inviting collaborations with upstream projects,
- building a professional, respectful, inclusive community,
- developing a port to Pyodide for serverless deployment with Javascript,
- developing a native Windows port.
Full documentation is available online.
Join passagemath.discourse.group for help and discussions.
Join the BlueSky platform and follow @passagemath.org to receive announcements.
People all around the globe have contributed to the development of SageMath since 2005, and hence of passagemath.
See CONTRIBUTING.md for how you can contribute.
passagemath is a major integrating force in the mathematical software landscape.
passagemath attempts to support all major Linux distributions and recent versions of macOS. Use on Windows currently requires the use of Windows Subsystem for Linux or virtualization.
Complete sets of binary wheels are provided on PyPI for Python versions 3.9.x-3.13.x for Linux and macOS, both for the x86_64 and ARM architectures.
Unless you need to install passagemath into a specific existing environment, we recommend
to create and activate a fresh virtual environment over a suitable Python (3.9.x-3.13.x),
for example ~/passagemath-venv/
:
$ python3 --version
Python 3.12.7
$ python3 -m venv ~/passagemath-venv
$ source ~/passagemath-venv/bin/activate
For Python 3.13.x on any platform, and for any Python version on the Linux aarch64 (ARM)
and macOS arm64 (Apple Silicon M1/M2/M3/M4) platforms,
some third-party packages are still missing wheels.
Build these wheels from source using
(passagemath-venv) $ export SAGE_CONF_TARGETS="fpylll gmpy2 lrcalc_python memory_allocator pplpy primecountpy"
(passagemath-venv) $ pip install --force-reinstall -v passagemath-conf
(passagemath-venv) $ export PIP_FIND_LINKS=$(sage-config SAGE_SPKG_WHEELS)
(passagemath-venv) $ export PIP_PREFER_BINARY=1
(passagemath-venv) $ pip install -v --prefer-binary passagemath-standard
Start the Sage REPL:
(passagemath-venv) $ sage
Alternatively, use a Python or IPython REPL, or use a Python or Sage kernel in Jupyter.
As the installation using pip shows, passagemath provides the Sage library in a large number of distributions (pip-installable packages) that can also be installed separately.
Authors of packages that depend on the Sage library can declare dependencies on these distributions. The benefit for users of the package: There is no longer a need to first install Sage. Instead, the parts of the Sage library that are needed by the package are automatically installed. Thus, the package becomes a first-class member of the Python ecosystem.
-
sage-numerical-interactive-mip is an example of a pure Python package that declares dependencies on four distributions: passagemath-polyhedra, passagemath-plot, passagemath-repl, and passagemath-flint.
-
kerrgeodesic_gw is an example of a pure Python package that declares optional dependencies ("extras-require") on three distributions: passagemath-symbolics, passagemath-plot, and passagemath-repl.
-
See passagemath/passagemath#248 for many more examples how to change a user package to make it ready for passagemath and the Python ecosystem.
Here is an overview of the distribution packages of passagemath.
The packages may also cover a wide range of generalizations/applications of the structure after which they are named. Users who work in a specialized research area will, of course, recognize what structures they need. The down-to-earth naming also creates discoverability by a broader audience.
provides "everything combinatorial", except for graphs. It consists of about 350 first-party Python and Cython modules and also provides the functionality of SYMMETRICA, the library for representation theory of the symmetric group, combinatorics of tableaux, symmetric functions, etc.
provides directed and undirected graphs, but also posets, combinatorial designs, abstract simplicial complexes, quivers, etc. It consists of over 170 first-party Python and Cython modules and uses the Boost Graph Library, with additional functionality from NetworkX and several other libraries.
provides groups and invariant theory. It heavily depends on GAP via passagemath-gap.
provides vector spaces, modules, matrices, tensors, homology, coding theory, abelian groups, matroids, etc. It consists of over 440 first-party Python and Cython modules and depends on the GNU Scientific Library and NumPy.
provides convex polyhedra in arbitrary dimension on the basis of the Parma Polyhedra Library. It consists of about 130 first-party Python and Cython modules that also provide fans, hyperplane arrangements, polyhedral complexes, linear and mixed-integer optimization, lattice point sets, and toric varieties.
provides algebraic varieties, schemes, elliptic curves, modular forms, etc.
provides symbolic expressions implemented in Pynac, a fork of GiNaC, symbolic calculus using Maxima, and interfaces to various other symbolic software systems including SymPy, as well as differential geometry (SageManifolds).
This makes technical sense because the dependencies will be localized to this distribution package, but it also helps give attribution and visibility to these libraries and projects that Sage depends on.
Standard packages | Optional packages |
---|---|
Sage extends Python's object system by dynamic mix-in classes that are driven by categories and axioms. It is loosely modeled on concepts of category theory and inspired by Scratchpad/Axiom/FriCAS, Magma, and MuPAD. This distribution package makes Sage objects, the element/parent framework, basic categories and functors, the coercion system and the related metaclasses available. It only depends on the basic arithmetic libraries GMP, MPFR, MPC, on the Cython interface gmpy2 to these libraries, and on cysignals.
This distribution package contains the full set of categories defined by Sage, as well as basic mathematical objects such as integers and rational numbers, a basic implementation of polynomials, and affine spaces. None of this brings in additional dependencies.
provides the
sage
script for launching the Sage REPL and accessing various developer tools and Python modules that provide the connection to the system and software environment.
The top-level interactive environment with the preparser that defines the surface language of Sage. This distribution also includes the doctesting facilities (
sage -t
), as the doctests are written in the surface language.
Plotting facilities, depending on matplotlib for 2D graphics, three.js for 3D graphics.
Ideally an empty meta-package that depends on everything that is not in passagemath-symbolics; as a catch-all mechanism, this distribution ships all modules that do not carry a
# sage_setup: distribution = ...
directive.
Everything as provided by a standard installation of the Sage distribution. This is reduced to an empty meta-package.
Confectionery and configuration system.
Build system for the Sage library.
Build system for the Sage documentation.
The remainder of this README contains self-contained instructions for building passagemath from source. This requires you to clone the git repository (as described in this README).
- Supported Platforms
- [Windows] Preparing the Platform
- [macOS] Preparing the Platform
- Preparation for Building from Source
- Full Installation from Source as passagemath
- Traditional Installation from Source as Sage-the-Distribution
- Use With an Existing Jupyter Installation
- Directory Layout
passagemath attempts to support all major Linux distributions and recent versions of macOS. Use on Windows currently requires the use of Windows Subsystem for Linux or virtualization.
Detailed information on supported platforms for a specific version of Sage can be found in the section Availability and installation help of the release notes for this version.
We highly appreciate contributions to passagemath that fix portability bugs and help port Sage to new platforms.
The preferred way to run Sage on Windows is using Windows Subsystem for Linux (WSL). Follow the official WSL setup guide to install Ubuntu (or another Linux distribution). Make sure you allocate WSL sufficient RAM; 5GB is known to work, while 2GB might be not enough for building Sage from source. Then all instructions for installation in Linux apply.
As an alternative, you can also run Linux on Windows using Docker or other virtualization solutions.
-
If your Mac uses the Apple Silicon (M1, M2, M3, M4; arm64) architecture and you set up your Mac by transferring files from an older Mac, make sure that the directory
/usr/local
does not contain an old copy of Homebrew (or other software) for the x86_64 architecture that you may have copied over. Note that Homebrew for Apple Silicon is installed in/opt/homebrew
, not/usr/local
. -
We strongly recommend to use Homebrew ("the missing package manager for macOS") from https://brew.sh/, which provides the
gfortran
compiler and many libraries. -
Otherwise, if you do not wish to install Homebrew, you will need to install the latest version of Xcode Command Line Tools. Open a terminal window and run
xcode-select --install
; then click "Install" in the pop-up window. If the Xcode Command Line Tools are already installed, you may want to check if they need to be updated by typingsoftwareupdate -l
.
The instructions cover all of Linux, macOS, and WSL.
More details, providing a background for these instructions, can be found in the section Install from Source Code in the Installation Guide.
-
Decide on the source/build directory (
SAGE_ROOT
):-
Any subdirectory of your :envvar:
HOME
directory should do. -
For example, you could use
SAGE_ROOT=~/sage/passagemath
, which we will use as the running example below. -
You need at least 10 GB of free disk space.
-
The full path to the source directory must contain no spaces.
-
After starting the build, you cannot move the source/build directory without breaking things.
-
You may want to avoid slow filesystems such as network file systems (NFS) and the like.
-
[macOS] macOS allows changing directories without using exact capitalization. Beware of this convenience when compiling for macOS. Ignoring exact capitalization when changing into :envvar:
SAGE_ROOT
can lead to build errors for dependencies requiring exact capitalization in path names.
-
-
Clone the sources with
git
:-
To check that
git
is available, open a terminal and enter the following command at the shell prompt ($
):$ git --version git version 2.42.0
The exact version does not matter, but if this command gives an error, install
git
using your package manager, using one of these commands:$ sudo pacman -S git # on Arch Linux $ sudo apt-get update && apt-get install git # on Debian/Ubuntu $ sudo yum install git # on Fedora/Redhat/CentOS $ sudo zypper install git # on openSUSE $ sudo xbps-install git # on Void Linux
-
Create the directory where
SAGE_ROOT
should be established:$ mkdir -p ~/sage $ cd ~/sage
-
Clone the passagemath git repository:
$ git clone -c core.symlinks=true --filter blob:none \ --origin passagemath \ https://github.com/passagemath/passagemath.git
This will create the subdirectory
~/sage/passagemath
. (See the section Setting up git and the following sections in the Sage Developer's Guide for more information.) -
Change into the created subdirectory:
$ cd passagemath
-
[Windows] The passagemath source tree contains symbolic links, and the build will not work if Windows line endings rather than UNIX line endings are used.
Therefore it is recommended (but not necessary) to use the WSL version of
git
.
-
-
Install system packages.
Either refer for this to the section on installation from source in the Sage Installation Manual for compilations of system packages that you can install.
The precise list of packages varies with the version of your distribution. If a package is not available and gives an error, just skip it and try again with the rest of the packages.
When done, skip to step 7 (bootstrapping).
Alternatively, follow the more fine-grained approach below.
-
[Linux, WSL] Install the required minimal build prerequisites:
-
Compilers:
gcc
,gfortran
,g++
(GCC versions from 9.x to 14.x and recent versions of Clang (LLVM) are supported). See build/pkgs/gcc/SPKG.rst and build/pkgs/gfortran/SPKG.rst for a discussion of suitable compilers. -
Build tools: GNU
make
, GNUm4
,perl
(includingExtUtils::MakeMaker
),ranlib
,git
,tar
,bc
. See build/pkgs/_prereq/SPKG.rst for more details. -
Python 3.4 or later, or Python 2.7, a full installation including
urllib
; but ideally version 3.9.x-3.13.x, which will avoid having to build Sage's own copy of Python 3. See build/pkgs/python3/SPKG.rst for more details.
We have collected lists of system packages that provide these build prerequisites. See, in the folder build/pkgs/_prereq/distros, the files arch.txt, debian.txt (also for Ubuntu, Linux Mint, etc.), fedora.txt (also for Red Hat, CentOS), opensuse.txt, slackware.txt, and void.txt, or visit https://doc.sagemath.org/html/en/reference/spkg/_prereq.html#spkg-prereq
-
-
Optional: It is recommended that you have both LaTeX and the ImageMagick tools (e.g. the "convert" command) installed since some plotting functionality benefits from them.
-
Install the bootstrapping prerequisites. See the files in the folder build/pkgs/_bootstrap/distros, or visit https://doc.sagemath.org/html/en/reference/spkg/_bootstrap.html#spkg-bootstrap
-
Sanitize the build environment. Use the command
$ env
to inspect the current environment variables, in particular
PATH
,PKG_CONFIG_PATH
,LD_LIBRARY_PATH
,CFLAGS
,CPPFLAGS
,CXXFLAGS
, andLDFLAGS
(if set).Remove items from these (colon-separated) environment variables that Sage should not use for its own build. In particular, remove items if they refer to a previous Sage installation.
-
[WSL] In particular, WSL imports many items from the Windows
PATH
variable into the Linux environment, which can lead to confusing build errors. These items typically start with/mnt/c
. It is best to remove all of them from the environment variables. For example, you can setPATH
using the command:$ export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/wsl/lib
-
[macOS with homebrew] Set required environment variables for the build:
$ source ./.homebrew-build-env
This is to make some of Homebrew's packages (so-called keg-only packages) available for the build. Run it once to apply the suggestions for the current terminal session. You may need to repeat this command before you rebuild Sage from a new terminal session, or after installing additional homebrew packages. (You can also add it to your shell profile so that it gets run automatically in all future sessions.)
-
-
Bootstrap the source tree using the following command:
$ make configure
Unless you need to install passagemath into a specific existing environment, we recommend
to create and activate a fresh virtual environment over a suitable Python (3.9.x-3.13.x),
for example ~/passagemath-venv/
:
$ python3 --version
Python 3.12.7
$ python3 -m venv ~/passagemath-venv
$ source ~/passagemath-venv/bin/activate
Next, if you want to build from PyPI, use the following command:
(passagemath-venv) $ export SAGE_CONF_TARGETS=build
If you want to build from a local clone of the passagemath repository instead, use the following command first.
(passagemath-venv) $ export SAGE_ROOT=$(pwd)
(passagemath-venv) $ export PIP_CONSTRAINT="$(pwd)/constraints_pkgs.txt"
(passagemath-venv) $ export SAGE_CONF_TARGETS=build-local
As the first installation step, install ,
which builds various prerequisite non-Python packages in a subdirectory of
~/.sage/
.
The build can be customized by setting SAGE_CONF_CONFIGURE_ARGS
.
(passagemath-venv) $ python3 -m pip install -v passagemath-conf
After a successful installation, a wheelhouse provides various Python packages. You can list the wheels using the command:
(passagemath-venv) $ ls $(sage-config SAGE_SPKG_WHEELS)
If this gives an error saying that sage-config
is not found, check any messages
that the pip install
command may have printed. You may need to adjust your PATH
,
for example by:
(passagemath-venv) $ export PATH="$(python3 -c 'import sysconfig; print(sysconfig.get_path("scripts", "posix_user"))'):$PATH"
(passagemath-venv) $ ls $(sage-config SAGE_SPKG_WHEELS)
Now arrange for the packages from the wheelhouse to be picked up:
(passagemath-venv) $ export PIP_FIND_LINKS=$(sage-config SAGE_SPKG_WHEELS)
(passagemath-venv) $ export PIP_PREFER_BINARY=1
(passagemath-venv) $ python3 -m pip install "passagemath-setup[autogen]"
Finally, install the Sage library from the package :
(passagemath-venv) $ python3 -m pip install --no-build-isolation -v passagemath-standard
The above instructions install the latest stable release of passagemath.
To install the latest development version instead, add the switch --pre
to all invocations of
python3 -m pip install
.
-
Optionally, decide on the installation prefix (
SAGE_LOCAL
):-
Traditionally, and by default, Sage is installed into the subdirectory hierarchy rooted at
SAGE_ROOT/local/
. -
This can be changed using
./configure --prefix=SAGE_LOCAL
, whereSAGE_LOCAL
is the desired installation prefix, which must be writable by the user.Unless you use this option in combination with
--enable-editable
, you can delete the entire Sage source tree after completing the build process. What is installed inSAGE_LOCAL
will be a self-contained installation of Sage. -
Note that in Sage's build process,
make
builds and installs (make install
is a no-op). Therefore the installation hierarchy must be writable by the user. -
See the Sage Installation Manual for options if you want to install into shared locations such as
/usr/local/
. Do not attempt to build Sage asroot
.
-
-
Optionally, review the configuration options, which includes many optional packages:
$ ./configure --help
Notable options for Sage developers are the following:
-
Use the option
--config-cache
to haveconfigure
keep a disk cache of configuration values. This gives a nice speedup when trying out ticket branches that make package upgrades, which involves automatic re-runs of the configuration step. -
Use the option
--enable-ccache
to have Sage install and use the optional packageccache
, which is preconfigured to keep a disk cache of object files created from source files. This can give a great speedup when switching between different branches, at the expense of disk space use.
-
-
Optional, but highly recommended: Set some environment variables to customize the build.
For example, the
MAKE
environment variable controls whether to run several jobs in parallel. On a machine with 4 processors, say, typingexport MAKE="make -j4"
will configure the build script to perform a parallel compilation of Sage using 4 jobs. On some powerful machines, you might even consider-j16
, as building with more jobs than CPU cores can speed things up further.To reduce the terminal output during the build, type
export V=0
. (V
stands for "verbosity".)Some environment variables deserve a special mention:
CC
,CXX
andFC
. These variables defining your compilers can be set at configuration time and their values will be recorded for further use at build time and runtime.For an in-depth discussion of more environment variables for building Sage, see the installation guide.
-
Type
./configure
, followed by any options that you wish to use. For example, to build Sage withgf2x
package supplied by Sage, use./configure --with-system-gf2x=no
.At the end of a successful
./configure
run, you may see messages recommending to install extra system packages using your package manager.For a large list of Sage packages, Sage is able to detect whether an installed system package is suitable for use with Sage; in that case, Sage will not build another copy from source.
Sometimes, the messages will recommend to install packages that are already installed on your system. See the earlier configure messages or the file
config.log
for explanation. Also, the messages may recommend to install packages that are actually not available; only the most recent releases of your distribution will have all of these recommended packages. -
Optional: If you choose to install the additional system packages, a re-run of
./configure
will test whether the versions installed are usable for Sage; if they are, this will reduce the compilation time and disk space needed by Sage. The usage of packages may be adjusted by./configure
parameters (check again the output of./configure --help
). -
Type
make build
. That's it! Everything is automatic and non-interactive.If you followed the above instructions, in particular regarding the installation of system packages recommended by the output of
./configure
(step 10), and regarding the parallel build (step 11), building Sage takes less than one hour on a modern computer. (Otherwise, it can take much longer.)The build should work fine on all fully supported platforms. If it does not, we want to know!
-
Type
./sage
to try it out. In Sage, try for example2 + 2
,plot(x^2)
,plot3d(lambda x, y: x*y, (-1, 1), (-1, 1))
to test a simple computation and plotting in 2D and 3D. Type Ctrl+D orquit
to quit Sage. -
Optional: Type
make ptestlong
to test all examples in the documentation (over 200,000 lines of input!) -- this takes from 10 minutes to several hours. Don't get too disturbed if there are 2 to 3 failures, but always feel free to email the section oflogs/ptestlong.log
that contains errors to the sage-support mailing list. If there are numerous failures, there was a serious problem with your build. -
Optional: If you want to build a local HTML version of the documentation, run
make doc-html
. After a successful build, it resides in the directorylocal/share/doc/sage/html/
. You may want to bookmark it in your browser. -
Optional: If you want to build the PDF version of the documentation, run
make doc-pdf
(this requires LaTeX to be installed). -
Optional: Install optional packages of interest to you: get a list by typing
./sage --optional
or by visiting the packages documentation page. -
Optional: Create a symlink to the installed
sage
script in a directory in yourPATH
, for example/usr/local/bin/
. This will allow you to start Sage by typingsage
from anywhere rather than having to either type the full path or navigate to the Sage directory and type./sage
. This can be done by running:$ sudo ln -s $(./sage -sh -c 'ls $SAGE_ROOT/venv/bin/sage') /usr/local/bin
- Optional: Set up SageMath as a Jupyter kernel in an existing Jupyter notebook or JupyterLab installation, as described in the section Launching SageMath in the Sage Installation Guide.
Simplified directory layout:
SAGE_ROOT Root directory (create by git clone)
├── COPYING.txt Copyright information
├── pkgs Source trees of Python distribution packages
│ ├── sage-conf
│ │ ├── sage_conf.py
│ │ └── setup.py
│ ├── sage-docbuild
│ │ ├── sage_docbuild/
│ │ └── setup.py
│ ├── sage-setup
│ │ ├── sage_setup/
│ │ └── setup.py
│ ├── sage-sws2rst
│ │ ├── sage_sws2rst/
│ │ └── setup.py
│ ...
│ └── sagemath-standard
│ ├── bin/
│ ├── sage -> ../../src/sage
│ └── setup.py
├── sage Script to start Sage
├── src Monolithic Sage library source tree
│ ├── bin/ Scripts that Sage uses internally
│ ├── doc/ Sage documentation sources
│ └── sage/ The Sage library source code
└── VERSION.txt
For more details see our Developer's Guide.