diff --git a/.travis.yml b/.travis.yml index ee8ec6b..d3ab063 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ before_install: - git clone --quiet --depth 1 https://github.com/minrk/travis-wheels travis-wheels - 'if [[ $GROUP != js* ]]; then COVERAGE="--coverage xml"; fi' install: - - pip install -f travis-wheels/wheelhouse file://$PWD#egg=ipython[all] coveralls + - pip install -f travis-wheels/wheelhouse -e file://$PWD#egg=ipython[all] coveralls before_script: - 'if [[ $GROUP == js* ]]; then python -m IPython.external.mathjax mathjax.zip; fi' script: diff --git a/IPython/frontend.py b/IPython/frontend.py index 5a47d77..f47b7b7 100644 --- a/IPython/frontend.py +++ b/IPython/frontend.py @@ -9,17 +9,9 @@ This will let code that was making `from IPython.frontend...` calls continue working, though a warning will be printed. """ -#----------------------------------------------------------------------------- -# Copyright (c) 2013, IPython Development Team. -# -# Distributed under the terms of the Modified BSD License. -# -# The full license is in the file COPYING.txt, distributed with this software. -#----------------------------------------------------------------------------- +# Copyright (c) IPython Development Team. +# Distributed under the terms of the Modified BSD License. -#----------------------------------------------------------------------------- -# Imports -#----------------------------------------------------------------------------- from __future__ import print_function # Stdlib @@ -30,47 +22,7 @@ from warnings import warn warn("The top-level `frontend` package has been deprecated. " "All its subpackages have been moved to the top `IPython` level.") -#----------------------------------------------------------------------------- -# Class declarations -#----------------------------------------------------------------------------- - -class ShimModule(types.ModuleType): - - def __init__(self, *args, **kwargs): - self._mirror = kwargs.pop("mirror") - super(ShimModule, self).__init__(*args, **kwargs) - - def __getattr__(self, key): - # Use the equivalent of import_item(name), see below - name = "%s.%s" % (self._mirror, key) - - # NOTE: the code below is copied *verbatim* from - # importstring.import_item. For some very strange reason that makes no - # sense to me, if we call it *as a function*, it doesn't work. This - # has something to do with the deep bowels of the import machinery and - # I couldn't find a way to make the code work as a standard function - # call. But at least since it's an unmodified copy of import_item, - # which is used extensively and has a test suite, we can be reasonably - # confident this is OK. If anyone finds how to call the function, all - # the below could be replaced simply with: - # - # from IPython.utils.importstring import import_item - # return import_item('MIRROR.' + key) - - parts = name.rsplit('.', 1) - if len(parts) == 2: - # called with 'foo.bar....' - package, obj = parts - module = __import__(package, fromlist=[obj]) - try: - pak = module.__dict__[obj] - except KeyError: - raise AttributeError(obj) - return pak - else: - # called with un-dotted string - return __import__(parts[0]) - +from IPython.utils.shimmodule import ShimModule # Unconditionally insert the shim into sys.modules so that further import calls # trigger the custom attribute access above diff --git a/IPython/qt.py b/IPython/qt.py new file mode 100644 index 0000000..bccdb4b --- /dev/null +++ b/IPython/qt.py @@ -0,0 +1,22 @@ +""" +Shim to maintain backwards compatibility with old IPython.qt imports. +""" +# Copyright (c) IPython Development Team. +# Distributed under the terms of the Modified BSD License. + +from __future__ import print_function + +# Stdlib +import sys +import types +from warnings import warn + +warn("The `IPython.qt` package has been deprecated. " + "You should import from jupyter_qtconsole instead.") + +from IPython.utils.shimmodule import ShimModule + +# Unconditionally insert the shim into sys.modules so that further import calls +# trigger the custom attribute access above + +sys.modules['IPython.qt'] = ShimModule('qt', mirror='jupyter_qtconsole') diff --git a/IPython/utils/shimmodule.py b/IPython/utils/shimmodule.py new file mode 100644 index 0000000..d9ac634 --- /dev/null +++ b/IPython/utils/shimmodule.py @@ -0,0 +1,43 @@ +"""A shim module for deprecated imports +""" +# Copyright (c) IPython Development Team. +# Distributed under the terms of the Modified BSD License. + +import types + +class ShimModule(types.ModuleType): + + def __init__(self, *args, **kwargs): + self._mirror = kwargs.pop("mirror") + super(ShimModule, self).__init__(*args, **kwargs) + + def __getattr__(self, key): + # Use the equivalent of import_item(name), see below + name = "%s.%s" % (self._mirror, key) + + # NOTE: the code below is copied *verbatim* from + # importstring.import_item. For some very strange reason that makes no + # sense to me, if we call it *as a function*, it doesn't work. This + # has something to do with the deep bowels of the import machinery and + # I couldn't find a way to make the code work as a standard function + # call. But at least since it's an unmodified copy of import_item, + # which is used extensively and has a test suite, we can be reasonably + # confident this is OK. If anyone finds how to call the function, all + # the below could be replaced simply with: + # + # from IPython.utils.importstring import import_item + # return import_item('MIRROR.' + key) + + parts = name.rsplit('.', 1) + if len(parts) == 2: + # called with 'foo.bar....' + package, obj = parts + module = __import__(package, fromlist=[obj]) + try: + pak = module.__dict__[obj] + except KeyError: + raise AttributeError(obj) + return pak + else: + # called with un-dotted string + return __import__(parts[0]) diff --git a/IPython/qt/__init__.py b/jupyter_qtconsole/__init__.py similarity index 100% rename from IPython/qt/__init__.py rename to jupyter_qtconsole/__init__.py diff --git a/IPython/qt/base_frontend_mixin.py b/jupyter_qtconsole/base_frontend_mixin.py similarity index 100% rename from IPython/qt/base_frontend_mixin.py rename to jupyter_qtconsole/base_frontend_mixin.py diff --git a/IPython/qt/client.py b/jupyter_qtconsole/client.py similarity index 100% rename from IPython/qt/client.py rename to jupyter_qtconsole/client.py diff --git a/IPython/qt/console/__init__.py b/jupyter_qtconsole/console/__init__.py similarity index 100% rename from IPython/qt/console/__init__.py rename to jupyter_qtconsole/console/__init__.py diff --git a/IPython/qt/console/__main__.py b/jupyter_qtconsole/console/__main__.py similarity index 100% rename from IPython/qt/console/__main__.py rename to jupyter_qtconsole/console/__main__.py diff --git a/IPython/qt/console/ansi_code_processor.py b/jupyter_qtconsole/console/ansi_code_processor.py similarity index 100% rename from IPython/qt/console/ansi_code_processor.py rename to jupyter_qtconsole/console/ansi_code_processor.py diff --git a/IPython/qt/console/bracket_matcher.py b/jupyter_qtconsole/console/bracket_matcher.py similarity index 100% rename from IPython/qt/console/bracket_matcher.py rename to jupyter_qtconsole/console/bracket_matcher.py diff --git a/IPython/qt/console/call_tip_widget.py b/jupyter_qtconsole/console/call_tip_widget.py similarity index 100% rename from IPython/qt/console/call_tip_widget.py rename to jupyter_qtconsole/console/call_tip_widget.py diff --git a/IPython/qt/console/completion_html.py b/jupyter_qtconsole/console/completion_html.py similarity index 100% rename from IPython/qt/console/completion_html.py rename to jupyter_qtconsole/console/completion_html.py diff --git a/IPython/qt/console/completion_plain.py b/jupyter_qtconsole/console/completion_plain.py similarity index 100% rename from IPython/qt/console/completion_plain.py rename to jupyter_qtconsole/console/completion_plain.py diff --git a/IPython/qt/console/completion_widget.py b/jupyter_qtconsole/console/completion_widget.py similarity index 100% rename from IPython/qt/console/completion_widget.py rename to jupyter_qtconsole/console/completion_widget.py diff --git a/IPython/qt/console/console_widget.py b/jupyter_qtconsole/console/console_widget.py similarity index 100% rename from IPython/qt/console/console_widget.py rename to jupyter_qtconsole/console/console_widget.py diff --git a/IPython/qt/console/frontend_widget.py b/jupyter_qtconsole/console/frontend_widget.py similarity index 100% rename from IPython/qt/console/frontend_widget.py rename to jupyter_qtconsole/console/frontend_widget.py diff --git a/IPython/qt/console/history_console_widget.py b/jupyter_qtconsole/console/history_console_widget.py similarity index 100% rename from IPython/qt/console/history_console_widget.py rename to jupyter_qtconsole/console/history_console_widget.py diff --git a/IPython/qt/console/ipython_widget.py b/jupyter_qtconsole/console/ipython_widget.py similarity index 100% rename from IPython/qt/console/ipython_widget.py rename to jupyter_qtconsole/console/ipython_widget.py diff --git a/IPython/qt/console/kill_ring.py b/jupyter_qtconsole/console/kill_ring.py similarity index 100% rename from IPython/qt/console/kill_ring.py rename to jupyter_qtconsole/console/kill_ring.py diff --git a/IPython/qt/console/magic_helper.py b/jupyter_qtconsole/console/magic_helper.py similarity index 100% rename from IPython/qt/console/magic_helper.py rename to jupyter_qtconsole/console/magic_helper.py diff --git a/IPython/qt/console/mainwindow.py b/jupyter_qtconsole/console/mainwindow.py similarity index 100% rename from IPython/qt/console/mainwindow.py rename to jupyter_qtconsole/console/mainwindow.py diff --git a/IPython/qt/console/pygments_highlighter.py b/jupyter_qtconsole/console/pygments_highlighter.py similarity index 100% rename from IPython/qt/console/pygments_highlighter.py rename to jupyter_qtconsole/console/pygments_highlighter.py diff --git a/IPython/qt/console/qtconsoleapp.py b/jupyter_qtconsole/console/qtconsoleapp.py similarity index 100% rename from IPython/qt/console/qtconsoleapp.py rename to jupyter_qtconsole/console/qtconsoleapp.py diff --git a/IPython/qt/console/resources/icon/IPythonConsole.svg b/jupyter_qtconsole/console/resources/icon/IPythonConsole.svg similarity index 100% rename from IPython/qt/console/resources/icon/IPythonConsole.svg rename to jupyter_qtconsole/console/resources/icon/IPythonConsole.svg diff --git a/IPython/qt/console/rich_ipython_widget.py b/jupyter_qtconsole/console/rich_ipython_widget.py similarity index 100% rename from IPython/qt/console/rich_ipython_widget.py rename to jupyter_qtconsole/console/rich_ipython_widget.py diff --git a/IPython/qt/console/styles.py b/jupyter_qtconsole/console/styles.py similarity index 100% rename from IPython/qt/console/styles.py rename to jupyter_qtconsole/console/styles.py diff --git a/IPython/qt/console/tests/__init__.py b/jupyter_qtconsole/console/tests/__init__.py similarity index 100% rename from IPython/qt/console/tests/__init__.py rename to jupyter_qtconsole/console/tests/__init__.py diff --git a/IPython/qt/console/tests/test_ansi_code_processor.py b/jupyter_qtconsole/console/tests/test_ansi_code_processor.py similarity index 100% rename from IPython/qt/console/tests/test_ansi_code_processor.py rename to jupyter_qtconsole/console/tests/test_ansi_code_processor.py diff --git a/IPython/qt/console/tests/test_app.py b/jupyter_qtconsole/console/tests/test_app.py similarity index 100% rename from IPython/qt/console/tests/test_app.py rename to jupyter_qtconsole/console/tests/test_app.py diff --git a/IPython/qt/console/tests/test_console_widget.py b/jupyter_qtconsole/console/tests/test_console_widget.py similarity index 100% rename from IPython/qt/console/tests/test_console_widget.py rename to jupyter_qtconsole/console/tests/test_console_widget.py diff --git a/IPython/qt/console/tests/test_kill_ring.py b/jupyter_qtconsole/console/tests/test_kill_ring.py similarity index 100% rename from IPython/qt/console/tests/test_kill_ring.py rename to jupyter_qtconsole/console/tests/test_kill_ring.py diff --git a/IPython/qt/inprocess.py b/jupyter_qtconsole/inprocess.py similarity index 100% rename from IPython/qt/inprocess.py rename to jupyter_qtconsole/inprocess.py diff --git a/IPython/qt/kernel_mixins.py b/jupyter_qtconsole/kernel_mixins.py similarity index 100% rename from IPython/qt/kernel_mixins.py rename to jupyter_qtconsole/kernel_mixins.py diff --git a/IPython/qt/manager.py b/jupyter_qtconsole/manager.py similarity index 100% rename from IPython/qt/manager.py rename to jupyter_qtconsole/manager.py diff --git a/IPython/qt/rich_text.py b/jupyter_qtconsole/rich_text.py similarity index 100% rename from IPython/qt/rich_text.py rename to jupyter_qtconsole/rich_text.py diff --git a/IPython/qt/svg.py b/jupyter_qtconsole/svg.py similarity index 100% rename from IPython/qt/svg.py rename to jupyter_qtconsole/svg.py diff --git a/IPython/qt/util.py b/jupyter_qtconsole/util.py similarity index 100% rename from IPython/qt/util.py rename to jupyter_qtconsole/util.py