From f18b180e5222d98710692fa6ed659f2ff2ddb5d5 2016-08-28 15:14:49 From: kaushikanant Date: 2016-08-28 15:14:49 Subject: [PATCH] Merge pull request #2 from ipython/master pulling changes from current master --- diff --git a/IPython/__init__.py b/IPython/__init__.py index 6bb5ba7..c551eb2 100644 --- a/IPython/__init__.py +++ b/IPython/__init__.py @@ -22,17 +22,24 @@ from __future__ import absolute_import import os import sys -import warnings #----------------------------------------------------------------------------- # Setup everything #----------------------------------------------------------------------------- # Don't forget to also update setup.py when this changes! -v = sys.version_info -if v[:2] < (3,3): - raise ImportError('IPython requires Python version 3.3 or above.') -del v +if sys.version_info < (3,3): + raise ImportError( +""" +IPython 6.0+ does not support Python 2.6, 2.7, 3.0, 3.1, or 3.2. +When using Python 2.7, please install IPython 5.x LTS Long Term Support version. +Beginning with IPython 6.0, Python 3.3 and above is required. + +See IPython `README.rst` file for more information: + + https://github.com/ipython/ipython/blob/master/README.rst + +""") # Make it easy to import extensions - they are always directly on pythonpath. # Therefore, non-IPython modules can be added to extensions directory. @@ -143,4 +150,3 @@ def start_kernel(argv=None, **kwargs): """ from IPython.kernel.zmq.kernelapp import launch_new_instance return launch_new_instance(argv=argv, **kwargs) - diff --git a/IPython/core/builtin_trap.py b/IPython/core/builtin_trap.py index 909a555..b3c9fdf 100644 --- a/IPython/core/builtin_trap.py +++ b/IPython/core/builtin_trap.py @@ -52,17 +52,6 @@ class BuiltinTrap(Configurable): 'quit': HideBuiltin, 'get_ipython': self.shell.get_ipython, } - # Recursive reload function - try: - from IPython.lib import deepreload - if self.shell.deep_reload: - from warnings import warn - warn("Automatically replacing builtin `reload` by `deepreload.reload` is deprecated since IPython 4.0, please import `reload` explicitly from `IPython.lib.deepreload", DeprecationWarning) - self.auto_builtins['reload'] = deepreload._dreload - else: - self.auto_builtins['dreload']= deepreload._dreload - except ImportError: - pass def __enter__(self): if self._nested_level == 0: diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index dd12715..1072209 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -260,21 +260,6 @@ class InteractiveShell(SingletonConfigurable): help="Set the color scheme (NoColor, Neutral, Linux, or LightBG)." ).tag(config=True) debug = Bool(False).tag(config=True) - deep_reload = Bool(False, help= - """ - **Deprecated** - - Will be removed in IPython 6.0 - - Enable deep (recursive) reloading by default. IPython can use the - deep_reload module which reloads changes in modules recursively (it - replaces the reload() function, so you don't need to change anything to - use it). `deep_reload` forces a full reload of modules whose code may - have changed, which the default reload() function does not. When - deep_reload is off, IPython will use the normal reload(), but - deep_reload will still be available as dreload(). - """ - ).tag(config=True) disable_failing_post_execute = Bool(False, help="Don't call post-execute functions that have failed in the past." ).tag(config=True) diff --git a/IPython/core/tests/test_paths.py b/IPython/core/tests/test_paths.py index d0a8768..20257ba 100644 --- a/IPython/core/tests/test_paths.py +++ b/IPython/core/tests/test_paths.py @@ -17,7 +17,7 @@ from IPython import paths from IPython.testing.decorators import skip_win32 from IPython.utils.tempdir import TemporaryDirectory -TMP_TEST_DIR = tempfile.mkdtemp() +TMP_TEST_DIR = os.path.realpath(tempfile.mkdtemp()) HOME_TEST_DIR = os.path.join(TMP_TEST_DIR, "home_test_dir") XDG_TEST_DIR = os.path.join(HOME_TEST_DIR, "xdg_test_dir") XDG_CACHE_DIR = os.path.join(HOME_TEST_DIR, "xdg_cache_dir") diff --git a/IPython/lib/deepreload.py b/IPython/lib/deepreload.py index 521acf3..9795eac 100644 --- a/IPython/lib/deepreload.py +++ b/IPython/lib/deepreload.py @@ -341,21 +341,3 @@ def reload(module, exclude=('sys', 'os.path', builtin_mod_name, '__main__')): return deep_reload_hook(module) finally: found_now = {} - - -def _dreload(module, **kwargs): - """ - **deprecated** - - import reload explicitly from `IPython.lib.deepreload` to use it - - """ - # this was marked as deprecated and for 5.0 removal, but - # IPython.core_builtin_trap have a Deprecation warning for 6.0, so cannot - # remove that now. - warn(""" -injecting `dreload` in interactive namespace is deprecated since IPython 4.0. -Please import `reload` explicitly from `IPython.lib.deepreload`. -""", DeprecationWarning, stacklevel=2) - reload(module, **kwargs) - diff --git a/IPython/terminal/interactiveshell.py b/IPython/terminal/interactiveshell.py index 7387822..5ad8d2f 100644 --- a/IPython/terminal/interactiveshell.py +++ b/IPython/terminal/interactiveshell.py @@ -8,10 +8,10 @@ from warnings import warn from IPython.core.interactiveshell import InteractiveShell, InteractiveShellABC from IPython.utils import io -from IPython.utils.py3compat import PY3, cast_unicode_py2, input +from IPython.utils.py3compat import PY3, cast_unicode_py2, input, string_types from IPython.utils.terminal import toggle_set_term_title, set_term_title from IPython.utils.process import abbrev_cwd -from traitlets import Bool, Unicode, Dict, Integer, observe, Instance, Type, default, Enum +from traitlets import Bool, Unicode, Dict, Integer, observe, Instance, Type, default, Enum, Union from prompt_toolkit.enums import DEFAULT_BUFFER, EditingMode from prompt_toolkit.filters import (HasFocus, Condition, IsDone) @@ -23,6 +23,7 @@ from prompt_toolkit.layout.processors import ConditionalProcessor, HighlightMatc from prompt_toolkit.styles import PygmentsStyle, DynamicStyle from pygments.styles import get_style_by_name, get_all_styles +from pygments.style import Style from pygments.token import Token from .debugger import TerminalPdb, Pdb @@ -132,8 +133,9 @@ class TerminalInteractiveShell(InteractiveShell): help="Enable mouse support in the prompt" ).tag(config=True) - highlighting_style = Unicode('legacy', - help="The name of a Pygments style to use for syntax highlighting: \n %s" % ', '.join(get_all_styles()) + highlighting_style = Union([Unicode('legacy'), Type(klass=Style)], + help="""The name or class of a Pygments style to use for syntax + highlighting: \n %s""" % ', '.join(get_all_styles()) ).tag(config=True) @@ -143,7 +145,7 @@ class TerminalInteractiveShell(InteractiveShell): self.refresh_style() def refresh_style(self): - self._style = self._make_style_from_name(self.highlighting_style) + self._style = self._make_style_from_name_or_cls(self.highlighting_style) highlighting_style_overrides = Dict( @@ -229,7 +231,7 @@ class TerminalInteractiveShell(InteractiveShell): if cell and (cell != last_cell): history.append(cell) - self._style = self._make_style_from_name(self.highlighting_style) + self._style = self._make_style_from_name_or_cls(self.highlighting_style) style = DynamicStyle(lambda: self._style) editing_mode = getattr(EditingMode, self.editing_mode.upper()) @@ -249,14 +251,14 @@ class TerminalInteractiveShell(InteractiveShell): self._pt_app, eventloop=self._eventloop, output=create_output(true_color=self.true_color)) - def _make_style_from_name(self, name): + def _make_style_from_name_or_cls(self, name_or_cls): """ Small wrapper that make an IPython compatible style from a style name We need that to add style for prompt ... etc. """ style_overrides = {} - if name == 'legacy': + if name_or_cls == 'legacy': legacy = self.colors.lower() if legacy == 'linux': style_cls = get_style_by_name('monokai') @@ -287,7 +289,10 @@ class TerminalInteractiveShell(InteractiveShell): else : raise ValueError('Got unknown colors: ', legacy) else : - style_cls = get_style_by_name(name) + if isinstance(name_or_cls, string_types): + style_cls = get_style_by_name(name_or_cls) + else: + style_cls = name_or_cls style_overrides = { Token.Prompt: '#009900', Token.PromptNum: '#00ff00 bold', diff --git a/IPython/terminal/prompts.py b/IPython/terminal/prompts.py index 732a711..f52862b 100644 --- a/IPython/terminal/prompts.py +++ b/IPython/terminal/prompts.py @@ -71,4 +71,4 @@ class RichPromptDisplayHook(DisplayHook): if self.shell.pt_cli: self.shell.pt_cli.print_tokens(tokens) else: - print(*(s for t, s in tokens), sep='') + sys.stdout.write(''.join(s for t, s in tokens)) diff --git a/IPython/utils/warn.py b/IPython/utils/warn.py deleted file mode 100644 index dd48522..0000000 --- a/IPython/utils/warn.py +++ /dev/null @@ -1,65 +0,0 @@ -# encoding: utf-8 -""" -Utilities for warnings. Shoudn't we just use the built in warnings module. -""" - -# Copyright (c) IPython Development Team. -# Distributed under the terms of the Modified BSD License. - -from __future__ import print_function - -import sys -import warnings - -warnings.warn("The module IPython.utils.warn is deprecated since IPython 4.0, use the standard warnings module instead", DeprecationWarning) - -def warn(msg,level=2,exit_val=1): - """Deprecated - - Standard warning printer. Gives formatting consistency. - - Output is sent to sys.stderr. - - Options: - - -level(2): allows finer control: - 0 -> Do nothing, dummy function. - 1 -> Print message. - 2 -> Print 'WARNING:' + message. (Default level). - 3 -> Print 'ERROR:' + message. - 4 -> Print 'FATAL ERROR:' + message and trigger a sys.exit(exit_val). - - -exit_val (1): exit value returned by sys.exit() for a level 4 - warning. Ignored for all other levels.""" - - warnings.warn("The module IPython.utils.warn is deprecated since IPython 4.0, use the standard warnings module instead", DeprecationWarning) - if level>0: - header = ['','','WARNING: ','ERROR: ','FATAL ERROR: '] - print(header[level], msg, sep='', file=sys.stderr) - if level == 4: - print('Exiting.\n', file=sys.stderr) - sys.exit(exit_val) - - -def info(msg): - """Deprecated - - Equivalent to warn(msg,level=1).""" - - warn(msg,level=1) - - -def error(msg): - """Deprecated - - Equivalent to warn(msg,level=3).""" - - warn(msg,level=3) - - -def fatal(msg,exit_val=1): - """Deprecated - - Equivalent to warn(msg,exit_val=exit_val,level=4).""" - - warn(msg,exit_val=exit_val,level=4) diff --git a/README.rst b/README.rst index d821ae5..bd435ee 100644 --- a/README.rst +++ b/README.rst @@ -19,7 +19,7 @@ Overview ======== Welcome to IPython. Our full documentation is available on `ipython.readthedocs.io -`_ and contain information on how to install, use +`_ and contains information on how to install, use and contribute to the project. Officially, IPython requires Python version 3.3 and above. @@ -32,20 +32,56 @@ if you want to use these. -Developement and Instant runnimg -================================ +Development and Instant running +=============================== You can find the latest version of the development documentation on `readthedocs -`_. +`_. You can run IPython from this directory without even installing it system-wide by typing at the terminal:: - + $ python -m IPython -Or see the `developement installation docs +Or see the `development installation docs `_ -for the latest revision on read the docs. +for the latest revision on read the docs. Documentation and installation instructions for older version of IPython can be found on the `IPython website `_ + + + +IPython requires Python version 3 or above +========================================== + +Starting with version 6.0, IPython does not support Python 2.7, 3.0, 3.1, or +3.2. + +For a version compatible with Python 2.7, please install the 5.x LTS Long Term +Support version. + +If you are encountering this error message you are likely trying to install or +use IPython from source. You need to checkout the remote 5.x branch. If you are +using git the following should work: + + $ git fetch origin + $ git checkout -b origin/5.x + +If you encounter this error message with a regular install of IPython, then you +likely need to update your package manager, for example if you are using `pip` +check the version of pip with + + $ pip --version + +You will need to update pip to the version 8.2 or greater. If you are not using +pip, please inquiry with the maintainers of the package for your package +manager. + +For more information see one of our blog posts: + + http://blog.jupyter.org/2016/07/08/ipython-5-0-released/ + +As well as the following Pull-Request for discussion: + + https://github.com/ipython/ipython/pull/9900 diff --git a/docs/source/config/details.rst b/docs/source/config/details.rst index d139296..841acab 100644 --- a/docs/source/config/details.rst +++ b/docs/source/config/details.rst @@ -101,9 +101,10 @@ is set to ``'legacy'``. It has four case-insensitive values: should be legible on either dark or light terminal backgrounds. *linux* is optimised for dark backgrounds and *lightbg* for light ones. -``TerminalInteractiveShell.highlighting_style`` determines prompt colours and syntax -highlighting. It takes the name of a Pygments style as a string, or the special -value ``'legacy'`` to pick a style in accordance with ``InteractiveShell.colors``. +``TerminalInteractiveShell.highlighting_style`` determines prompt colours and +syntax highlighting. It takes the name (as a string) or class (as a subclass of +``pygments.style.Style``) of a Pygments style, or the special value ``'legacy'`` +to pick a style in accordance with ``InteractiveShell.colors``. You can see the Pygments styles available on your system by running:: diff --git a/docs/source/whatsnew/pr/incompat-no-dreload.rst b/docs/source/whatsnew/pr/incompat-no-dreload.rst new file mode 100644 index 0000000..8921082 --- /dev/null +++ b/docs/source/whatsnew/pr/incompat-no-dreload.rst @@ -0,0 +1,3 @@ +The `--deep-reload` flag and the corresponding options to inject `dreload` or +`reload` into the interactive namespace have been removed. You have to +explicitly import `reload` from `IPython.lib.deepreload` to use it. diff --git a/docs/source/whatsnew/pr/removed-Ipython-utils-warn.rst b/docs/source/whatsnew/pr/removed-Ipython-utils-warn.rst new file mode 100644 index 0000000..faf055f --- /dev/null +++ b/docs/source/whatsnew/pr/removed-Ipython-utils-warn.rst @@ -0,0 +1,2 @@ +IPython.utils.warn was deprecated in IPython 4.0, and has now been removed. +instead of Ipython.utils.warn inbuilt warning module is used. diff --git a/setup.py b/setup.py index f03db18..5d70626 100755 --- a/setup.py +++ b/setup.py @@ -26,9 +26,18 @@ import sys # This check is also made in IPython/__init__, don't forget to update both when # changing Python version requirements. -v = sys.version_info -if v[:2] < (3,3): - error = "ERROR: IPython requires Python version 3.3 or above." +if sys.version_info < (3,3): + error = """ +IPython 6.0+ does not support Python 2.6, 2.7, 3.0, 3.1, or 3.2. +When using Python 2.7, please install IPython 5.x LTS Long Term Support version. +Beginning with IPython 6.0, Python 3.3 and above is required. + +See IPython `README.rst` file for more information: + + https://github.com/ipython/ipython/blob/master/README.rst + +""" + print(error, file=sys.stderr) sys.exit(1)