##// END OF EJS Templates
Reduce the number of test on Appveyor....
Reduce the number of test on Appveyor. Appveyor is way slower than Travis, in part because we test on more architecture. In particular 32 and 64 bits. And accumulate delay sometime leading to 30 min between travis success and AppVeyor response. 32 Bits OSes are starting to be rare (or not our target, like tablets). Less that 1/5 market share is some survey, and account for more than 2/3 of our testing time. So slash 3 out of 4 testing on 32 bits. Test only python 3.6 32 bits. (I know that's paradoxal are mostly old system are 32 bits... but do we expect people with old system and old python to use new IPython ?) For example: Windows Arch Share Windows 10 64 bit 36.97% Windows 7 64 bit 32.99% Windows 8.1 64 bit 12.93% Windows 8 64 bit 1.64% Windows Vista 64 bit 0.13% Windows 7 32 bit 6.97% Windows XP 32 bit 2.00% Windows 10 32 bit 1.31% Windows 8.1 32 bit 0.34% Windows Vista 32 bit 0.24% Windows 8 32 bit 0.15% Total about 83ish % of 64 bits. Source: http://www.digitaltrends.com/computing/steam-users-windows-10-market-share/ and http://store.steampowered.com/hwsurvey?platform=pc

File last commit:

r23220:4f9bd43d
r23236:a8f84d57
Show More
index.rst
103 lines | 3.9 KiB | text/x-rst | RstLexer

IPython extensions

A level above configuration are IPython extensions, Python modules which modify the behaviour of the shell. They are referred to by an importable module name, and can be placed anywhere you'd normally import from, or in .ipython/extensions/.

Getting extensions

A few important extensions are :ref:`bundled with IPython <bundled_extensions>`. Others can be found on the extensions index on the wiki, and the Framework :: IPython tag on PyPI.

Extensions on PyPI can be installed using pip, like any other Python package.

Using extensions

To load an extension while IPython is running, use the %load_ext magic:

In [1]: %load_ext myextension

To load it each time IPython starts, list it in your configuration file:

c.InteractiveShellApp.extensions = [
    'myextension'
]

Writing extensions

An IPython extension is an importable Python module that has a couple of special functions to load and unload it. Here is a template:

# myextension.py

def load_ipython_extension(ipython):
    # The `ipython` argument is the currently active `InteractiveShell`
    # instance, which can be used in any way. This allows you to register
    # new magics or aliases, for example.

def unload_ipython_extension(ipython):
    # If you want your extension to be unloadable, put that logic here.

This :func:`load_ipython_extension` function is called after your extension is imported, and the currently active :class:`~IPython.core.interactiveshell.InteractiveShell` instance is passed as the only argument. You can do anything you want with IPython at that point.

:func:`load_ipython_extension` will not be called again if the user use %load_extension. The user have to explicitly ask the extension to be reloaded (with %reload_extension). In case where the use ask the extension to be reloaded, , the extension will be unloaded (with unload_ipython_extension), and loaded again.

Useful :class:`InteractiveShell` methods include :meth:`~IPython.core.interactiveshell.InteractiveShell.register_magic_function`, :meth:`~IPython.core.interactiveshell.InteractiveShell.push` (to add variables to the user namespace) and :meth:`~IPython.core.interactiveshell.InteractiveShell.drop_by_id` (to remove variables on unloading).

You can put your extension modules anywhere you want, as long as they can be imported by Python's standard import mechanism. However, to make it easy to write extensions, you can also put your extensions in :file:`extensions/` within the :ref:`IPython directory <ipythondir>`. This directory is added to :data:`sys.path` automatically.

When your extension is ready for general use, please add it to the extensions index. We also encourage you to upload it to PyPI and use the Framework :: IPython classifier, so that users can install it with standard packaging tools.

Extensions bundled with IPython

  • octavemagic used to be bundled, but is now part of oct2py. Use %load_ext oct2py.ipython to load it.
  • rmagic is now part of rpy2. Use %load_ext rpy2.ipython to load it, and see :mod:`rpy2.ipython.rmagic` for details of how to use it.
  • cythonmagic used to be bundled, but is now part of cython Use %load_ext Cython to load it.
  • sympyprinting used to be a bundled extension, but you should now use :func:`sympy.init_printing` instead.