Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions IPython/core/magics/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
19 changes: 8 additions & 11 deletions IPython/core/tests/test_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,25 +605,22 @@ 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")
nt.assert_equal(_ip.user_ns['arq'], 185)
_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')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why delete this test? It doesn't seem to use install_ext at all.

def test_notebook_export_json():
Expand Down
1 change: 1 addition & 0 deletions docs/source/whatsnew/pr/incompat-deleted-install_ext.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deleted the install_ext magic function