Note

The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.

SageMath

From Funtoo
Jump to navigation Jump to search

SageMath is mathematical software with features covering many aspects of mathematics, including algebra, combinatorics, numerical mathematics, number theory, and calculus.

http://www.sagemath.org

Screenshot from SageMath

Installation

SageMath ebuilds are not present in the Funtoo portage tree. Instead these are available through separate overlays (repositories). To install SageMath on Funtoo Linux the overlay sage-on-gentoo is required, together with dependencies found in the overlay science.

Gentoo users will be familiar with the science overlay from Gentoo's Science Project (https://wiki.gentoo.org/wiki/Project:Science).

Install Required Overlays

Using layman

The easiest (fastest) method of installing the required overlays is via the package layman (app-portage/layman). Make sure layman is installed with USE=git and correctly configured. You may find a guide for layman at: http://www.gentoo.org/proj/en/overlays/userguide.xml

Update your layman list:

root # layman -L

Add the two overlays to Funtoo. Firstly is the science overlay (if not already installed):

root # layman -a science

Finally, add the SageMath overlay:

root # layman -a sage-on-gentoo

(Alternative) Using Portage Repositories

Users may add the science and sage-on-gentoo overlays as repositories in portage without the need for layman. Both overlays are available via https://github.com and portage is able to sync with them.

If not already present, first create a location for portage to store a local clone of the overlays.

root # mkdir /path/to/local-repos

Before configuring portage we will manually clone the two repositories into this local folder using dev-vcs/git. Starting with science for SageMath dependencies

root # cd /path/to/local-repos
root # git clone https://github.com/gentoo-science/sci.git science

and then sage-on-gentoo for the actual SageMath ebuilds

root # git clone https://github.com/cschwan/sage-on-gentoo.git

The final step is to configure portage to be able to use these additional repositories. This is achieved by adding appropriate configuration settings to files saved within /etc/portage/repos.conf/. (More information on repositories can be found by reading man portage).

Using your favorite text editor, create and save the following file in /etc/portage/repos.conf/ for the science repository.

   /etc/portage/repos.conf/science.conf
[science]
priority = 50
location = /path/to/local-repos/science
sync-type = git
sync-uri = https://github.com/gentoo-science/sci.git
auto-sync = Yes

Now repeat the previous step for a second file in /etc/portage/repos.conf/ corresponding to the sage-on-gentoo repository.

   /etc/portage/repos.conf/sage.conf
[sage-on-gentoo]
priority = 50
location = /path/to/local-repos/sage-on-gentoo
sync-type = git
sync-uri = https://github.com/cschwan/sage-on-gentoo.git
auto-sync = Yes
   Important

The sage-on-gentoo repository has the repo_name 'sage-on-gentoo'. Setting the name in this .conf file to something else (e.g. "[sagemath]") will cause portage to complain.

If these previous steps are successful, portage will be able to access and update ebuilds within these two repositories. Initiate these repositories by simply running

root # emerge --sync

Apply Required package.use and package.unmask Settings

   Note

This section favors /etc/portage/package.use and /etc/portage/package.unmask being directories instead of files which is a common case. Portage allows these to be directories and will processes the files contained within as if one single package.use or package.unmask file.

Before users must manually unmask dependencies and apply per-package USE flags required by SageMath. Fortunately the required settings are available in ready-made files shipped with the sage-on-gentoo overlay. Three files are required:

  • sage-on-gentoo/package.unmask/sage
  • sage-on-gentoo/package.use/sage
  • sage-on-gentoo/package.use/sage-unstable

To use these files permanently, we will create symbolic links within /etc/portage/. Updates made to these files within the sage-on-gentoo overlay will transfer to your system with each emerge --sync.

The default directory for layman overlays, if not set manually, is /var/lib/layman. If a portage repository was used instead of layman, use the appropriate /path/to/local-repo. For the layman example we will create a symbolic links for the package.unmask file:

root # ln -s /var/lib/layman/sage-on-gentoo/package.unmask/sage  /etc/portage/package.unmask/sage

Similarly create a symbolic link for each of the two package.use files:

root # ln -s /var/lib/layman/sage-on-gentoo/package.use/sage  /etc/portage/package.use/sage
root # ln -s /var/lib/layman/sage-on-gentoo/package.use/sage-unstable /etc/portage/package.use/sage-unstable

Installing SageMath

root # emerge -va sci-mathematics/sage

Please, note that this will pull in a lot of dependencies. If you can not proceed with this step (because of circular dependencies, missing USE-flags, and so on), report this behavior.

Testing your SageMath install

From the console:

root # sage

You will be asked to create password for SageMath's 'admin' account.

If successful, the command notebook() should launch the SageMath notebook in a new browser session (assuming that you are running X). The command quit() will exit SageMath.

Troubleshooting

USE flags

When attempting to merge SageMath, portage is likely to indicate that certain packages require per-package USE flags to be set.

Read each message carefully. When appling per-package USE flags, save these to a file inside of /etc/portage/package.use/ that is other than the two files that are symbolic links since changes could be overwritten with each overlay sync.

For example, add per-package use settings to a file /etc/portage/package.use/my-package-use.

Circular Dependencies when installing

This is an example of a circular dependency encountered when attempting to merge SageMath

root # emerge -pv sci-mathematics/sage

These are the packages that would be merged, in order:

Calculating dependencies... done!


[nomerge       ] sci-mathematics/sage-7.5.1-r1::sage-on-gentoo  USE="X doc-html sagenb -bliss -debug -doc-pdf -latex -libbraiding -libhomfly -modular_decomposition -testsuite" L10N="en -ca -de -fr -hu -it -ja -pt -ru -tr" PYTHON_TARGETS="python2_7"
[nomerge       ]  dev-python/ipython-5.3.0::gentoo  USE="notebook smp -doc -examples -matplotlib -mongodb -nbconvert -qt4 {-test} -wxwidgets" PYTHON_TARGETS="python2_7 python3_4 -python3_5 -python3_6"
[ebuild  N     ]   dev-python/ipywidgets-6.0.0-r1::sage-on-gentoo  USE="{-test}" PYTHON_TARGETS="python2_7 python3_4 -python3_5
-python3_6" 817 KiB
[ebuild  N     ]    dev-python/widgetsnbextension-2.0.0::gentoo  PYTHON_TARGETS="python2_7 python3_4 -python3_5 -python3_6" 558
KiB
[ebuild  N     ]   dev-python/ipyparallel-6.0.2::gentoo  USE="-doc {-test}" PYTHON_TARGETS="python2_7 python3_4 -python3_5 -python3_6" 2,312 KiB
[ebuild  N     ] sci-mathematics/sage-7.5.1-r1::sage-on-gentoo  USE="X doc-html sagenb -bliss -debug -doc-pdf -latex -libbraiding -libhomfly -modular_decomposition -testsuite" L10N="en -ca -de -fr -hu -it -ja -pt -ru -tr" PYTHON_TARGETS="python2_7" 20,944
KiB
[nomerge       ] dev-python/ipyparallel-6.0.2::gentoo  USE="-doc {-test}" PYTHON_TARGETS="python2_7 python3_4 -python3_5 -python3_6"
[ebuild  N     ]  dev-python/notebook-4.4.1::gentoo  USE="-doc {-test}" PYTHON_TARGETS="python2_7 python3_4 -python3_5 -python3_6" 10,135 KiB
[ebuild  N     ]   dev-python/ipykernel-4.5.2::gentoo  USE="{-test}" PYTHON_TARGETS="python2_7 python3_4 -python3_5 -python3_6"
87 KiB                                                                                                                                         
[ebuild  N     ]    dev-python/ipython-5.3.0::gentoo  USE="notebook smp -doc -examples -matplotlib -mongodb -nbconvert -qt4 {-test} -wxwidgets" PYTHON_TARGETS="python2_7 python3_4 -python3_5 -python3_6" 4,852 KiB                                                                          
                                                                                                                                               
Total: 7 packages (7 new), Size of downloads: 39,702 KiB                                                                                       
                                                                                                                                               
 * Error: circular dependencies:                                                                                                               
                                                                                                                                               
(dev-python/ipython-5.3.0:0/0::gentoo, ebuild scheduled for merge) depends on                                                                  
 (dev-python/notebook-4.4.1:0/0::gentoo, ebuild scheduled for merge) (runtime)                                                                 
  (dev-python/ipykernel-4.5.2:0/0::gentoo, ebuild scheduled for merge) (buildtime)                                                             
   (dev-python/ipython-5.3.0:0/0::gentoo, ebuild scheduled for merge) (buildtime)                                                              
                                                                                                                                               
 * Note that circular dependencies can often be avoided by temporarily                                                                         
 * disabling USE flags that trigger optional dependencies.

The issue here is with dev-python/ipython. A successful workaround is to first merge it separately with the 'notebook' USE flag disabled.

root # USE="-notebook" emerge --ask --oneshot --verbose dev-python/ipython

Now continue with the install of SageMath

root # emerge -va sci-mathematics/sage