Date: Saturday, July 16, 2016 @ 21:09:23 Author: arojas Revision: 183005
Port to ipython 5.0 Added: sagemath/trunk/sagemath-ipython5.patch Modified: sagemath/trunk/PKGBUILD -------------------------+ PKGBUILD | 9 ++- sagemath-ipython5.patch | 120 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+), 3 deletions(-) Modified: PKGBUILD =================================================================== --- PKGBUILD 2016-07-16 16:16:26 UTC (rev 183004) +++ PKGBUILD 2016-07-16 21:09:23 UTC (rev 183005) @@ -9,7 +9,7 @@ pkgname=sagemath pkgver=7.2 -pkgrel=6 +pkgrel=7 pkgdesc="Open Source Mathematics Software, free alternative to Magma, Maple, Mathematica, and Matlab" arch=(i686 x86_64) url="http://www.sagemath.org" @@ -35,7 +35,7 @@ provides=(sage-mathematics) source=("$pkgname-$pkgver.tar.gz::https://github.com/sagemath/sage/archive/$pkgver.tar.gz" anal.h env.patch paths.patch clean.patch skip-check.patch cython-sys-path.patch is-package-installed.patch package.patch - disable-fes.patch jupyter-path.patch test-optional.patch python-2.7.11.patch linbox-1.4.patch ecm-7.patch) + disable-fes.patch jupyter-path.patch test-optional.patch python-2.7.11.patch linbox-1.4.patch ecm-7.patch sagemath-ipython5.patch) md5sums=('2afeb8f75a33107fef5d509698c0eabc' 'a906a180d198186a39820b0a2f9a9c63' 'f6c62f0ccc168c5e6e3dd9d6f73f6389' @@ -50,7 +50,8 @@ 'cdcabd475b80afe0534a5621e972736e' 'ef927896f2071b442b1d07d7e69f5f3a' '9f1cef3e477bafebe2ad301db56db8a2' - '0c9a57d35de80c2cd418ebec912efbbb') + '0c9a57d35de80c2cd418ebec912efbbb' + '55e75afd249048a8718c4377c22afa52') prepare(){ cd sage-$pkgver @@ -92,6 +93,8 @@ patch -p0 -i ../disable-fes.patch # port to new givaro/fflas-ffpack/linbox http://trac.sagemath.org/ticket/17635 patch -p1 -i ../linbox-1.4.patch +# port to ipython 5.0 https://trac.sagemath.org/ticket/21006 + patch -p1 -i ../sagemath-ipython5.patch # replace is_package_installed usage http://trac.sagemath.org/ticket/20377 patch -p1 -i ../is-package-installed.patch Added: sagemath-ipython5.patch =================================================================== --- sagemath-ipython5.patch (rev 0) +++ sagemath-ipython5.patch 2016-07-16 21:09:23 UTC (rev 183005) @@ -0,0 +1,120 @@ +diff --git a/src/sage/repl/interpreter.py b/src/sage/repl/interpreter.py +index ef8724d..6896985 100644 +--- a/src/sage/repl/interpreter.py ++++ b/src/sage/repl/interpreter.py +@@ -103,6 +103,7 @@ import os + import re + import sys + from sage.repl.preparse import preparse ++from sage.repl.prompts import SagePrompts, InterfacePrompts + + from traitlets.config.loader import Config + from traitlets import Bool, Type +@@ -371,11 +372,6 @@ class SageTestShell(SageShellOverride, TerminalInteractiveShell): + ################################################################### + + DEFAULT_SAGE_CONFIG = Config( +- PromptManager = Config( +- in_template = 'sage: ', +- in2_template = '....: ', +- justify = False, +- out_template = ''), + TerminalIPythonApp = Config( + display_banner = False, + verbose_crash = True, +@@ -383,6 +379,7 @@ DEFAULT_SAGE_CONFIG = Config( + shell_class = SageTerminalInteractiveShell, + ), + InteractiveShell = Config( ++ prompts_class = SagePrompts, + ast_node_interactivity = 'all', + colors = 'LightBG' if sys.stdout.isatty() else 'NoColor', + confirm_exit = False, +@@ -616,13 +613,11 @@ def interface_shell_embed(interface): + cfg = copy.deepcopy(get_ipython().config) + except NameError: + cfg = copy.deepcopy(DEFAULT_SAGE_CONFIG) +- cfg.PromptManager['in_template'] = interface.name() + ': ' +- cfg.PromptManager['in2_template'] = len(interface.name())*'.' + ': ' +- + ipshell = InteractiveShellEmbed(config=cfg, + banner1='\n --> Switching to %s <--\n\n'%interface, + exit_msg = '\n --> Exiting back to Sage <--\n') + ipshell.interface = interface ++ ipshell.prompts = InterfacePrompts(interface.name()) + + while ipshell.prefilter_manager.transformers: + ipshell.prefilter_manager.transformers.pop() +diff --git a/src/sage/repl/prompts.py b/src/sage/repl/prompts.py +new file mode 100644 +index 0000000..69f8cdd +--- /dev/null ++++ b/src/sage/repl/prompts.py +@@ -0,0 +1,67 @@ ++r""" ++Sage Commandline Prompts ++""" ++ ++#***************************************************************************** ++# Copyright (C) 2016 Volker Braun <vbraun.n...@gmail.com> ++# ++# This program is free software: you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation, either version 2 of the License, or ++# (at your option) any later version. ++# http://www.gnu.org/licenses/ ++#***************************************************************************** ++ ++from pygments.token import Token ++from IPython.terminal.prompts import Prompts ++ ++ ++class SagePrompts(Prompts): ++ ++ def in_prompt_tokens(self, cli=None): ++ return [ ++ (Token.Prompt, 'sage: '), ++ ] ++ ++ def continuation_prompt_tokens(self, cli=None, width=None): ++ return [ ++ (Token.Prompt, '....: '), ++ ] ++ ++ def rewrite_prompt_tokens(self): ++ return [ ++ (Token.Prompt, '----> '), ++ ] ++ ++ def out_prompt_tokens(self): ++ return [ ++ (Token.OutPrompt, ''), ++ ] ++ ++ ++class InterfacePrompts(Prompts): ++ ++ def __init__(self, interface_name): ++ self.__name = interface_name ++ self.__width = len(interface_name) ++ ++ def in_prompt_tokens(self, cli=None): ++ return [ ++ (Token.Prompt, self.__name + ': '), ++ ] ++ ++ def continuation_prompt_tokens(self, cli=None, width=None): ++ return [ ++ (Token.Prompt, '.' * self.__width + ': '), ++ ] ++ ++ def rewrite_prompt_tokens(self): ++ return [ ++ (Token.Prompt, '-' * self.__width + '> '), ++ ] ++ ++ def out_prompt_tokens(self): ++ return [ ++ (Token.OutPrompt, ''), ++ ] ++