diff --git a/IPython/core/magics/extension.py b/IPython/core/magics/extension.py index 65f3993258c..2991d55ca40 100644 --- a/IPython/core/magics/extension.py +++ b/IPython/core/magics/extension.py @@ -29,35 +29,6 @@ class ExtensionMagics(Magics): """Magics to manage the IPython extensions system.""" - @line_magic - def install_ext(self, parameter_s=''): - """Download and install an extension from a URL, e.g.:: - - %install_ext https://bitbucket.org/birkenfeld/ipython-physics/raw/d1310a2ab15d/physics.py - - The URL should point to an importable Python module - either a .py file - or a .zip file. - - Parameters: - - -n filename : Specify a name for the file, rather than taking it from - the URL. - """ - warn("%install_ext` is deprecated, please distribute your extension " - "as a python package.", UserWarning) - opts, args = self.parse_options(parameter_s, 'n:') - try: - filename = self.shell.extension_manager.install_extension(args, - opts.get('n')) - except ValueError as e: - print(e) - return - - filename = os.path.basename(filename) - print("Installed %s. To use it, type:" % filename) - print(" %%load_ext %s" % os.path.splitext(filename)[0]) - - @line_magic def load_ext(self, module_str): """Load an IPython extension by its module name.""" diff --git a/IPython/core/tests/test_magic.py b/IPython/core/tests/test_magic.py index a507ab9861d..9718d19e844 100644 --- a/IPython/core/tests/test_magic.py +++ b/IPython/core/tests/test_magic.py @@ -605,16 +605,13 @@ def test_prun_quotes(): nt.assert_equal(_ip.user_ns['x'], '\t') def test_extension(): - # Debugging information for failures of this test - print('sys.path:') - for p in sys.path: - print(' ', p) - print('CWD', os.getcwd()) - - nt.assert_raises(ImportError, _ip.magic, "load_ext daft_extension") - daft_path = os.path.join(os.path.dirname(__file__), "daft_extension") - sys.path.insert(0, daft_path) + tmpdir = TemporaryDirectory() + orig_ipython_dir = _ip.ipython_dir try: + _ip.ipython_dir = tmpdir.name + nt.assert_raises(ImportError, _ip.magic, "load_ext daft_extension") + url = os.path.join(os.path.dirname(__file__), "daft_extension.py") + _ip.magic("install_ext %s" % url) _ip.user_ns.pop('arq', None) invalidate_caches() # Clear import caches _ip.magic("load_ext daft_extension") @@ -622,8 +619,8 @@ def test_extension(): _ip.magic("unload_ext daft_extension") assert 'arq' not in _ip.user_ns finally: - sys.path.remove(daft_path) - + _ip.ipython_dir = orig_ipython_dir + tmpdir.cleanup() @dec.skip_without('nbformat') def test_notebook_export_json(): diff --git a/docs/source/whatsnew/pr/incompat-deleted-install_ext.rst b/docs/source/whatsnew/pr/incompat-deleted-install_ext.rst new file mode 100644 index 00000000000..01b6d750497 --- /dev/null +++ b/docs/source/whatsnew/pr/incompat-deleted-install_ext.rst @@ -0,0 +1 @@ +Deleted the install_ext magic function