Installing the Sage IPython Kernel

Kernels have to register themselves with IPython so that they appear in the IPython notebook’s kernel drop-down. This is done by SageKernelSpec.

class sage.repl.ipython_kernel.install.SageKernelSpec

Bases: object

Utility to manage Sage kernels

EXAMPLES:

sage: from sage.repl.ipython_kernel.install import SageKernelSpec
sage: spec = SageKernelSpec()
sage: spec._display_name    # random output
'Sage 6.6.beta2'
classmethod identifier()

Internal identifier for the Sage kernel

OUTPUT:

String.

EXAMPLES:

sage: from sage.repl.ipython_kernel.install import SageKernelSpec
sage: SageKernelSpec.identifier()    # random output
'sage_6_6_beta3'
sage: SageKernelSpec.identifier().startswith('sage_')
True
kernel_spec()

Return the kernel spec as Python dictionary

OUTPUT:

A dictionary. See the IPython documentation for details.

EXAMPLES:

sage: from sage.repl.ipython_kernel.install import SageKernelSpec
sage: spec = SageKernelSpec()
sage: spec.kernel_spec()
{'argv': ..., 'display_name': 'Sage ...'}

Symlink src to dst

This is not an atomic operation.

Already-existing symlinks will be deleted, already existing non-empty directories will be kept.

EXAMPLES:

sage: from sage.repl.ipython_kernel.install import SageKernelSpec
sage: spec = SageKernelSpec()
sage: path = tmp_dir()
sage: spec.symlink(os.path.join(path, 'a'), os.path.join(path, 'b'))
sage: os.listdir(path)
['b']
classmethod update()

Configure the IPython notebook for the Sage kernel

This method does everything necessary to use the Sage kernel, you should never need to call any of the other methods directly.

EXAMPLES:

sage: from sage.repl.ipython_kernel.install import SageKernelSpec
sage: spec = SageKernelSpec()
sage: spec.update()
use_local_jsmol()
use_local_mathjax()

Symlink Sage’s Mathjax Install to the IPython notebook.

EXAMPLES:

sage: from sage.repl.ipython_kernel.install import SageKernelSpec
sage: from IPython.utils.path import get_ipython_dir
sage: spec = SageKernelSpec()
sage: spec.use_local_mathjax()
sage: ipython_dir = get_ipython_dir()
sage: mathjax = os.path.join(ipython_dir, 'nbextensions', 'mathjax')
sage: os.path.exists(mathjax)
True
sage.repl.ipython_kernel.install.have_prerequisites()

Check that we have all prerequisites to run the IPython notebook.

In particular, the IPython notebook requires OpenSSL whether or not you are using https. See trac:17318.

OUTPUT:

Boolean.

EXAMPLES:

sage: from sage.repl.ipython_kernel.install import have_prerequisites
sage: have_prerequisites() in [True, False]
True