[sagemath] 01/03: Add patch to work with ipython 5.

Tobias Hansen thansen at moszumanska.debian.org
Sat Jul 30 07:59:20 UTC 2016


This is an automated email from the git hooks/post-receive script.

thansen pushed a commit to branch master
in repository sagemath.

commit 75966208e35efefa68f439cbd1fa183b781690e1
Author: Tobias Hansen <thansen at debian.org>
Date:   Fri Jul 29 23:07:49 2016 +0000

    Add patch to work with ipython 5.
---
 debian/patches/series                  |   1 +
 debian/patches/version-ipython-5.patch | 118 +++++++++++++++++++++++++++++++++
 2 files changed, 119 insertions(+)

diff --git a/debian/patches/series b/debian/patches/series
index 6dda8c8..40a2bdc 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -12,6 +12,7 @@ fixsage-sphinx.patch
 version-python-2.7.11.patch
 version-ecm-7.patch
 version-linbox-1.4.patch
+version-ipython-5.patch
 
 # due to Debian's inherent differences with upstream;
 # we're unlikely to forward these upstream
diff --git a/debian/patches/version-ipython-5.patch b/debian/patches/version-ipython-5.patch
new file mode 100644
index 0000000..96806ea
--- /dev/null
+++ b/debian/patches/version-ipython-5.patch
@@ -0,0 +1,118 @@
+Description: Necessary changes to work with ipython 5.
+Origin: https://git.archlinux.org/svntogit/community.git/tree/trunk?h=packages/sagemath
+
+--- a/sage/src/sage/repl/interpreter.py
++++ b/sage/src/sage/repl/interpreter.py
+@@ -103,6 +103,7 @@
+ 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
+@@ -385,11 +386,6 @@
+ ###################################################################
+ 
+ DEFAULT_SAGE_CONFIG = Config(
+-    PromptManager = Config(
+-        in_template = 'sage: ',
+-        in2_template = '....: ',
+-        justify = False,
+-        out_template = ''),
+     TerminalIPythonApp = Config(
+         display_banner = False,
+         verbose_crash = True,
+@@ -397,6 +393,7 @@
+         shell_class = SageTerminalInteractiveShell,
+     ),
+     InteractiveShell = Config(
++        prompts_class = SagePrompts,
+         ast_node_interactivity = 'all',
+         colors = 'LightBG' if sys.stdout.isatty() else 'NoColor',
+         confirm_exit = False,
+@@ -630,13 +627,11 @@
+         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()
+--- /dev/null
++++ b/sage/src/sage/repl/prompts.py
+@@ -0,0 +1,67 @@
++r"""
++Sage Commandline Prompts
++"""
++
++#*****************************************************************************
++#       Copyright (C) 2016 Volker Braun <vbraun.name at 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, ''),
++        ]
++

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/sagemath.git



More information about the debian-science-commits mailing list