Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork407
This repository used to be the user-facing mirror of the Sage source tree. As Sage development migrated on 2023-02-01 fromhttps://trac.sagemath.org/ to our new repository on GitHub,https://github.com/sagemath/sage, we have renamed and archived this repository.
License
sagemath/sage-archive-2023-02-01
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
"Creating a Viable Open Source Alternative toMagma, Maple, Mathematica, and MATLAB"
Copyright (C) 2005-2022 The Sage Development Team
The Sage Library is free software released under theGNU General Public Licence GPLv2+, and included packageshavecompatible software licenses.Over 800 peoplehave contributed code to Sage. In many cases, documentationfor modules and functions list the authors.
TheSage Installation Guideprovides a decision tree that guides you to the type of installationthat will work best for you. This includes building from source,obtaining Sage from a package manager, using a container image, or usingSage in the cloud.
This README contains self-contained instructions for building Sage from source.It assumes that you have already cloned the git repository or downloaded thesources in the formof a tarball.
If you have questions or encounter problems, please do not hesitateto email thesage-support mailing listor ask on theAsk Sage questions and answers site.
Sage attempts to support all major Linux distributions, recent versions ofmacOS, and Windows (using Windows Subsystem for Linux orvirtualization).
Detailed information on supported platforms for a specific version of Sagecan be found in the section "Availability and installation help" of therelease tour for this version.
We highly appreciate contributions to Sage that fix portability bugsand help port Sage to new platforms; let us know at thesage-develmailing list.
The preferred way to run Sage on Windows is using theWindows Subsystem forLinux, which allowsyou to install a standard Linux distribution such as Ubuntu withinyour Windows. Then all instructions for installation in Linux apply.
As an alternative, you can also run Linux on Windows using Docker (seeabove) or other virtualization solutions.
If your Mac uses the Apple Silicon (M1, arm64) architecture:
If you set up your Mac by transfering files from an older Mac, make surethat the directory
/usr/local
does not contain an old copy of Homebrew(or other software) for the x86_64 architecture that you may have copiedover. Note that Homebrew for the M1 is installed in/opt/homebrew
, not/usr/local
.If you wish to use conda, please see thesection onconda in the SageInstallation Manual for guidance.
Otherwise, using Homebrew ("the missing package manager for macOS") fromhttps://brew.sh/ required because it provides a version of
gfortran
withnecessary changes for this platform that are not in a released upstreamversion of GCC. (Thegfortran
package that comes with the Sagedistribution is not suitable for the M1/M2.)
If your Mac uses the Intel (x86_64) architecture:
If you wish to use conda, please see thesection onconda in the SageInstallation Manual for guidance.
Otherwise, we strongly recommend to use Homebrew ("the missing packagemanager for macOS") fromhttps://brew.sh/, which provides the
gfortran
compiler and many libraries.Otherwise, if you do not wish to install Homebrew, you will need to installthe latest version of Xcode Command Line Tools. Open a terminal window andrun
xcode-select --install
; then click "Install" in the pop-up window. Ifthe Xcode Command Line Tools are already installed, you may want to check ifthey need to be updated by typingsoftwareupdate -l
.
Like many other software packages, Sage is built from source using./configure
, followed bymake
. However, we strongly recommend toread the following step-by-step instructions for building Sage.
The instructions cover all of Linux, macOS, and WSL.
More details, providing a background for these instructions, can be foundin thesection "Install from Source Code".in the Installation Guide.
Decide on the source/build directory (
SAGE_ROOT
):On personal computers, any subdirectory of your :envvar:
HOME
directory should do.For example, you could use
SAGE_ROOT=~/sage/sage-x.y
, which wewill use as the running example below, wherex.y
is thecurrent Sage version.You need at least 10 GB of free disk space.
The full path to the source directory must containno spaces.
After starting the build, you cannot move the source/builddirectory without breaking things.
You may want to avoid slow filesystems such asnetwork file systems (NFS)and the like.
[macOS] macOS allows changing directories without using exact capitalization.Beware of this convenience when compiling for macOS. Ignoring exactcapitalization when changing into :envvar:
SAGE_ROOT
can lead to builderrors for dependencies requiring exact capitalization in path names.
Download/unpack or clone the sources.
Go tohttps://www.sagemath.org/download-source.html, select a mirror,and download the file :file:
sage-x.y.tar.gz
.This compressed archive file contains the source code for Sage andthe source for all programs on which Sage depends.
After downloading the source tarball
sage-x.y.tar.gz
into~/sage/
:$ cd ~/sage/ $ tar xf sage-x.y.tar.gz # adapt x.y; takes a while
This creates the subdirectory
sage-x.y
. Now change into it:$ cd sage-x.y/ # adapt x.y
[Git] Alternatively, and required for Sage development, clone the Sagegit repository:
$ ORIG=https://github.com/sagemath/sage.git $ git clone -c core.symlinks=true --branch develop --tags $ORIG
This will create the directory
sage
. (See the sectionSetting up gitand the following sections in the Sage Developer's Guidefor more information.)Change into it and pick the branch you need, typicallythe latest development branch:
$ cd sage $ git checkout develop
[Windows] The Sage source tree contains symbolic links, and thebuild will not work if Windows line endings rather than UNIXline endings are used.
Therefore it is crucial that you unpack the source tree from theWSL
bash
using the WSLtar
utility and not using otherWindows tools (including mingw). Likewise, when usinggit
, itis recommended (but not necessary) to use the WSL version ofgit
.
[Linux, WSL] Install the required minimal build prerequisites.
Compilers:
gcc
,gfortran
,g++
(GCC 8.x to 12.x and recentversions of Clang (LLVM) are supported).Seebuild/pkgs/gcc/SPKG.rst andbuild/pkgs/gfortran/SPKG.rstfor a discussion of suitable compilers.Build tools: GNU
make
, GNUm4
,perl
(includingExtUtils::MakeMaker
),ranlib
,git
,tar
,bc
.Seebuild/pkgs/_prereq/SPKG.rst formore details.Python 3.4 or later, or Python 2.7, a full installation including
urllib
; but ideally version 3.8.x, 3.9.x, or 3.10.x, whichwill avoid having to build Sage's own copy of Python 3.Seebuild/pkgs/python3/SPKG.rstfor more details.
We have collected lists of system packages that provide these buildprerequisites. See, in the folderbuild/pkgs/_prereq/distros,the filesarch.txt,debian.txt(also for Ubuntu, Linux Mint, etc.),fedora.txt(also for Red Hat, CentOS),opensuse.txt,slackware.txt, andvoid.txt, or visithttps://doc.sagemath.org/html/en/reference/spkg/_prereq.html#spkg-prereq
[Git] If you plan to do Sage development or otherwise work with ticket branchesand not only releases, install the bootstrapping prerequisites. See thefiles in the folderbuild/pkgs/_bootstrap/distros, orvisithttps://doc.sagemath.org/html/en/reference/spkg/_bootstrap.html#spkg-bootstrap
[Git] If you cloned the Sage repository using
git
, bootstrap thesource tree using the following command:$ make configure
(If the bootstrapping prerequisites are not installed, this command willdownload a package providing pre-built bootstrap output instead.)
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 variablesthat Sage should not use for its own build. In particular, removeitems 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 toconfusing 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/sbin/:/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-onlypackages) available for the build. Run it once to apply thesuggestions for the current terminal session. You may need torepeat this command before you rebuild Sage from a new terminalsession, or after installing additional homebrew packages. (Youcan also add it to your shell profile so that it gets runautomatically in all future sessions.)
Optionally, decide on the installation prefix (
SAGE_LOCAL
):Traditionally, and by default, Sage is installed into thesubdirectory hierarchy rooted at
SAGE_ROOT/local/
.This can be changed using
./configure --prefix=SAGE_LOCAL
,whereSAGE_LOCAL
is the desired installation prefix, whichmust be writable by the user.If you use this option in combination with
--disable-editable
,you can delete the entire Sage source tree after completingthe build process. What is installed inSAGE_LOCAL
will bea self-contained installation of Sage.Note that in Sage's build process,
make
buildsandinstalls (make install
is a no-op). Therefore theinstallation hierarchy must be writable by the user.See the installation manual for options if you want toinstall into shared locations such as
/usr/local/
.Do not attempt to build Sage asroot
.
Optional: It is recommended that you have both LaTeX andthe ImageMagick tools (e.g. the "convert" command) installedsince some plotting functionality benefits from them.
Optionally, review the configuration options, which includesmany optional packages:
$ ./configure --help
A notable option for Sage developers is the following:
- Use
./configure --enable-download-from-upstream-url
to allowdownloading packages from their upstream URL if they cannot (yet) befound on the Sage mirrors. This is useful for trying out ticket branchesthat make package upgrades.
- Use
Optional, but highly recommended: Set some environment variables tocustomize the build.
For example, the
MAKE
environment variable controls whether torun several jobs in parallel. On a machine with 4 processors, say,typingexport MAKE="make -j4"
will configure the build script toperform a parallel compilation of Sage using 4 jobs. On somepowerful machines, you might even consider-j16
, as building withmore 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 compilerscan be set at configuration time and their values will be recorded forfurther use at build time and runtime.For an in-depth discussion of more environment variables forbuilding Sage, seethe installationguide.
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 messagesrecommending to install extra system packages using your packagemanager.For a largelist of Sagepackages, Sage is able todetect whether an installed system package is suitable for use withSage; in that case, Sage will not build another copy from source.
Sometimes, the messages will recommend to install packages that arealready installed on your system. See the earlier configuremessages or the file
config.log
for explanation. Also, themessages may recommend to install packages that are actually notavailable; only the most recent releases of your distribution willhave 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 installedare usable for Sage; if they are, this will reduce the compilationtime and disk space needed by Sage. The usage of packages may beadjusted by./configure
parameters (check again the output of./configure --help
).Type
make
. That's it! Everything is automatic andnon-interactive.If you followed the above instructions, in particular regarding theinstallation of system packages recommended by the output of
./configure
(step 10), and regarding the parallel build (step 9),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 itdoes 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.TypeCtrl+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 toseveral hours. Don't get too disturbed if there are 2 to 3 failures,but always feel free to email the section oflogs/ptestlong.log
thatcontains errors to thesage-support mailing list.If there are numerous failures, there was a serious problem with your build.The HTML version of thedocumentationis built during the compilation process of Sage and resides in the directory
local/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 thepackages documentation page.Optional: Create a symlink to the installed
sage
script in adirectory in yourPATH
, for example/usr/local
. This willallow you to start Sage by typingsage
from anywhere rather thanhaving to either type the full path or navigate to the Sagedirectory 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 notebookor JupyterLab installation, as described insection"Launching SageMath"in the installation manual.
If you have problems building Sage, check the Sage Installation Guide,as well as the version-specific Sage Installation FAQ in theSage ReleaseTour corresponding to theversion that you are installing.
Please do not hesitate to ask for help in theSageMath forum or thesage-support mailinglist. TheTroubleshooting section in the Sage Installation Guideprovides instructions on what information to provide so that we can providehelp more effectively.
If you'd like to contribute to Sage, we strongly recommend that you read theDeveloper's Guide.
Sage has significant components written in the following languages:C/C++, Python, Cython, Common Lisp, Fortran, and a bit of Perl.
Simplified directory layout (only essential files/directories):
SAGE_ROOT Root directory (sage-x.y in Sage tarball)├── build│ └── pkgs Every package is a subdirectory here│ ├── 4ti2/│ …│ └── zlib/├── configure Top-level configure script├── 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├── local (SAGE_LOCAL) Installation hierarchy for non-Python packages│ ├── bin Executables│ ├── include C/C++ headers│ ├── lib Shared libraries, architecture-dependent data│ ├── share Databases, architecture-independent data, docs│ │ └── doc Viewable docs of Sage and of some components│ └── var│ ├── lib/sage│ │ ├── installed/│ │ │ Records of installed non-Python packages│ │ ├── scripts/ Scripts for uninstalling installed packages│ │ └── venv-python3.9 (SAGE_VENV)│ │ │ Installation hierarchy (virtual environment)│ │ │ for Python packages│ │ ├── bin/ Executables and installed scripts│ │ ├── lib/python3.9/site-packages/│ │ │ Python modules/packages are installed here│ │ └── var/lib/sage/│ │ └── wheels/│ │ Python wheels for all installed Python packages│ ││ └── tmp/sage/ Temporary files when building Sage├── logs│ ├── install.log Full install log│ └── pkgs Build logs of individual packages│ ├── alabaster-0.7.12.log│ …│ └── zlib-1.2.11.log├── m4 M4 macros for generating the configure script│ └── *.m4├── Makefile Running "make" uses this file├── prefix -> SAGE_LOCAL Convenience symlink to the installation tree├── README.md This file├── 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├── upstream Source tarballs of packages│ ├── Babel-2.9.1.tar.gz│ …│ └── zlib-1.2.11.tar.gz├── venv -> SAGE_VENV Convenience symlink to the virtual environment└── VERSION.txt
For more details seeour Developer's Guide.
This is a brief summary of the Sage software distribution's build system.There are two components to the full Sage system--the Sage Python libraryand its associated user interfaces, and the larger software distribution ofSage's main dependencies (for those dependencies not supplied by the user'ssystem).
Sage's Python library is built and installed using asetup.py
script as isstandard for Python packages (Sage'ssetup.py
is non-trivial, but notunusual).
Most of the rest of the build system is concerned with building all of Sage'sdependencies in the correct order in relation to each other. The dependenciesincluded by Sage are referred to as SPKGs (i.e. "Sage Packages") and are listedunderbuild/pkgs
.
The main entrypoint to Sage's build system is the top-levelMakefile
at theroot of the source tree. Unlike most normal projects that use autoconf (Sagedoes as well, as described below), thisMakefile
is not generated. Instead,it contains a few high-level targets and targets related to bootstrapping thesystem. Nonetheless, we still runmake <target>
from the root of the sourcetree--targets not explicitly defined in the top-levelMakefile
are passedthrough to another Makefile underbuild/make/Makefile
.
The latterbuild/make/Makefile
is generated by an autoconf-generatedconfigure
script, using the template inbuild/make/Makefile.in
. Thisincludes rules for building the Sage library itself (make sagelib
), and forbuilding and installing each of Sage's dependencies (e.g.make gf2x
).
Theconfigure
script itself, if it is not already built, can be generated byrunning thebootstrap
script (the latter requiresGNU autotools being installed).The top-levelMakefile
also takes care of this automatically.
To summarize, running a command likemake python3
at the top-level of thesource tree goes something like this:
make python3
- run
./bootstrap
ifconfigure
needs updating - run
./configure
with any previously configured options ifbuild/make/Makefile
needs updating - change directory into
build/make
and run theinstall
script--this islittle more than a front-end to runningmake -f build/make/Makefile python3
,which sets some necessary environment variables and logs some information build/make/Makefile
contains the actual rule for buildingpython3
; thisincludes building all ofpython3
's dependencies first (and theirdependencies, recursively); the actual package installation is performedwith thesage-spkg
program
It is not supported to move theSAGE_ROOT
orSAGE_LOCAL
directoryafter building Sage. If you do move the directories, you will have torunmake distclean
and build Sage again from scratch.
For a system-wide installation, you have to build Sage as a "normal" userand then as root you can change permissions. See theInstallation Guidefor further information.
Your local Sage install is almost exactly the same as any "developer"install. You can make changes to documentation, source, etc., and veryeasily package the complete results up for redistribution just like wedo.
To make a binary distribution with your currently installed packages,visitsagemath/binary-pkg.
To make your own source tarball of Sage, type:
$ make dist
The result is placed in the directory
dist/
.
All software included with Sage is copyrighted by the respective authorsand released under an open source license that isGPL version 3 orlater compatible. SeeCOPYING.txt for more details.
Sources are in unmodified (as far as possible) tarballs in theupstream/
directory. The remaining description, versioninformation, patches, and build scripts are in the accompanyingbuild/pkgs/<packagename>
directory. This directory ispart of the Sage git repository.
About
This repository used to be the user-facing mirror of the Sage source tree. As Sage development migrated on 2023-02-01 fromhttps://trac.sagemath.org/ to our new repository on GitHub,https://github.com/sagemath/sage, we have renamed and archived this repository.
Topics
Resources
License
Code of conduct
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.