Show More
@@ -1,44 +1,25 | |||
|
1 | 1 | # http://travis-ci.org/#!/ipython/ipython |
|
2 | 2 | language: python |
|
3 | 3 | python: |
|
4 | 4 | - "nightly" |
|
5 | 5 | - 3.5 |
|
6 | 6 | - 3.4 |
|
7 | 7 | - 3.3 |
|
8 | - 2.7 | |
|
9 | - pypy | |
|
10 | 8 | sudo: false |
|
11 | 9 | before_install: |
|
12 | 10 | - git clone --quiet --depth 1 https://github.com/minrk/travis-wheels travis-wheels |
|
13 | 11 | - 'if [[ $GROUP != js* ]]; then COVERAGE=""; fi' |
|
14 | 12 | install: |
|
15 | 13 | - pip install "setuptools>=18.5" |
|
16 | # Installs PyPy (+ its Numpy). Based on @frol comment at: | |
|
17 | # https://github.com/travis-ci/travis-ci/issues/5027 | |
|
18 | - | | |
|
19 | if [ "$TRAVIS_PYTHON_VERSION" = "pypy" ]; then | |
|
20 | export PYENV_ROOT="$HOME/.pyenv" | |
|
21 | if [ -f "$PYENV_ROOT/bin/pyenv" ]; then | |
|
22 | cd "$PYENV_ROOT" && git pull | |
|
23 | else | |
|
24 | rm -rf "$PYENV_ROOT" && git clone --depth 1 https://github.com/yyuu/pyenv.git "$PYENV_ROOT" | |
|
25 | fi | |
|
26 | export PYPY_VERSION="5.3.1" | |
|
27 | "$PYENV_ROOT/bin/pyenv" install "pypy-$PYPY_VERSION" | |
|
28 | virtualenv --python="$PYENV_ROOT/versions/pypy-$PYPY_VERSION/bin/python" "$HOME/virtualenvs/pypy-$PYPY_VERSION" | |
|
29 | source "$HOME/virtualenvs/pypy-$PYPY_VERSION/bin/activate" | |
|
30 | pip install https://bitbucket.org/pypy/numpy/get/master.zip | |
|
31 | fi | |
|
32 | 14 | - pip install -f travis-wheels/wheelhouse -e file://$PWD#egg=ipython[test] |
|
33 | 15 | - pip install codecov |
|
34 | 16 | script: |
|
35 | 17 | - cd /tmp && iptest --coverage xml && cd - |
|
36 | 18 | after_success: |
|
37 | 19 | - cp /tmp/ipy_coverage.xml ./ |
|
38 | 20 | - cp /tmp/.coverage ./ |
|
39 | 21 | - codecov |
|
40 | 22 | |
|
41 | 23 | matrix: |
|
42 | 24 | allow_failures: |
|
43 | 25 | - python: nightly |
|
44 | - python: pypy |
@@ -1,146 +1,146 | |||
|
1 | 1 | # encoding: utf-8 |
|
2 | 2 | """ |
|
3 | 3 | IPython: tools for interactive and parallel computing in Python. |
|
4 | 4 | |
|
5 | 5 | http://ipython.org |
|
6 | 6 | """ |
|
7 | 7 | #----------------------------------------------------------------------------- |
|
8 | 8 | # Copyright (c) 2008-2011, IPython Development Team. |
|
9 | 9 | # Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.edu> |
|
10 | 10 | # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de> |
|
11 | 11 | # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu> |
|
12 | 12 | # |
|
13 | 13 | # Distributed under the terms of the Modified BSD License. |
|
14 | 14 | # |
|
15 | 15 | # The full license is in the file COPYING.txt, distributed with this software. |
|
16 | 16 | #----------------------------------------------------------------------------- |
|
17 | 17 | |
|
18 | 18 | #----------------------------------------------------------------------------- |
|
19 | 19 | # Imports |
|
20 | 20 | #----------------------------------------------------------------------------- |
|
21 | 21 | from __future__ import absolute_import |
|
22 | 22 | |
|
23 | 23 | import os |
|
24 | 24 | import sys |
|
25 | 25 | import warnings |
|
26 | 26 | |
|
27 | 27 | #----------------------------------------------------------------------------- |
|
28 | 28 | # Setup everything |
|
29 | 29 | #----------------------------------------------------------------------------- |
|
30 | 30 | |
|
31 | 31 | # Don't forget to also update setup.py when this changes! |
|
32 | 32 | v = sys.version_info |
|
33 | if v[:2] < (2,7) or (v[0] >= 3 and v[:2] < (3,3)): | |
|
34 |
raise ImportError('IPython requires Python version |
|
|
33 | if v[:2] < (3,3): | |
|
34 | raise ImportError('IPython requires Python version 3.3 or above.') | |
|
35 | 35 | del v |
|
36 | 36 | |
|
37 | 37 | # Make it easy to import extensions - they are always directly on pythonpath. |
|
38 | 38 | # Therefore, non-IPython modules can be added to extensions directory. |
|
39 | 39 | # This should probably be in ipapp.py. |
|
40 | 40 | sys.path.append(os.path.join(os.path.dirname(__file__), "extensions")) |
|
41 | 41 | |
|
42 | 42 | #----------------------------------------------------------------------------- |
|
43 | 43 | # Setup the top level names |
|
44 | 44 | #----------------------------------------------------------------------------- |
|
45 | 45 | |
|
46 | 46 | from .core.getipython import get_ipython |
|
47 | 47 | from .core import release |
|
48 | 48 | from .core.application import Application |
|
49 | 49 | from .terminal.embed import embed |
|
50 | 50 | |
|
51 | 51 | from .core.interactiveshell import InteractiveShell |
|
52 | 52 | from .testing import test |
|
53 | 53 | from .utils.sysinfo import sys_info |
|
54 | 54 | from .utils.frame import extract_module_locals |
|
55 | 55 | |
|
56 | 56 | # Release data |
|
57 | 57 | __author__ = '%s <%s>' % (release.author, release.author_email) |
|
58 | 58 | __license__ = release.license |
|
59 | 59 | __version__ = release.version |
|
60 | 60 | version_info = release.version_info |
|
61 | 61 | |
|
62 | 62 | def embed_kernel(module=None, local_ns=None, **kwargs): |
|
63 | 63 | """Embed and start an IPython kernel in a given scope. |
|
64 | 64 | |
|
65 | 65 | If you don't want the kernel to initialize the namespace |
|
66 | 66 | from the scope of the surrounding function, |
|
67 | 67 | and/or you want to load full IPython configuration, |
|
68 | 68 | you probably want `IPython.start_kernel()` instead. |
|
69 | 69 | |
|
70 | 70 | Parameters |
|
71 | 71 | ---------- |
|
72 | 72 | module : ModuleType, optional |
|
73 | 73 | The module to load into IPython globals (default: caller) |
|
74 | 74 | local_ns : dict, optional |
|
75 | 75 | The namespace to load into IPython user namespace (default: caller) |
|
76 | 76 | |
|
77 | 77 | kwargs : various, optional |
|
78 | 78 | Further keyword args are relayed to the IPKernelApp constructor, |
|
79 | 79 | allowing configuration of the Kernel. Will only have an effect |
|
80 | 80 | on the first embed_kernel call for a given process. |
|
81 | 81 | """ |
|
82 | 82 | |
|
83 | 83 | (caller_module, caller_locals) = extract_module_locals(1) |
|
84 | 84 | if module is None: |
|
85 | 85 | module = caller_module |
|
86 | 86 | if local_ns is None: |
|
87 | 87 | local_ns = caller_locals |
|
88 | 88 | |
|
89 | 89 | # Only import .zmq when we really need it |
|
90 | 90 | from ipykernel.embed import embed_kernel as real_embed_kernel |
|
91 | 91 | real_embed_kernel(module=module, local_ns=local_ns, **kwargs) |
|
92 | 92 | |
|
93 | 93 | def start_ipython(argv=None, **kwargs): |
|
94 | 94 | """Launch a normal IPython instance (as opposed to embedded) |
|
95 | 95 | |
|
96 | 96 | `IPython.embed()` puts a shell in a particular calling scope, |
|
97 | 97 | such as a function or method for debugging purposes, |
|
98 | 98 | which is often not desirable. |
|
99 | 99 | |
|
100 | 100 | `start_ipython()` does full, regular IPython initialization, |
|
101 | 101 | including loading startup files, configuration, etc. |
|
102 | 102 | much of which is skipped by `embed()`. |
|
103 | 103 | |
|
104 | 104 | This is a public API method, and will survive implementation changes. |
|
105 | 105 | |
|
106 | 106 | Parameters |
|
107 | 107 | ---------- |
|
108 | 108 | |
|
109 | 109 | argv : list or None, optional |
|
110 | 110 | If unspecified or None, IPython will parse command-line options from sys.argv. |
|
111 | 111 | To prevent any command-line parsing, pass an empty list: `argv=[]`. |
|
112 | 112 | user_ns : dict, optional |
|
113 | 113 | specify this dictionary to initialize the IPython user namespace with particular values. |
|
114 | 114 | kwargs : various, optional |
|
115 | 115 | Any other kwargs will be passed to the Application constructor, |
|
116 | 116 | such as `config`. |
|
117 | 117 | """ |
|
118 | 118 | from IPython.terminal.ipapp import launch_new_instance |
|
119 | 119 | return launch_new_instance(argv=argv, **kwargs) |
|
120 | 120 | |
|
121 | 121 | def start_kernel(argv=None, **kwargs): |
|
122 | 122 | """Launch a normal IPython kernel instance (as opposed to embedded) |
|
123 | 123 | |
|
124 | 124 | `IPython.embed_kernel()` puts a shell in a particular calling scope, |
|
125 | 125 | such as a function or method for debugging purposes, |
|
126 | 126 | which is often not desirable. |
|
127 | 127 | |
|
128 | 128 | `start_kernel()` does full, regular IPython initialization, |
|
129 | 129 | including loading startup files, configuration, etc. |
|
130 | 130 | much of which is skipped by `embed()`. |
|
131 | 131 | |
|
132 | 132 | Parameters |
|
133 | 133 | ---------- |
|
134 | 134 | |
|
135 | 135 | argv : list or None, optional |
|
136 | 136 | If unspecified or None, IPython will parse command-line options from sys.argv. |
|
137 | 137 | To prevent any command-line parsing, pass an empty list: `argv=[]`. |
|
138 | 138 | user_ns : dict, optional |
|
139 | 139 | specify this dictionary to initialize the IPython user namespace with particular values. |
|
140 | 140 | kwargs : various, optional |
|
141 | 141 | Any other kwargs will be passed to the Application constructor, |
|
142 | 142 | such as `config`. |
|
143 | 143 | """ |
|
144 | 144 | from IPython.kernel.zmq.kernelapp import launch_new_instance |
|
145 | 145 | return launch_new_instance(argv=argv, **kwargs) |
|
146 | 146 |
@@ -1,584 +1,583 | |||
|
1 | 1 | """Implementation of basic magic functions.""" |
|
2 | 2 | |
|
3 | 3 | from __future__ import print_function |
|
4 | 4 | from __future__ import absolute_import |
|
5 | 5 | |
|
6 | import argparse | |
|
6 | 7 | import io |
|
7 | 8 | import sys |
|
8 | 9 | from pprint import pformat |
|
9 | 10 | |
|
10 | 11 | from IPython.core import magic_arguments, page |
|
11 | 12 | from IPython.core.error import UsageError |
|
12 | 13 | from IPython.core.magic import Magics, magics_class, line_magic, magic_escapes |
|
13 | 14 | from IPython.utils.text import format_screen, dedent, indent |
|
14 | 15 | from IPython.testing.skipdoctest import skip_doctest |
|
15 | 16 | from IPython.utils.ipstruct import Struct |
|
16 | 17 | from IPython.utils.py3compat import unicode_type |
|
17 | 18 | from warnings import warn |
|
18 | 19 | from logging import error |
|
19 | 20 | |
|
20 | 21 | |
|
21 | 22 | class MagicsDisplay(object): |
|
22 | 23 | def __init__(self, magics_manager): |
|
23 | 24 | self.magics_manager = magics_manager |
|
24 | 25 | |
|
25 | 26 | def _lsmagic(self): |
|
26 | 27 | """The main implementation of the %lsmagic""" |
|
27 | 28 | mesc = magic_escapes['line'] |
|
28 | 29 | cesc = magic_escapes['cell'] |
|
29 | 30 | mman = self.magics_manager |
|
30 | 31 | magics = mman.lsmagic() |
|
31 | 32 | out = ['Available line magics:', |
|
32 | 33 | mesc + (' '+mesc).join(sorted(magics['line'])), |
|
33 | 34 | '', |
|
34 | 35 | 'Available cell magics:', |
|
35 | 36 | cesc + (' '+cesc).join(sorted(magics['cell'])), |
|
36 | 37 | '', |
|
37 | 38 | mman.auto_status()] |
|
38 | 39 | return '\n'.join(out) |
|
39 | 40 | |
|
40 | 41 | def _repr_pretty_(self, p, cycle): |
|
41 | 42 | p.text(self._lsmagic()) |
|
42 | 43 | |
|
43 | 44 | def __str__(self): |
|
44 | 45 | return self._lsmagic() |
|
45 | 46 | |
|
46 | 47 | def _jsonable(self): |
|
47 | 48 | """turn magics dict into jsonable dict of the same structure |
|
48 | 49 | |
|
49 | 50 | replaces object instances with their class names as strings |
|
50 | 51 | """ |
|
51 | 52 | magic_dict = {} |
|
52 | 53 | mman = self.magics_manager |
|
53 | 54 | magics = mman.lsmagic() |
|
54 | 55 | for key, subdict in magics.items(): |
|
55 | 56 | d = {} |
|
56 | 57 | magic_dict[key] = d |
|
57 | 58 | for name, obj in subdict.items(): |
|
58 | 59 | try: |
|
59 | 60 | classname = obj.__self__.__class__.__name__ |
|
60 | 61 | except AttributeError: |
|
61 | 62 | classname = 'Other' |
|
62 | 63 | |
|
63 | 64 | d[name] = classname |
|
64 | 65 | return magic_dict |
|
65 | 66 | |
|
66 | 67 | def _repr_json_(self): |
|
67 | 68 | return self._jsonable() |
|
68 | 69 | |
|
69 | 70 | |
|
70 | 71 | @magics_class |
|
71 | 72 | class BasicMagics(Magics): |
|
72 | 73 | """Magics that provide central IPython functionality. |
|
73 | 74 | |
|
74 | 75 | These are various magics that don't fit into specific categories but that |
|
75 | 76 | are all part of the base 'IPython experience'.""" |
|
76 | 77 | |
|
77 | 78 | @magic_arguments.magic_arguments() |
|
78 | 79 | @magic_arguments.argument( |
|
79 | 80 | '-l', '--line', action='store_true', |
|
80 | 81 | help="""Create a line magic alias.""" |
|
81 | 82 | ) |
|
82 | 83 | @magic_arguments.argument( |
|
83 | 84 | '-c', '--cell', action='store_true', |
|
84 | 85 | help="""Create a cell magic alias.""" |
|
85 | 86 | ) |
|
86 | 87 | @magic_arguments.argument( |
|
87 | 88 | 'name', |
|
88 | 89 | help="""Name of the magic to be created.""" |
|
89 | 90 | ) |
|
90 | 91 | @magic_arguments.argument( |
|
91 | 92 | 'target', |
|
92 | 93 | help="""Name of the existing line or cell magic.""" |
|
93 | 94 | ) |
|
94 | 95 | @line_magic |
|
95 | 96 | def alias_magic(self, line=''): |
|
96 | 97 | """Create an alias for an existing line or cell magic. |
|
97 | 98 | |
|
98 | 99 | Examples |
|
99 | 100 | -------- |
|
100 | 101 | :: |
|
101 | 102 | |
|
102 | 103 | In [1]: %alias_magic t timeit |
|
103 | 104 | Created `%t` as an alias for `%timeit`. |
|
104 | 105 | Created `%%t` as an alias for `%%timeit`. |
|
105 | 106 | |
|
106 | 107 | In [2]: %t -n1 pass |
|
107 | 108 | 1 loops, best of 3: 954 ns per loop |
|
108 | 109 | |
|
109 | 110 | In [3]: %%t -n1 |
|
110 | 111 | ...: pass |
|
111 | 112 | ...: |
|
112 | 113 | 1 loops, best of 3: 954 ns per loop |
|
113 | 114 | |
|
114 | 115 | In [4]: %alias_magic --cell whereami pwd |
|
115 | 116 | UsageError: Cell magic function `%%pwd` not found. |
|
116 | 117 | In [5]: %alias_magic --line whereami pwd |
|
117 | 118 | Created `%whereami` as an alias for `%pwd`. |
|
118 | 119 | |
|
119 | 120 | In [6]: %whereami |
|
120 | 121 | Out[6]: u'/home/testuser' |
|
121 | 122 | """ |
|
122 | 123 | args = magic_arguments.parse_argstring(self.alias_magic, line) |
|
123 | 124 | shell = self.shell |
|
124 | 125 | mman = self.shell.magics_manager |
|
125 | 126 | escs = ''.join(magic_escapes.values()) |
|
126 | 127 | |
|
127 | 128 | target = args.target.lstrip(escs) |
|
128 | 129 | name = args.name.lstrip(escs) |
|
129 | 130 | |
|
130 | 131 | # Find the requested magics. |
|
131 | 132 | m_line = shell.find_magic(target, 'line') |
|
132 | 133 | m_cell = shell.find_magic(target, 'cell') |
|
133 | 134 | if args.line and m_line is None: |
|
134 | 135 | raise UsageError('Line magic function `%s%s` not found.' % |
|
135 | 136 | (magic_escapes['line'], target)) |
|
136 | 137 | if args.cell and m_cell is None: |
|
137 | 138 | raise UsageError('Cell magic function `%s%s` not found.' % |
|
138 | 139 | (magic_escapes['cell'], target)) |
|
139 | 140 | |
|
140 | 141 | # If --line and --cell are not specified, default to the ones |
|
141 | 142 | # that are available. |
|
142 | 143 | if not args.line and not args.cell: |
|
143 | 144 | if not m_line and not m_cell: |
|
144 | 145 | raise UsageError( |
|
145 | 146 | 'No line or cell magic with name `%s` found.' % target |
|
146 | 147 | ) |
|
147 | 148 | args.line = bool(m_line) |
|
148 | 149 | args.cell = bool(m_cell) |
|
149 | 150 | |
|
150 | 151 | if args.line: |
|
151 | 152 | mman.register_alias(name, target, 'line') |
|
152 | 153 | print('Created `%s%s` as an alias for `%s%s`.' % ( |
|
153 | 154 | magic_escapes['line'], name, |
|
154 | 155 | magic_escapes['line'], target)) |
|
155 | 156 | |
|
156 | 157 | if args.cell: |
|
157 | 158 | mman.register_alias(name, target, 'cell') |
|
158 | 159 | print('Created `%s%s` as an alias for `%s%s`.' % ( |
|
159 | 160 | magic_escapes['cell'], name, |
|
160 | 161 | magic_escapes['cell'], target)) |
|
161 | 162 | |
|
162 | 163 | @line_magic |
|
163 | 164 | def lsmagic(self, parameter_s=''): |
|
164 | 165 | """List currently available magic functions.""" |
|
165 | 166 | return MagicsDisplay(self.shell.magics_manager) |
|
166 | 167 | |
|
167 | 168 | def _magic_docs(self, brief=False, rest=False): |
|
168 | 169 | """Return docstrings from magic functions.""" |
|
169 | 170 | mman = self.shell.magics_manager |
|
170 | 171 | docs = mman.lsmagic_docs(brief, missing='No documentation') |
|
171 | 172 | |
|
172 | 173 | if rest: |
|
173 | 174 | format_string = '**%s%s**::\n\n%s\n\n' |
|
174 | 175 | else: |
|
175 | 176 | format_string = '%s%s:\n%s\n' |
|
176 | 177 | |
|
177 | 178 | return ''.join( |
|
178 | 179 | [format_string % (magic_escapes['line'], fname, |
|
179 | 180 | indent(dedent(fndoc))) |
|
180 | 181 | for fname, fndoc in sorted(docs['line'].items())] |
|
181 | 182 | + |
|
182 | 183 | [format_string % (magic_escapes['cell'], fname, |
|
183 | 184 | indent(dedent(fndoc))) |
|
184 | 185 | for fname, fndoc in sorted(docs['cell'].items())] |
|
185 | 186 | ) |
|
186 | 187 | |
|
187 | 188 | @line_magic |
|
188 | 189 | def magic(self, parameter_s=''): |
|
189 | 190 | """Print information about the magic function system. |
|
190 | 191 | |
|
191 | 192 | Supported formats: -latex, -brief, -rest |
|
192 | 193 | """ |
|
193 | 194 | |
|
194 | 195 | mode = '' |
|
195 | 196 | try: |
|
196 | 197 | mode = parameter_s.split()[0][1:] |
|
197 | 198 | except IndexError: |
|
198 | 199 | pass |
|
199 | 200 | |
|
200 | 201 | brief = (mode == 'brief') |
|
201 | 202 | rest = (mode == 'rest') |
|
202 | 203 | magic_docs = self._magic_docs(brief, rest) |
|
203 | 204 | |
|
204 | 205 | if mode == 'latex': |
|
205 | 206 | print(self.format_latex(magic_docs)) |
|
206 | 207 | return |
|
207 | 208 | else: |
|
208 | 209 | magic_docs = format_screen(magic_docs) |
|
209 | 210 | |
|
210 | 211 | out = [""" |
|
211 | 212 | IPython's 'magic' functions |
|
212 | 213 | =========================== |
|
213 | 214 | |
|
214 | 215 | The magic function system provides a series of functions which allow you to |
|
215 | 216 | control the behavior of IPython itself, plus a lot of system-type |
|
216 | 217 | features. There are two kinds of magics, line-oriented and cell-oriented. |
|
217 | 218 | |
|
218 | 219 | Line magics are prefixed with the % character and work much like OS |
|
219 | 220 | command-line calls: they get as an argument the rest of the line, where |
|
220 | 221 | arguments are passed without parentheses or quotes. For example, this will |
|
221 | 222 | time the given statement:: |
|
222 | 223 | |
|
223 | 224 | %timeit range(1000) |
|
224 | 225 | |
|
225 | 226 | Cell magics are prefixed with a double %%, and they are functions that get as |
|
226 | 227 | an argument not only the rest of the line, but also the lines below it in a |
|
227 | 228 | separate argument. These magics are called with two arguments: the rest of the |
|
228 | 229 | call line and the body of the cell, consisting of the lines below the first. |
|
229 | 230 | For example:: |
|
230 | 231 | |
|
231 | 232 | %%timeit x = numpy.random.randn((100, 100)) |
|
232 | 233 | numpy.linalg.svd(x) |
|
233 | 234 | |
|
234 | 235 | will time the execution of the numpy svd routine, running the assignment of x |
|
235 | 236 | as part of the setup phase, which is not timed. |
|
236 | 237 | |
|
237 | 238 | In a line-oriented client (the terminal or Qt console IPython), starting a new |
|
238 | 239 | input with %% will automatically enter cell mode, and IPython will continue |
|
239 | 240 | reading input until a blank line is given. In the notebook, simply type the |
|
240 | 241 | whole cell as one entity, but keep in mind that the %% escape can only be at |
|
241 | 242 | the very start of the cell. |
|
242 | 243 | |
|
243 | 244 | NOTE: If you have 'automagic' enabled (via the command line option or with the |
|
244 | 245 | %automagic function), you don't need to type in the % explicitly for line |
|
245 | 246 | magics; cell magics always require an explicit '%%' escape. By default, |
|
246 | 247 | IPython ships with automagic on, so you should only rarely need the % escape. |
|
247 | 248 | |
|
248 | 249 | Example: typing '%cd mydir' (without the quotes) changes your working directory |
|
249 | 250 | to 'mydir', if it exists. |
|
250 | 251 | |
|
251 | 252 | For a list of the available magic functions, use %lsmagic. For a description |
|
252 | 253 | of any of them, type %magic_name?, e.g. '%cd?'. |
|
253 | 254 | |
|
254 | 255 | Currently the magic system has the following functions:""", |
|
255 | 256 | magic_docs, |
|
256 | 257 | "Summary of magic functions (from %slsmagic):" % magic_escapes['line'], |
|
257 | 258 | str(self.lsmagic()), |
|
258 | 259 | ] |
|
259 | 260 | page.page('\n'.join(out)) |
|
260 | 261 | |
|
261 | 262 | |
|
262 | 263 | @line_magic |
|
263 | 264 | def page(self, parameter_s=''): |
|
264 | 265 | """Pretty print the object and display it through a pager. |
|
265 | 266 | |
|
266 | 267 | %page [options] OBJECT |
|
267 | 268 | |
|
268 | 269 | If no object is given, use _ (last output). |
|
269 | 270 | |
|
270 | 271 | Options: |
|
271 | 272 | |
|
272 | 273 | -r: page str(object), don't pretty-print it.""" |
|
273 | 274 | |
|
274 | 275 | # After a function contributed by Olivier Aubert, slightly modified. |
|
275 | 276 | |
|
276 | 277 | # Process options/args |
|
277 | 278 | opts, args = self.parse_options(parameter_s, 'r') |
|
278 | 279 | raw = 'r' in opts |
|
279 | 280 | |
|
280 | 281 | oname = args and args or '_' |
|
281 | 282 | info = self.shell._ofind(oname) |
|
282 | 283 | if info['found']: |
|
283 | 284 | txt = (raw and str or pformat)( info['obj'] ) |
|
284 | 285 | page.page(txt) |
|
285 | 286 | else: |
|
286 | 287 | print('Object `%s` not found' % oname) |
|
287 | 288 | |
|
288 | 289 | @line_magic |
|
289 | 290 | def profile(self, parameter_s=''): |
|
290 | 291 | """Print your currently active IPython profile. |
|
291 | 292 | |
|
292 | 293 | See Also |
|
293 | 294 | -------- |
|
294 | 295 | prun : run code using the Python profiler |
|
295 | 296 | (:meth:`~IPython.core.magics.execution.ExecutionMagics.prun`) |
|
296 | 297 | """ |
|
297 | 298 | warn("%profile is now deprecated. Please use get_ipython().profile instead.") |
|
298 | 299 | from IPython.core.application import BaseIPythonApplication |
|
299 | 300 | if BaseIPythonApplication.initialized(): |
|
300 | 301 | print(BaseIPythonApplication.instance().profile) |
|
301 | 302 | else: |
|
302 | 303 | error("profile is an application-level value, but you don't appear to be in an IPython application") |
|
303 | 304 | |
|
304 | 305 | @line_magic |
|
305 | 306 | def pprint(self, parameter_s=''): |
|
306 | 307 | """Toggle pretty printing on/off.""" |
|
307 | 308 | ptformatter = self.shell.display_formatter.formatters['text/plain'] |
|
308 | 309 | ptformatter.pprint = bool(1 - ptformatter.pprint) |
|
309 | 310 | print('Pretty printing has been turned', |
|
310 | 311 | ['OFF','ON'][ptformatter.pprint]) |
|
311 | 312 | |
|
312 | 313 | @line_magic |
|
313 | 314 | def colors(self, parameter_s=''): |
|
314 | 315 | """Switch color scheme for prompts, info system and exception handlers. |
|
315 | 316 | |
|
316 | 317 | Currently implemented schemes: NoColor, Linux, LightBG. |
|
317 | 318 | |
|
318 | 319 | Color scheme names are not case-sensitive. |
|
319 | 320 | |
|
320 | 321 | Examples |
|
321 | 322 | -------- |
|
322 | 323 | To get a plain black and white terminal:: |
|
323 | 324 | |
|
324 | 325 | %colors nocolor |
|
325 | 326 | """ |
|
326 | 327 | def color_switch_err(name): |
|
327 | 328 | warn('Error changing %s color schemes.\n%s' % |
|
328 | 329 | (name, sys.exc_info()[1]), stacklevel=2) |
|
329 | 330 | |
|
330 | 331 | |
|
331 | 332 | new_scheme = parameter_s.strip() |
|
332 | 333 | if not new_scheme: |
|
333 | 334 | raise UsageError( |
|
334 | 335 | "%colors: you must specify a color scheme. See '%colors?'") |
|
335 | 336 | # local shortcut |
|
336 | 337 | shell = self.shell |
|
337 | 338 | |
|
338 | 339 | # Set shell colour scheme |
|
339 | 340 | try: |
|
340 | 341 | shell.colors = new_scheme |
|
341 | 342 | shell.refresh_style() |
|
342 | 343 | except: |
|
343 | 344 | color_switch_err('shell') |
|
344 | 345 | |
|
345 | 346 | # Set exception colors |
|
346 | 347 | try: |
|
347 | 348 | shell.InteractiveTB.set_colors(scheme = new_scheme) |
|
348 | 349 | shell.SyntaxTB.set_colors(scheme = new_scheme) |
|
349 | 350 | except: |
|
350 | 351 | color_switch_err('exception') |
|
351 | 352 | |
|
352 | 353 | # Set info (for 'object?') colors |
|
353 | 354 | if shell.color_info: |
|
354 | 355 | try: |
|
355 | 356 | shell.inspector.set_active_scheme(new_scheme) |
|
356 | 357 | except: |
|
357 | 358 | color_switch_err('object inspector') |
|
358 | 359 | else: |
|
359 | 360 | shell.inspector.set_active_scheme('NoColor') |
|
360 | 361 | |
|
361 | 362 | @line_magic |
|
362 | 363 | def xmode(self, parameter_s=''): |
|
363 | 364 | """Switch modes for the exception handlers. |
|
364 | 365 | |
|
365 | 366 | Valid modes: Plain, Context and Verbose. |
|
366 | 367 | |
|
367 | 368 | If called without arguments, acts as a toggle.""" |
|
368 | 369 | |
|
369 | 370 | def xmode_switch_err(name): |
|
370 | 371 | warn('Error changing %s exception modes.\n%s' % |
|
371 | 372 | (name,sys.exc_info()[1])) |
|
372 | 373 | |
|
373 | 374 | shell = self.shell |
|
374 | 375 | new_mode = parameter_s.strip().capitalize() |
|
375 | 376 | try: |
|
376 | 377 | shell.InteractiveTB.set_mode(mode=new_mode) |
|
377 | 378 | print('Exception reporting mode:',shell.InteractiveTB.mode) |
|
378 | 379 | except: |
|
379 | 380 | xmode_switch_err('user') |
|
380 | 381 | |
|
381 | 382 | @line_magic |
|
382 | 383 | def quickref(self,arg): |
|
383 | 384 | """ Show a quick reference sheet """ |
|
384 | 385 | from IPython.core.usage import quick_reference |
|
385 | 386 | qr = quick_reference + self._magic_docs(brief=True) |
|
386 | 387 | page.page(qr) |
|
387 | 388 | |
|
388 | 389 | @line_magic |
|
389 | 390 | def doctest_mode(self, parameter_s=''): |
|
390 | 391 | """Toggle doctest mode on and off. |
|
391 | 392 | |
|
392 | 393 | This mode is intended to make IPython behave as much as possible like a |
|
393 | 394 | plain Python shell, from the perspective of how its prompts, exceptions |
|
394 | 395 | and output look. This makes it easy to copy and paste parts of a |
|
395 | 396 | session into doctests. It does so by: |
|
396 | 397 | |
|
397 | 398 | - Changing the prompts to the classic ``>>>`` ones. |
|
398 | 399 | - Changing the exception reporting mode to 'Plain'. |
|
399 | 400 | - Disabling pretty-printing of output. |
|
400 | 401 | |
|
401 | 402 | Note that IPython also supports the pasting of code snippets that have |
|
402 | 403 | leading '>>>' and '...' prompts in them. This means that you can paste |
|
403 | 404 | doctests from files or docstrings (even if they have leading |
|
404 | 405 | whitespace), and the code will execute correctly. You can then use |
|
405 | 406 | '%history -t' to see the translated history; this will give you the |
|
406 | 407 | input after removal of all the leading prompts and whitespace, which |
|
407 | 408 | can be pasted back into an editor. |
|
408 | 409 | |
|
409 | 410 | With these features, you can switch into this mode easily whenever you |
|
410 | 411 | need to do testing and changes to doctests, without having to leave |
|
411 | 412 | your existing IPython session. |
|
412 | 413 | """ |
|
413 | 414 | |
|
414 | 415 | # Shorthands |
|
415 | 416 | shell = self.shell |
|
416 | 417 | meta = shell.meta |
|
417 | 418 | disp_formatter = self.shell.display_formatter |
|
418 | 419 | ptformatter = disp_formatter.formatters['text/plain'] |
|
419 | 420 | # dstore is a data store kept in the instance metadata bag to track any |
|
420 | 421 | # changes we make, so we can undo them later. |
|
421 | 422 | dstore = meta.setdefault('doctest_mode',Struct()) |
|
422 | 423 | save_dstore = dstore.setdefault |
|
423 | 424 | |
|
424 | 425 | # save a few values we'll need to recover later |
|
425 | 426 | mode = save_dstore('mode',False) |
|
426 | 427 | save_dstore('rc_pprint',ptformatter.pprint) |
|
427 | 428 | save_dstore('xmode',shell.InteractiveTB.mode) |
|
428 | 429 | save_dstore('rc_separate_out',shell.separate_out) |
|
429 | 430 | save_dstore('rc_separate_out2',shell.separate_out2) |
|
430 | 431 | save_dstore('rc_separate_in',shell.separate_in) |
|
431 | 432 | save_dstore('rc_active_types',disp_formatter.active_types) |
|
432 | 433 | |
|
433 | 434 | if not mode: |
|
434 | 435 | # turn on |
|
435 | 436 | |
|
436 | 437 | # Prompt separators like plain python |
|
437 | 438 | shell.separate_in = '' |
|
438 | 439 | shell.separate_out = '' |
|
439 | 440 | shell.separate_out2 = '' |
|
440 | 441 | |
|
441 | 442 | |
|
442 | 443 | ptformatter.pprint = False |
|
443 | 444 | disp_formatter.active_types = ['text/plain'] |
|
444 | 445 | |
|
445 | 446 | shell.magic('xmode Plain') |
|
446 | 447 | else: |
|
447 | 448 | # turn off |
|
448 | 449 | shell.separate_in = dstore.rc_separate_in |
|
449 | 450 | |
|
450 | 451 | shell.separate_out = dstore.rc_separate_out |
|
451 | 452 | shell.separate_out2 = dstore.rc_separate_out2 |
|
452 | 453 | |
|
453 | 454 | ptformatter.pprint = dstore.rc_pprint |
|
454 | 455 | disp_formatter.active_types = dstore.rc_active_types |
|
455 | 456 | |
|
456 | 457 | shell.magic('xmode ' + dstore.xmode) |
|
457 | 458 | |
|
458 | 459 | # mode here is the state before we switch; switch_doctest_mode takes |
|
459 | 460 | # the mode we're switching to. |
|
460 | 461 | shell.switch_doctest_mode(not mode) |
|
461 | 462 | |
|
462 | 463 | # Store new mode and inform |
|
463 | 464 | dstore.mode = bool(not mode) |
|
464 | 465 | mode_label = ['OFF','ON'][dstore.mode] |
|
465 | 466 | print('Doctest mode is:', mode_label) |
|
466 | 467 | |
|
467 | 468 | @line_magic |
|
468 | 469 | def gui(self, parameter_s=''): |
|
469 | 470 | """Enable or disable IPython GUI event loop integration. |
|
470 | 471 | |
|
471 | 472 | %gui [GUINAME] |
|
472 | 473 | |
|
473 | 474 | This magic replaces IPython's threaded shells that were activated |
|
474 | 475 | using the (pylab/wthread/etc.) command line flags. GUI toolkits |
|
475 | 476 | can now be enabled at runtime and keyboard |
|
476 | 477 | interrupts should work without any problems. The following toolkits |
|
477 | 478 | are supported: wxPython, PyQt4, PyGTK, Tk and Cocoa (OSX):: |
|
478 | 479 | |
|
479 | 480 | %gui wx # enable wxPython event loop integration |
|
480 | 481 | %gui qt4|qt # enable PyQt4 event loop integration |
|
481 | 482 | %gui qt5 # enable PyQt5 event loop integration |
|
482 | 483 | %gui gtk # enable PyGTK event loop integration |
|
483 | 484 | %gui gtk3 # enable Gtk3 event loop integration |
|
484 | 485 | %gui tk # enable Tk event loop integration |
|
485 | 486 | %gui osx # enable Cocoa event loop integration |
|
486 | 487 | # (requires %matplotlib 1.1) |
|
487 | 488 | %gui # disable all event loop integration |
|
488 | 489 | |
|
489 | 490 | WARNING: after any of these has been called you can simply create |
|
490 | 491 | an application object, but DO NOT start the event loop yourself, as |
|
491 | 492 | we have already handled that. |
|
492 | 493 | """ |
|
493 | 494 | opts, arg = self.parse_options(parameter_s, '') |
|
494 | 495 | if arg=='': arg = None |
|
495 | 496 | try: |
|
496 | 497 | return self.shell.enable_gui(arg) |
|
497 | 498 | except Exception as e: |
|
498 | 499 | # print simple error message, rather than traceback if we can't |
|
499 | 500 | # hook up the GUI |
|
500 | 501 | error(str(e)) |
|
501 | 502 | |
|
502 | 503 | @skip_doctest |
|
503 | 504 | @line_magic |
|
504 | 505 | def precision(self, s=''): |
|
505 | 506 | """Set floating point precision for pretty printing. |
|
506 | 507 | |
|
507 | 508 | Can set either integer precision or a format string. |
|
508 | 509 | |
|
509 | 510 | If numpy has been imported and precision is an int, |
|
510 | 511 | numpy display precision will also be set, via ``numpy.set_printoptions``. |
|
511 | 512 | |
|
512 | 513 | If no argument is given, defaults will be restored. |
|
513 | 514 | |
|
514 | 515 | Examples |
|
515 | 516 | -------- |
|
516 | 517 | :: |
|
517 | 518 | |
|
518 | 519 | In [1]: from math import pi |
|
519 | 520 | |
|
520 | 521 | In [2]: %precision 3 |
|
521 | 522 | Out[2]: u'%.3f' |
|
522 | 523 | |
|
523 | 524 | In [3]: pi |
|
524 | 525 | Out[3]: 3.142 |
|
525 | 526 | |
|
526 | 527 | In [4]: %precision %i |
|
527 | 528 | Out[4]: u'%i' |
|
528 | 529 | |
|
529 | 530 | In [5]: pi |
|
530 | 531 | Out[5]: 3 |
|
531 | 532 | |
|
532 | 533 | In [6]: %precision %e |
|
533 | 534 | Out[6]: u'%e' |
|
534 | 535 | |
|
535 | 536 | In [7]: pi**10 |
|
536 | 537 | Out[7]: 9.364805e+04 |
|
537 | 538 | |
|
538 | 539 | In [8]: %precision |
|
539 | 540 | Out[8]: u'%r' |
|
540 | 541 | |
|
541 | 542 | In [9]: pi**10 |
|
542 | 543 | Out[9]: 93648.047476082982 |
|
543 | 544 | """ |
|
544 | 545 | ptformatter = self.shell.display_formatter.formatters['text/plain'] |
|
545 | 546 | ptformatter.float_precision = s |
|
546 | 547 | return ptformatter.float_format |
|
547 | 548 | |
|
548 | 549 | @magic_arguments.magic_arguments() |
|
549 | 550 | @magic_arguments.argument( |
|
550 | 551 | '-e', '--export', action='store_true', default=False, |
|
551 | help='Export IPython history as a notebook. The filename argument ' | |
|
552 | 'is used to specify the notebook name and format. For example ' | |
|
553 | 'a filename of notebook.ipynb will result in a notebook name ' | |
|
554 | 'of "notebook" and a format of "json". Likewise using a ".py" ' | |
|
555 | 'file extension will write the notebook as a Python script' | |
|
552 | help=argparse.SUPPRESS | |
|
556 | 553 | ) |
|
557 | 554 | @magic_arguments.argument( |
|
558 | 555 | 'filename', type=unicode_type, |
|
559 | 556 | help='Notebook name or filename' |
|
560 | 557 | ) |
|
561 | 558 | @line_magic |
|
562 | 559 | def notebook(self, s): |
|
563 | 560 | """Export and convert IPython notebooks. |
|
564 | 561 | |
|
565 | 562 | This function can export the current IPython history to a notebook file. |
|
566 |
For example, to export the history to "foo.ipynb" do "%notebook |
|
|
567 | To export the history to "foo.py" do "%notebook -e foo.py". | |
|
563 | For example, to export the history to "foo.ipynb" do "%notebook foo.ipynb". | |
|
564 | ||
|
565 | The -e or --export flag is deprecated in IPython 5.2, and will be | |
|
566 | removed in the future. | |
|
568 | 567 | """ |
|
569 | 568 | args = magic_arguments.parse_argstring(self.notebook, s) |
|
570 | 569 | |
|
571 | 570 | from nbformat import write, v4 |
|
572 | if args.export: | |
|
573 |
|
|
|
574 |
|
|
|
575 |
|
|
|
576 |
|
|
|
577 |
|
|
|
578 |
|
|
|
579 |
|
|
|
580 |
|
|
|
581 |
|
|
|
582 |
|
|
|
583 |
|
|
|
584 |
|
|
|
571 | ||
|
572 | cells = [] | |
|
573 | hist = list(self.shell.history_manager.get_range()) | |
|
574 | if(len(hist)<=1): | |
|
575 | raise ValueError('History is empty, cannot export') | |
|
576 | for session, execution_count, source in hist[:-1]: | |
|
577 | cells.append(v4.new_code_cell( | |
|
578 | execution_count=execution_count, | |
|
579 | source=source | |
|
580 | )) | |
|
581 | nb = v4.new_notebook(cells=cells) | |
|
582 | with io.open(args.filename, 'w', encoding='utf-8') as f: | |
|
583 | write(nb, f, version=4) |
@@ -1,123 +1,121 | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | """Release data for the IPython project.""" |
|
3 | 3 | |
|
4 | 4 | #----------------------------------------------------------------------------- |
|
5 | 5 | # Copyright (c) 2008, IPython Development Team. |
|
6 | 6 | # Copyright (c) 2001, Fernando Perez <fernando.perez@colorado.edu> |
|
7 | 7 | # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de> |
|
8 | 8 | # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu> |
|
9 | 9 | # |
|
10 | 10 | # Distributed under the terms of the Modified BSD License. |
|
11 | 11 | # |
|
12 | 12 | # The full license is in the file COPYING.txt, distributed with this software. |
|
13 | 13 | #----------------------------------------------------------------------------- |
|
14 | 14 | |
|
15 | 15 | # Name of the package for release purposes. This is the name which labels |
|
16 | 16 | # the tarballs and RPMs made by distutils, so it's best to lowercase it. |
|
17 | 17 | name = 'ipython' |
|
18 | 18 | |
|
19 | 19 | # IPython version information. An empty _version_extra corresponds to a full |
|
20 | 20 | # release. 'dev' as a _version_extra string means this is a development |
|
21 | 21 | # version |
|
22 |
_version_major = |
|
|
23 |
_version_minor = |
|
|
22 | _version_major = 6 | |
|
23 | _version_minor = 0 | |
|
24 | 24 | _version_patch = 0 |
|
25 | 25 | _version_extra = '.dev' |
|
26 | 26 | # _version_extra = 'rc1' |
|
27 | #_version_extra = '' # Uncomment this for full releases | |
|
27 | # _version_extra = '' # Uncomment this for full releases | |
|
28 | 28 | |
|
29 | 29 | # release.codename is deprecated in 2.0, will be removed in 3.0 |
|
30 | 30 | codename = '' |
|
31 | 31 | |
|
32 | 32 | # Construct full version string from these. |
|
33 | 33 | _ver = [_version_major, _version_minor, _version_patch] |
|
34 | 34 | |
|
35 | 35 | __version__ = '.'.join(map(str, _ver)) |
|
36 | 36 | if _version_extra: |
|
37 | 37 | __version__ = __version__ + _version_extra |
|
38 | 38 | |
|
39 | 39 | version = __version__ # backwards compatibility name |
|
40 | 40 | version_info = (_version_major, _version_minor, _version_patch, _version_extra) |
|
41 | 41 | |
|
42 | 42 | # Change this when incrementing the kernel protocol version |
|
43 | 43 | kernel_protocol_version_info = (5, 0) |
|
44 | 44 | kernel_protocol_version = "%i.%i" % kernel_protocol_version_info |
|
45 | 45 | |
|
46 | 46 | description = "IPython: Productive Interactive Computing" |
|
47 | 47 | |
|
48 | 48 | long_description = \ |
|
49 | 49 | """ |
|
50 | 50 | IPython provides a rich toolkit to help you make the most out of using Python |
|
51 | 51 | interactively. Its main components are: |
|
52 | 52 | |
|
53 | 53 | * A powerful interactive Python shell |
|
54 | 54 | * A `Jupyter <http://jupyter.org/>`_ kernel to work with Python code in Jupyter |
|
55 | 55 | notebooks and other interactive frontends. |
|
56 | 56 | |
|
57 | 57 | The enhanced interactive Python shells have the following main features: |
|
58 | 58 | |
|
59 | 59 | * Comprehensive object introspection. |
|
60 | 60 | |
|
61 | 61 | * Input history, persistent across sessions. |
|
62 | 62 | |
|
63 | 63 | * Caching of output results during a session with automatically generated |
|
64 | 64 | references. |
|
65 | 65 | |
|
66 | 66 | * Extensible tab completion, with support by default for completion of python |
|
67 | 67 | variables and keywords, filenames and function keywords. |
|
68 | 68 | |
|
69 | 69 | * Extensible system of 'magic' commands for controlling the environment and |
|
70 | 70 | performing many tasks related either to IPython or the operating system. |
|
71 | 71 | |
|
72 | 72 | * A rich configuration system with easy switching between different setups |
|
73 | 73 | (simpler than changing $PYTHONSTARTUP environment variables every time). |
|
74 | 74 | |
|
75 | 75 | * Session logging and reloading. |
|
76 | 76 | |
|
77 | 77 | * Extensible syntax processing for special purpose situations. |
|
78 | 78 | |
|
79 | 79 | * Access to the system shell with user-extensible alias system. |
|
80 | 80 | |
|
81 | 81 | * Easily embeddable in other Python programs and GUIs. |
|
82 | 82 | |
|
83 | 83 | * Integrated access to the pdb debugger and the Python profiler. |
|
84 | 84 | |
|
85 | 85 | The latest development version is always available from IPython's `GitHub |
|
86 | 86 | site <http://github.com/ipython>`_. |
|
87 | 87 | """ |
|
88 | 88 | |
|
89 | 89 | license = 'BSD' |
|
90 | 90 | |
|
91 | 91 | authors = {'Fernando' : ('Fernando Perez','fperez.net@gmail.com'), |
|
92 | 92 | 'Janko' : ('Janko Hauser','jhauser@zscout.de'), |
|
93 | 93 | 'Nathan' : ('Nathaniel Gray','n8gray@caltech.edu'), |
|
94 | 94 | 'Ville' : ('Ville Vainio','vivainio@gmail.com'), |
|
95 | 95 | 'Brian' : ('Brian E Granger', 'ellisonbg@gmail.com'), |
|
96 | 96 | 'Min' : ('Min Ragan-Kelley', 'benjaminrk@gmail.com'), |
|
97 | 97 | 'Thomas' : ('Thomas A. Kluyver', 'takowl@gmail.com'), |
|
98 | 98 | 'Jorgen' : ('Jorgen Stenarson', 'jorgen.stenarson@bostream.nu'), |
|
99 | 99 | 'Matthias' : ('Matthias Bussonnier', 'bussonniermatthias@gmail.com'), |
|
100 | 100 | } |
|
101 | 101 | |
|
102 | 102 | author = 'The IPython Development Team' |
|
103 | 103 | |
|
104 | 104 | author_email = 'ipython-dev@scipy.org' |
|
105 | 105 | |
|
106 | 106 | url = 'http://ipython.org' |
|
107 | 107 | |
|
108 | 108 | |
|
109 | 109 | platforms = ['Linux','Mac OSX','Windows'] |
|
110 | 110 | |
|
111 | 111 | keywords = ['Interactive','Interpreter','Shell', 'Embedding'] |
|
112 | 112 | |
|
113 | 113 | classifiers = [ |
|
114 | 114 | 'Framework :: IPython', |
|
115 | 115 | 'Intended Audience :: Developers', |
|
116 | 116 | 'Intended Audience :: Science/Research', |
|
117 | 117 | 'License :: OSI Approved :: BSD License', |
|
118 | 118 | 'Programming Language :: Python', |
|
119 | 'Programming Language :: Python :: 2', | |
|
120 | 'Programming Language :: Python :: 2.7', | |
|
121 | 119 | 'Programming Language :: Python :: 3', |
|
122 | 120 | 'Topic :: System :: Shells' |
|
123 | 121 | ] |
@@ -1,51 +1,51 | |||
|
1 | 1 | .. image:: https://codecov.io/github/ipython/ipython/coverage.svg?branch=master |
|
2 | 2 | :target: https://codecov.io/github/ipython/ipython?branch=master |
|
3 | 3 | |
|
4 | 4 | .. image:: https://img.shields.io/pypi/dm/IPython.svg |
|
5 | 5 | :target: https://pypi.python.org/pypi/ipython |
|
6 | 6 | |
|
7 | 7 | .. image:: https://img.shields.io/pypi/v/IPython.svg |
|
8 | 8 | :target: https://pypi.python.org/pypi/ipython |
|
9 | 9 | |
|
10 | 10 | .. image:: https://img.shields.io/travis/ipython/ipython.svg |
|
11 | 11 | :target: https://travis-ci.org/ipython/ipython |
|
12 | 12 | |
|
13 | 13 | |
|
14 | 14 | =========================================== |
|
15 | 15 | IPython: Productive Interactive Computing |
|
16 | 16 | =========================================== |
|
17 | 17 | |
|
18 | 18 | Overview |
|
19 | 19 | ======== |
|
20 | 20 | |
|
21 | 21 | Welcome to IPython. Our full documentation is available on `ipython.readthedocs.io |
|
22 | 22 | <https://ipython.readthedocs.io/en/stable/>`_ and contain information on how to install, use |
|
23 | 23 | contribute to the project. |
|
24 | 24 | |
|
25 |
Officially, IPython requires Python version |
|
|
26 |
IPython |
|
|
25 | Officially, IPython requires Python version 3.3 and above. | |
|
26 | IPython 5.x is the last IPython version to support Python 2.7. | |
|
27 | 27 | |
|
28 | 28 | The Notebook, Qt console and a number of other pieces are now parts of *Jupyter*. |
|
29 | 29 | See the `Jupyter installation docs <http://jupyter.readthedocs.io/en/latest/install.html>`__ |
|
30 | 30 | if you want to use these. |
|
31 | 31 | |
|
32 | 32 | |
|
33 | 33 | |
|
34 | 34 | |
|
35 | 35 | Developement and Instant runnimg |
|
36 | 36 | ================================ |
|
37 | 37 | |
|
38 | 38 | You can find the latest version of the development documentation on `readthedocs |
|
39 | 39 | <http://ipython.readthedocs.io/en/latest/>`_. |
|
40 | 40 | |
|
41 | 41 | You can run IPython from this directory without even installing it system-wide |
|
42 | 42 | by typing at the terminal:: |
|
43 | 43 | |
|
44 | 44 | $ python -m IPython |
|
45 | 45 | |
|
46 | 46 | Or see the `developement installation docs |
|
47 | 47 | <http://ipython.readthedocs.io/en/latest/install/install.html#installing-the-development-version>`_ |
|
48 | 48 | for the latest revision on read the docs. |
|
49 | 49 | |
|
50 | 50 | Documentation and installation instructions for older version of IPython can be |
|
51 | 51 | found on the `IPython website <http://ipython.org/documentation.html>`_ |
@@ -1,52 +1,54 | |||
|
1 | 1 | .. _integrating: |
|
2 | 2 | |
|
3 | 3 | ===================================== |
|
4 | 4 | Integrating your objects with IPython |
|
5 | 5 | ===================================== |
|
6 | 6 | |
|
7 | 7 | Tab completion |
|
8 | 8 | ============== |
|
9 | 9 | |
|
10 | 10 | To change the attributes displayed by tab-completing your object, define a |
|
11 | 11 | ``__dir__(self)`` method for it. For more details, see the documentation of the |
|
12 | 12 | built-in `dir() function <http://docs.python.org/library/functions.html#dir>`_. |
|
13 | 13 | |
|
14 | 14 | You can also customise key completions for your objects, e.g. pressing tab after |
|
15 | 15 | ``obj["a``. To do so, define a method ``_ipython_key_completions_()``, which |
|
16 | 16 | returns a list of objects which are possible keys in a subscript expression |
|
17 | 17 | ``obj[key]``. |
|
18 | 18 | |
|
19 | 19 | .. versionadded:: 5.0 |
|
20 | 20 | Custom key completions |
|
21 | 21 | |
|
22 | 22 | Rich display |
|
23 | 23 | ============ |
|
24 | 24 | |
|
25 | 25 | The notebook and the Qt console can display richer representations of objects. |
|
26 | 26 | To use this, you can define any of a number of ``_repr_*_()`` methods. Note that |
|
27 | 27 | these are surrounded by single, not double underscores. |
|
28 | 28 | |
|
29 | 29 | Both the notebook and the Qt console can display ``svg``, ``png`` and ``jpeg`` |
|
30 | 30 | representations. The notebook can also display ``html``, ``javascript``, |
|
31 | 31 | and ``latex``. If the methods don't exist, or return ``None``, it falls |
|
32 | 32 | back to a standard ``repr()``. |
|
33 | 33 | |
|
34 | 34 | For example:: |
|
35 | 35 | |
|
36 | 36 | class Shout(object): |
|
37 | 37 | def __init__(self, text): |
|
38 | 38 | self.text = text |
|
39 | 39 | |
|
40 | 40 | def _repr_html_(self): |
|
41 | 41 | return "<h1>" + self.text + "</h1>" |
|
42 | 42 | |
|
43 | 43 | Custom exception tracebacks |
|
44 | 44 | =========================== |
|
45 | 45 | |
|
46 |
Rarely, you might want to display a |
|
|
47 | IPython's own parallel computing framework does this to display errors from the | |
|
48 |
|
|
|
49 | a list of strings, each containing one line of the traceback. | |
|
46 | Rarely, you might want to display a custom traceback when reporting an | |
|
47 | exception. To do this, define the custom traceback using | |
|
48 | `_render_traceback_(self)` method which returns a list of strings, one string | |
|
49 | for each line of the traceback. For example, the `ipyparallel | |
|
50 | <http://ipyparallel.readthedocs.io/>`__ a parallel computing framework for | |
|
51 | IPython, does this to display errors from multiple engines. | |
|
50 | 52 | |
|
51 | 53 | Please be conservative in using this feature; by replacing the default traceback |
|
52 | 54 | you may hide important information from the user. |
@@ -1,244 +1,246 | |||
|
1 | 1 | .. _release_process: |
|
2 | 2 | |
|
3 | 3 | ======================= |
|
4 | 4 | IPython release process |
|
5 | 5 | ======================= |
|
6 | 6 | |
|
7 | 7 | This document contains the process that is used to create an IPython release. |
|
8 | 8 | |
|
9 | 9 | Conveniently, the ``release`` script in the ``tools`` directory of the ``IPython`` |
|
10 | 10 | repository automates most of the release process. This document serves as a |
|
11 | 11 | handy reminder and checklist for the release manager. |
|
12 | 12 | |
|
13 | 13 | During the release process, you might need the extra following dependencies: |
|
14 | 14 | |
|
15 | 15 | - ``keyring`` to access your GitHub authentication tokens |
|
16 | 16 | - ``graphviz`` to generate some graphs in the documentation |
|
17 | 17 | |
|
18 | 18 | Make sure you have all the required dependencies to run the tests as well. |
|
19 | 19 | |
|
20 | 20 | |
|
21 | 21 | 1. Set Environment variables |
|
22 | 22 | ---------------------------- |
|
23 | 23 | |
|
24 | 24 | Set environment variables to document previous release tag, current |
|
25 | 25 | release milestone, current release version, and git tag. |
|
26 | 26 | |
|
27 | 27 | These variables may be used later to copy/paste as answers to the script |
|
28 | 28 | questions instead of typing the appropriate command when the time comes. These |
|
29 | 29 | variables are not used by the scripts directly; therefore, there is no need to |
|
30 | 30 | ``export`` them. The format for bash is as follows, but note that these values |
|
31 | 31 | are just an example valid only for the 5.0 release; you'll need to update them |
|
32 | 32 | for the release you are actually making:: |
|
33 | 33 | |
|
34 | 34 | PREV_RELEASE=4.2.1 |
|
35 | 35 | MILESTONE=5.0 |
|
36 | 36 | VERSION=5.0.0 |
|
37 | 37 | BRANCH=master |
|
38 | 38 | |
|
39 | 39 | |
|
40 | 40 | 2. Create GitHub stats and finish release note |
|
41 | 41 | ---------------------------------------------- |
|
42 | 42 | |
|
43 | 43 | .. note:: |
|
44 | 44 | |
|
45 | 45 | This step is optional if making a Beta or RC release. |
|
46 | 46 | |
|
47 | 47 | .. note:: |
|
48 | 48 | |
|
49 | 49 | Before generating the GitHub stats, verify that all closed issues and pull |
|
50 | 50 | requests have `appropriate milestones |
|
51 | 51 | <https://github.com/ipython/ipython/wiki/Dev%3A-GitHub-workflow#milestones>`_. |
|
52 | 52 | `This search |
|
53 | 53 | <https://github.com/ipython/ipython/issues?q=is%3Aclosed+no%3Amilestone+is%3Aissue>`_ |
|
54 | 54 | should return no results before creating the GitHub stats. |
|
55 | 55 | |
|
56 | 56 | If a major release: |
|
57 | 57 | |
|
58 | 58 | - merge any pull request notes into what's new:: |
|
59 | 59 | |
|
60 | 60 | python tools/update_whatsnew.py |
|
61 | 61 | |
|
62 | 62 | - update ``docs/source/whatsnew/development.rst``, to ensure it covers |
|
63 | 63 | the major release features |
|
64 | 64 | |
|
65 | 65 | - move the contents of ``development.rst`` to ``versionX.rst`` where ``X`` is |
|
66 | 66 | the numerical release version |
|
67 | 67 | |
|
68 | 68 | - generate summary of GitHub contributions, which can be done with:: |
|
69 | 69 | |
|
70 | 70 | python tools/github_stats.py --milestone $MILESTONE > stats.rst |
|
71 | 71 | |
|
72 | 72 | which may need some manual cleanup of ``stats.rst``. Add the cleaned |
|
73 | 73 | ``stats.rst`` results to ``docs/source/whatsnew/github-stats-X.rst`` |
|
74 | 74 | where ``X`` is the numerical release version (don't forget to add it to |
|
75 | 75 | the git repo as well). If creating a major release, make a new |
|
76 | 76 | ``github-stats-X.rst`` file; if creating a minor release, the content |
|
77 | 77 | from ``stats.rst`` may simply be added to the top of an existing |
|
78 | 78 | ``github-stats-X.rst`` file. Finally, edit |
|
79 | 79 | ``docs/source/whatsnew/index.rst`` to list the new ``github-stats-X`` |
|
80 | 80 | file you just created and remove temporarily the first entry called |
|
81 | 81 | ``development`` (you'll need to add it back after release). |
|
82 | 82 | |
|
83 | 83 | Make sure that the stats file has a header or it won't be rendered in |
|
84 | 84 | the final documentation. |
|
85 | 85 | |
|
86 | 86 | To find duplicates and update `.mailmap`, use:: |
|
87 | 87 | |
|
88 | 88 | git log --format="%aN <%aE>" $PREV_RELEASE... | sort -u -f |
|
89 | 89 | |
|
90 | 90 | 3. Make sure the repository is clean |
|
91 | 91 | ------------------------------------ |
|
92 | 92 | |
|
93 | 93 | of any file that could be problematic. |
|
94 | 94 | Remove all non-tracked files with: |
|
95 | 95 | |
|
96 | 96 | .. code:: |
|
97 | 97 | |
|
98 | 98 | git clean -xfdi |
|
99 | 99 | |
|
100 | 100 | This will ask for confirmation before removing all untracked files. Make |
|
101 | 101 | sure the ``dist/`` folder is clean to avoid any stale builds from |
|
102 | 102 | previous build attempts. |
|
103 | 103 | |
|
104 | 104 | |
|
105 | 105 | 4. Update the release version number |
|
106 | 106 | ------------------------------------ |
|
107 | 107 | |
|
108 | 108 | Edit ``IPython/core/release.py`` to have the current version. |
|
109 | 109 | |
|
110 | 110 | in particular, update version number and ``_version_extra`` content in |
|
111 | 111 | ``IPython/core/release.py``. |
|
112 | 112 | |
|
113 | 113 | Step 5 will validate your changes automatically, but you might still want to |
|
114 | 114 | make sure the version number matches pep440. |
|
115 | 115 | |
|
116 | 116 | In particular, ``rc`` and ``beta`` are not separated by ``.`` or the ``sdist`` |
|
117 | 117 | and ``bdist`` will appear as different releases. For example, a valid version |
|
118 | 118 | number for a release candidate (rc) release is: ``1.3rc1``. Notice that there |
|
119 | 119 | is no separator between the '3' and the 'r'. Check the environment variable |
|
120 | 120 | ``$VERSION`` as well. |
|
121 | 121 | |
|
122 | 122 | You will likely just have to modify/comment/uncomment one of the lines setting |
|
123 | 123 | ``_version_extra`` |
|
124 | 124 | |
|
125 | 125 | |
|
126 | 126 | 5. Run the `tools/build_release` script |
|
127 | 127 | --------------------------------------- |
|
128 | 128 | |
|
129 | 129 | Running ``tools/build_release`` does all the file checking and building that |
|
130 | 130 | the real release script will do. This makes test installations, checks that |
|
131 | 131 | the build procedure runs OK, and tests other steps in the release process. |
|
132 | 132 | |
|
133 | 133 | The ``build_release`` script will in particular verify that the version number |
|
134 | 134 | match PEP 440, in order to avoid surprise at the time of build upload. |
|
135 | 135 | |
|
136 | 136 | We encourage creating a test build of the docs as well. |
|
137 | 137 | |
|
138 | 138 | 6. Create and push the new tag |
|
139 | 139 | ------------------------------ |
|
140 | 140 | |
|
141 | 141 | Commit the changes to release.py:: |
|
142 | 142 | |
|
143 | 143 | git commit -am "release $VERSION" |
|
144 | 144 | git push origin $BRANCH |
|
145 | 145 | |
|
146 | 146 | Create and push the tag:: |
|
147 | 147 | |
|
148 | 148 | git tag -am "release $VERSION" "$VERSION" |
|
149 | 149 | git push origin --tags |
|
150 | 150 | |
|
151 | 151 | Update release.py back to ``x.y-dev`` or ``x.y-maint``, and re-add the |
|
152 | 152 | ``development`` entry in ``docs/source/whatsnew/index.rst`` and push:: |
|
153 | 153 | |
|
154 | 154 | git commit -am "back to development" |
|
155 | 155 | git push origin $BRANCH |
|
156 | 156 | |
|
157 | 157 | 7. Get a fresh clone |
|
158 | 158 | -------------------- |
|
159 | 159 | |
|
160 | 160 | Get a fresh clone of the tag for building the release:: |
|
161 | 161 | |
|
162 | 162 | cd /tmp |
|
163 | 163 | git clone --depth 1 https://github.com/ipython/ipython.git -b "$VERSION" |
|
164 | 164 | cd ipython |
|
165 | 165 | |
|
166 | 166 | .. note:: |
|
167 | 167 | |
|
168 | 168 | You can aslo cleanup the current working repository with ``git clean -xfdi`` |
|
169 | 169 | |
|
170 | 170 | 8. Run the release script |
|
171 | 171 | ------------------------- |
|
172 | 172 | |
|
173 | 173 | Run the ``release`` script, this step requires having a current wheel, Python |
|
174 | 174 | >=3.4 and Python 2.7.:: |
|
175 | 175 | |
|
176 | 176 | ./tools/release |
|
177 | 177 | |
|
178 | 178 | This makes the tarballs, zipfiles, and wheels, and put them under the ``dist/`` |
|
179 |
folder. Be sure to test the ``wheel`` and the ``sdist`` locally before |
|
|
180 | them to PyPI. | |
|
179 | folder. Be sure to test the ``wheels`` and the ``sdist`` locally before | |
|
180 | uploading them to PyPI. We do not use an universal wheel as each wheel | |
|
181 | installs an ``ipython2`` or ``ipython3`` script, depending on the version of | |
|
182 | Python it is built for. Using an universal wheel would prevent this. | |
|
181 | 183 | |
|
182 | 184 | Use the following to actually upload the result of the build:: |
|
183 | 185 | |
|
184 | 186 | ./tools/release upload |
|
185 | 187 | |
|
186 | 188 | It should posts them to ``archive.ipython.org``. |
|
187 | 189 | |
|
188 | 190 | You will need to use `twine <https://github.com/pypa/twine>`_ ) manually to |
|
189 | 191 | actually upload on PyPI. Unlike setuptools, twine is able to upload packages |
|
190 | 192 | over SSL. |
|
191 | 193 | |
|
192 | 194 | twine upload dist/* |
|
193 | 195 | |
|
194 | 196 | |
|
195 | 197 | PyPI/Warehouse will automatically hide previous releases. If you are uploading |
|
196 | 198 | a non-stable version, make sure to log-in to PyPI and un-hide previous version. |
|
197 | 199 | |
|
198 | 200 | |
|
199 | 201 | 9. Draft a short release announcement |
|
200 | 202 | ------------------------------------- |
|
201 | 203 | |
|
202 | 204 | The announcement should include: |
|
203 | 205 | |
|
204 | 206 | - release highlights |
|
205 | 207 | - a link to the html version of the *What's new* section of the documentation |
|
206 | 208 | - a link to upgrade or installation tips (if necessary) |
|
207 | 209 | |
|
208 | 210 | Post the announcement to the mailing list and or blog, and link from Twitter. |
|
209 | 211 | |
|
210 | 212 | .. note:: |
|
211 | 213 | |
|
212 | 214 | If you are doing a RC or Beta, you can likely skip the next steps. |
|
213 | 215 | |
|
214 | 216 | 10. Update milestones on GitHub |
|
215 | 217 | ------------------------------- |
|
216 | 218 | |
|
217 | 219 | These steps will bring milestones up to date: |
|
218 | 220 | |
|
219 | 221 | - close the just released milestone |
|
220 | 222 | - open a new milestone for the next release (x, y+1), if the milestone doesn't |
|
221 | 223 | exist already |
|
222 | 224 | |
|
223 | 225 | 11. Update the IPython website |
|
224 | 226 | ------------------------------ |
|
225 | 227 | |
|
226 | 228 | The IPython website should document the new release: |
|
227 | 229 | |
|
228 | 230 | - add release announcement (news, announcements) |
|
229 | 231 | - update current version and download links |
|
230 | 232 | - update links on the documentation page (especially if a major release) |
|
231 | 233 | |
|
232 | 234 | 12. Update readthedocs |
|
233 | 235 | ---------------------- |
|
234 | 236 | |
|
235 | 237 | Make sure to update readthedocs and set the latest tag as stable, as well as |
|
236 | 238 | checking that previous release is still building under its own tag. |
|
237 | 239 | |
|
238 | 240 | |
|
239 | 241 | 13. Celebrate! |
|
240 | 242 | -------------- |
|
241 | 243 | |
|
242 | 244 | Celebrate the release and please thank the contributors for their work. Great |
|
243 | 245 | job! |
|
244 | 246 |
@@ -1,135 +1,132 | |||
|
1 | 1 | .. _config_overview: |
|
2 | 2 | |
|
3 | 3 | ============================================ |
|
4 | 4 | Overview of the IPython configuration system |
|
5 | 5 | ============================================ |
|
6 | 6 | |
|
7 | 7 | This section describes the IPython configuration system. This is based on |
|
8 | 8 | :mod:`traitlets.config`; see that documentation for more information |
|
9 | 9 | about the overall architecture. |
|
10 | 10 | |
|
11 | 11 | Configuration file location |
|
12 | 12 | =========================== |
|
13 | 13 | |
|
14 | 14 | So where should you put your configuration files? IPython uses "profiles" for |
|
15 | 15 | configuration, and by default, all profiles will be stored in the so called |
|
16 | 16 | "IPython directory". The location of this directory is determined by the |
|
17 | 17 | following algorithm: |
|
18 | 18 | |
|
19 | 19 | * If the ``ipython-dir`` command line flag is given, its value is used. |
|
20 | 20 | |
|
21 | 21 | * If not, the value returned by :func:`IPython.paths.get_ipython_dir` |
|
22 | 22 | is used. This function will first look at the :envvar:`IPYTHONDIR` |
|
23 | 23 | environment variable and then default to :file:`~/.ipython`. |
|
24 | 24 | Historical support for the :envvar:`IPYTHON_DIR` environment variable will |
|
25 | 25 | be removed in a future release. |
|
26 | 26 | |
|
27 | 27 | For most users, the configuration directory will be :file:`~/.ipython`. |
|
28 | 28 | |
|
29 | 29 | Previous versions of IPython on Linux would use the XDG config directory, |
|
30 | 30 | creating :file:`~/.config/ipython` by default. We have decided to go |
|
31 | 31 | back to :file:`~/.ipython` for consistency among systems. IPython will |
|
32 | 32 | issue a warning if it finds the XDG location, and will move it to the new |
|
33 | 33 | location if there isn't already a directory there. |
|
34 | 34 | |
|
35 | 35 | Once the location of the IPython directory has been determined, you need to know |
|
36 | 36 | which profile you are using. For users with a single configuration, this will |
|
37 | 37 | simply be 'default', and will be located in |
|
38 | 38 | :file:`<IPYTHONDIR>/profile_default`. |
|
39 | 39 | |
|
40 | 40 | The next thing you need to know is what to call your configuration file. The |
|
41 | 41 | basic idea is that each application has its own default configuration filename. |
|
42 | 42 | The default named used by the :command:`ipython` command line program is |
|
43 | 43 | :file:`ipython_config.py`, and *all* IPython applications will use this file. |
|
44 | Other applications, such as the parallel :command:`ipcluster` scripts or the | |
|
45 | QtConsole will load their own config files *after* :file:`ipython_config.py`. To | |
|
46 | load a particular configuration file instead of the default, the name can be | |
|
47 | overridden by the ``config_file`` command line flag. | |
|
44 | The IPython kernel will load its own config file *after* | |
|
45 | :file:`ipython_config.py`. To load a particular configuration file instead of | |
|
46 | the default, the name can be overridden by the ``config_file`` command line | |
|
47 | flag. | |
|
48 | 48 | |
|
49 | 49 | To generate the default configuration files, do:: |
|
50 | 50 | |
|
51 | 51 | $ ipython profile create |
|
52 | 52 | |
|
53 | 53 | and you will have a default :file:`ipython_config.py` in your IPython directory |
|
54 | under :file:`profile_default`. If you want the default config files for the | |
|
55 | :mod:`IPython.parallel` applications, add ``--parallel`` to the end of the | |
|
56 | command-line args. | |
|
57 | ||
|
54 | under :file:`profile_default`. | |
|
58 | 55 | .. note:: |
|
59 | 56 | |
|
60 | 57 | IPython configuration options are case sensitive, and IPython cannot |
|
61 | 58 | catch misnamed keys or invalid values. |
|
62 | 59 | |
|
63 | 60 | By default IPython will also ignore any invalid configuration files. |
|
64 | 61 | |
|
65 | 62 | .. versionadded:: 5.0 |
|
66 | 63 | |
|
67 | 64 | IPython can be configured to abort in case of invalid configuration file. |
|
68 | 65 | To do so set the environment variable ``IPYTHON_SUPPRESS_CONFIG_ERRORS`` to |
|
69 | 66 | `'1'` or `'true'` |
|
70 | 67 | |
|
71 | 68 | |
|
72 | 69 | Locating these files |
|
73 | 70 | -------------------- |
|
74 | 71 | |
|
75 | 72 | From the command-line, you can quickly locate the IPYTHONDIR or a specific |
|
76 | 73 | profile with: |
|
77 | 74 | |
|
78 | 75 | .. sourcecode:: bash |
|
79 | 76 | |
|
80 | 77 | $ ipython locate |
|
81 | 78 | /home/you/.ipython |
|
82 | 79 | |
|
83 | 80 | $ ipython locate profile foo |
|
84 | 81 | /home/you/.ipython/profile_foo |
|
85 | 82 | |
|
86 | 83 | These map to the utility functions: :func:`IPython.utils.path.get_ipython_dir` |
|
87 | 84 | and :func:`IPython.utils.path.locate_profile` respectively. |
|
88 | 85 | |
|
89 | 86 | |
|
90 | 87 | .. _profiles_dev: |
|
91 | 88 | |
|
92 | 89 | Profiles |
|
93 | 90 | ======== |
|
94 | 91 | |
|
95 | 92 | A profile is a directory containing configuration and runtime files, such as |
|
96 | 93 | logs, connection info for the parallel apps, and your IPython command history. |
|
97 | 94 | |
|
98 | 95 | The idea is that users often want to maintain a set of configuration files for |
|
99 | 96 | different purposes: one for doing numerical computing with NumPy and SciPy and |
|
100 | 97 | another for doing symbolic computing with SymPy. Profiles make it easy to keep a |
|
101 | 98 | separate configuration files, logs, and histories for each of these purposes. |
|
102 | 99 | |
|
103 | 100 | Let's start by showing how a profile is used: |
|
104 | 101 | |
|
105 | 102 | .. code-block:: bash |
|
106 | 103 | |
|
107 | 104 | $ ipython --profile=sympy |
|
108 | 105 | |
|
109 | 106 | This tells the :command:`ipython` command line program to get its configuration |
|
110 | 107 | from the "sympy" profile. The file names for various profiles do not change. The |
|
111 | 108 | only difference is that profiles are named in a special way. In the case above, |
|
112 | 109 | the "sympy" profile means looking for :file:`ipython_config.py` in :file:`<IPYTHONDIR>/profile_sympy`. |
|
113 | 110 | |
|
114 | 111 | The general pattern is this: simply create a new profile with: |
|
115 | 112 | |
|
116 | 113 | .. code-block:: bash |
|
117 | 114 | |
|
118 | 115 | $ ipython profile create <name> |
|
119 | 116 | |
|
120 | 117 | which adds a directory called ``profile_<name>`` to your IPython directory. Then |
|
121 | 118 | you can load this profile by adding ``--profile=<name>`` to your command line |
|
122 | 119 | options. Profiles are supported by all IPython applications. |
|
123 | 120 | |
|
124 | 121 | IPython ships with some sample profiles in :file:`IPython/config/profile`. If |
|
125 | 122 | you create profiles with the name of one of our shipped profiles, these config |
|
126 | 123 | files will be copied over instead of starting with the automatically generated |
|
127 | 124 | config files. |
|
128 | 125 | |
|
129 | 126 | IPython extends the config loader for Python files so that you can inherit |
|
130 | 127 | config from another profile. To do this, use a line like this in your Python |
|
131 | 128 | config file: |
|
132 | 129 | |
|
133 | 130 | .. sourcecode:: python |
|
134 | 131 | |
|
135 | 132 | load_subconfig('ipython_config.py', profile='default') |
@@ -1,144 +1,144 | |||
|
1 | 1 | .. _install: |
|
2 | 2 | |
|
3 | 3 | Installing IPython |
|
4 | 4 | ================== |
|
5 | 5 | |
|
6 | 6 | |
|
7 | IPython requires Python 2.7 or ≥ 3.3. | |
|
7 | IPython 6 requires Python ≥ 3.3. IPython 5.x can be installed on Python 2. | |
|
8 | 8 | |
|
9 | 9 | |
|
10 | 10 | Quick Install |
|
11 | 11 | ------------- |
|
12 | 12 | |
|
13 | 13 | With ``pip`` already installed : |
|
14 | 14 | |
|
15 | 15 | .. code-block:: bash |
|
16 | 16 | |
|
17 | 17 | $ pip install ipython |
|
18 | 18 | |
|
19 | 19 | This installs IPython as well as its dependencies. |
|
20 | 20 | |
|
21 | 21 | If you want to use IPython with notebooks or the Qt console, you should also |
|
22 | 22 | install Jupyter ``pip install jupyter``. |
|
23 | 23 | |
|
24 | 24 | |
|
25 | 25 | |
|
26 | 26 | Overview |
|
27 | 27 | -------- |
|
28 | 28 | |
|
29 | 29 | This document describes in detail the steps required to install IPython. For a |
|
30 | 30 | few quick ways to get started with package managers or full Python |
|
31 | 31 | distributions, see `the install page <http://ipython.org/install.html>`_ of the |
|
32 | 32 | IPython website. |
|
33 | 33 | |
|
34 | 34 | Please let us know if you have problems installing IPython or any of its |
|
35 | 35 | dependencies. |
|
36 | 36 | |
|
37 | 37 | IPython and most dependencies should be installed via :command:`pip`. |
|
38 | 38 | In many scenarios, this is the simplest method of installing Python packages. |
|
39 | 39 | More information about :mod:`pip` can be found on |
|
40 | 40 | `its PyPI page <https://pip.pypa.io>`__. |
|
41 | 41 | |
|
42 | 42 | |
|
43 | 43 | More general information about installing Python packages can be found in |
|
44 | 44 | `Python's documentation <http://docs.python.org>`_. |
|
45 | 45 | |
|
46 | 46 | .. _dependencies: |
|
47 | 47 | |
|
48 | 48 | Dependencies |
|
49 | 49 | ~~~~~~~~~~~~ |
|
50 | 50 | |
|
51 | 51 | IPython relies on a number of other Python packages. Installing using a package |
|
52 | 52 | manager like pip or conda will ensure the necessary packages are installed. |
|
53 | 53 | Manual installation without dependencies is possible, but not recommended. |
|
54 | 54 | The dependencies can be viewed with package manager commands, |
|
55 | 55 | such as :command:`pip show ipython` or :command:`conda info ipython`. |
|
56 | 56 | |
|
57 | 57 | |
|
58 | 58 | Installing IPython itself |
|
59 | 59 | ~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
60 | 60 | |
|
61 | 61 | IPython requires several dependencies to work correctly, it is not recommended |
|
62 | 62 | to install IPython and all its dependencies manually as this can be quite long |
|
63 | 63 | and troublesome. You should use the python package manager ``pip``. |
|
64 | 64 | |
|
65 | 65 | Installation using pip |
|
66 | 66 | ~~~~~~~~~~~~~~~~~~~~~~ |
|
67 | 67 | |
|
68 | 68 | Make sure you have the latest version of :mod:`pip` (the Python package |
|
69 | 69 | manager) installed. If you do not, head to `Pip documentation |
|
70 | 70 | <https://pip.pypa.io/en/stable/installing/>`_ and install :mod:`pip` first. |
|
71 | 71 | |
|
72 | 72 | The quickest way to get up and running with IPython is to install it with pip: |
|
73 | 73 | |
|
74 | 74 | .. code-block:: bash |
|
75 | 75 | |
|
76 | 76 | $ pip install ipython |
|
77 | 77 | |
|
78 | 78 | That's it. |
|
79 | 79 | |
|
80 | 80 | |
|
81 | 81 | Installation from source |
|
82 | 82 | ~~~~~~~~~~~~~~~~~~~~~~~~ |
|
83 | 83 | |
|
84 | 84 | If you don't want to use :command:`pip`, or don't have it installed, |
|
85 | 85 | grab the latest stable tarball of IPython `from PyPI |
|
86 | 86 | <https://pypi.python.org/pypi/ipython>`__. Then do the following: |
|
87 | 87 | |
|
88 | 88 | .. code-block:: bash |
|
89 | 89 | |
|
90 | 90 | $ tar -xzf ipython.tar.gz |
|
91 | 91 | $ cd ipython |
|
92 | 92 | $ pip install . |
|
93 | 93 | |
|
94 | 94 | Do not invoke ``setup.py`` directly as this can have undesirable consequences |
|
95 | 95 | for further upgrades. Try to also avoid any usage of ``easy_install`` that can |
|
96 | 96 | have similar undesirable consequences. |
|
97 | 97 | |
|
98 | 98 | If you are installing to a location (like ``/usr/local``) that requires higher |
|
99 | 99 | permissions, you may need to run the last command with :command:`sudo`. You can |
|
100 | 100 | also install in user specific location by using the ``--user`` flag in |
|
101 | 101 | conjunction with pip. |
|
102 | 102 | |
|
103 | 103 | To run IPython's test suite, use the :command:`iptest` command from outside of |
|
104 | 104 | the IPython source tree: |
|
105 | 105 | |
|
106 | 106 | .. code-block:: bash |
|
107 | 107 | |
|
108 | 108 | $ iptest |
|
109 | 109 | |
|
110 | 110 | .. _devinstall: |
|
111 | 111 | |
|
112 | 112 | Installing the development version |
|
113 | 113 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
114 | 114 | |
|
115 | 115 | It is also possible to install the development version of IPython from our |
|
116 | 116 | `Git <http://git-scm.com/>`_ source code repository. To do this you will |
|
117 | 117 | need to have Git installed on your system. |
|
118 | 118 | |
|
119 | 119 | |
|
120 | 120 | Then do: |
|
121 | 121 | |
|
122 | 122 | .. code-block:: bash |
|
123 | 123 | |
|
124 | 124 | $ git clone https://github.com/ipython/ipython.git |
|
125 | 125 | $ cd ipython |
|
126 | 126 | $ pip install -e . |
|
127 | 127 | |
|
128 | 128 | The :command:`pip install -e .` command allows users and developers to follow |
|
129 | 129 | the development branch as it changes by creating links in the right places and |
|
130 | 130 | installing the command line scripts to the appropriate locations. |
|
131 | 131 | |
|
132 | 132 | Then, if you want to update your IPython at any time, do: |
|
133 | 133 | |
|
134 | 134 | .. code-block:: bash |
|
135 | 135 | |
|
136 | 136 | $ git pull |
|
137 | 137 | |
|
138 | 138 | If the dependencies or entrypoints have changed, you may have to run |
|
139 | 139 | |
|
140 | 140 | .. code-block:: bash |
|
141 | 141 | |
|
142 | 142 | $ pip install -e . |
|
143 | 143 | |
|
144 | 144 | again, but this is infrequent. |
@@ -1,296 +1,255 | |||
|
1 | 1 | .. _overview: |
|
2 | 2 | |
|
3 | 3 | ======== |
|
4 | 4 | Overview |
|
5 | 5 | ======== |
|
6 | 6 | |
|
7 | 7 | One of Python's most useful features is its interactive interpreter. |
|
8 | 8 | It allows for very fast testing of ideas without the overhead of |
|
9 | 9 | creating test files as is typical in most programming languages. |
|
10 | 10 | However, the interpreter supplied with the standard Python distribution |
|
11 | 11 | is somewhat limited for extended interactive use. |
|
12 | 12 | |
|
13 | 13 | The goal of IPython is to create a comprehensive environment for |
|
14 | 14 | interactive and exploratory computing. To support this goal, IPython |
|
15 | 15 | has three main components: |
|
16 | 16 | |
|
17 | 17 | * An enhanced interactive Python shell. |
|
18 | 18 | |
|
19 | 19 | * A decoupled :ref:`two-process communication model <ipythonzmq>`, which |
|
20 | 20 | allows for multiple clients to connect to a computation kernel, most notably |
|
21 | 21 | the web-based notebook provided with `Jupyter <https://jupyter.org>`_. |
|
22 | 22 | |
|
23 | 23 | * An architecture for interactive parallel computing now part of the |
|
24 | 24 | `ipyparallel` package. |
|
25 | 25 | |
|
26 | 26 | All of IPython is open source (released under the revised BSD license). |
|
27 | 27 | |
|
28 | 28 | Enhanced interactive Python shell |
|
29 | 29 | ================================= |
|
30 | 30 | |
|
31 | 31 | IPython's interactive shell (:command:`ipython`), has the following goals, |
|
32 | 32 | amongst others: |
|
33 | 33 | |
|
34 | 34 | 1. Provide an interactive shell superior to Python's default. IPython |
|
35 | 35 | has many features for tab-completion, object introspection, system shell |
|
36 | 36 | access, command history retrieval across sessions, and its own special |
|
37 | 37 | command system for adding functionality when working interactively. It |
|
38 | 38 | tries to be a very efficient environment both for Python code development |
|
39 | 39 | and for exploration of problems using Python objects (in situations like |
|
40 | 40 | data analysis). |
|
41 | 41 | |
|
42 | 42 | 2. Serve as an embeddable, ready to use interpreter for your own |
|
43 | 43 | programs. An interactive IPython shell can be started with a single call |
|
44 | 44 | from inside another program, providing access to the current namespace. |
|
45 | 45 | This can be very useful both for debugging purposes and for situations |
|
46 | 46 | where a blend of batch-processing and interactive exploration are needed. |
|
47 | 47 | |
|
48 | 48 | 3. Offer a flexible framework which can be used as the base |
|
49 | 49 | environment for working with other systems, with Python as the underlying |
|
50 | 50 | bridge language. Specifically scientific environments like Mathematica, |
|
51 | 51 | IDL and Matlab inspired its design, but similar ideas can be |
|
52 | 52 | useful in many fields. |
|
53 | 53 | |
|
54 | 54 | 4. Allow interactive testing of threaded graphical toolkits. IPython |
|
55 | 55 | has support for interactive, non-blocking control of GTK, Qt, WX, GLUT, and |
|
56 | 56 | OS X applications via special threading flags. The normal Python |
|
57 | 57 | shell can only do this for Tkinter applications. |
|
58 | 58 | |
|
59 | 59 | Main features of the interactive shell |
|
60 | 60 | -------------------------------------- |
|
61 | 61 | |
|
62 | 62 | * Dynamic object introspection. One can access docstrings, function |
|
63 | 63 | definition prototypes, source code, source files and other details |
|
64 | 64 | of any object accessible to the interpreter with a single |
|
65 | 65 | keystroke (:samp:`?`, and using :samp:`??` provides additional detail). |
|
66 | 66 | |
|
67 | 67 | * Searching through modules and namespaces with :samp:`*` wildcards, both |
|
68 | 68 | when using the :samp:`?` system and via the :samp:`%psearch` command. |
|
69 | 69 | |
|
70 | 70 | * Completion in the local namespace, by typing :kbd:`TAB` at the prompt. |
|
71 | 71 | This works for keywords, modules, methods, variables and files in the |
|
72 | 72 | current directory. This is supported via the ``prompt_toolkit`` library. |
|
73 | 73 | Custom completers can be implemented easily for different purposes |
|
74 | 74 | (system commands, magic arguments etc.) |
|
75 | 75 | |
|
76 | 76 | * Numbered input/output prompts with command history (persistent |
|
77 | 77 | across sessions and tied to each profile), full searching in this |
|
78 | 78 | history and caching of all input and output. |
|
79 | 79 | |
|
80 | 80 | * User-extensible 'magic' commands. A set of commands prefixed with |
|
81 | 81 | :samp:`%` or :samp:`%%` is available for controlling IPython itself and provides |
|
82 | 82 | directory control, namespace information and many aliases to |
|
83 | 83 | common system shell commands. |
|
84 | 84 | |
|
85 | 85 | * Alias facility for defining your own system aliases. |
|
86 | 86 | |
|
87 | 87 | * Complete system shell access. Lines starting with :samp:`!` are passed |
|
88 | 88 | directly to the system shell, and using :samp:`!!` or :samp:`var = !cmd` |
|
89 | 89 | captures shell output into python variables for further use. |
|
90 | 90 | |
|
91 | 91 | * The ability to expand python variables when calling the system shell. In a |
|
92 | 92 | shell command, any python variable prefixed with :samp:`$` is expanded. A |
|
93 | 93 | double :samp:`$$` allows passing a literal :samp:`$` to the shell (for access |
|
94 | 94 | to shell and environment variables like :envvar:`PATH`). |
|
95 | 95 | |
|
96 | 96 | * Filesystem navigation, via a magic :samp:`%cd` command, along with a |
|
97 | 97 | persistent bookmark system (using :samp:`%bookmark`) for fast access to |
|
98 | 98 | frequently visited directories. |
|
99 | 99 | |
|
100 | 100 | * A lightweight persistence framework via the :samp:`%store` command, which |
|
101 | 101 | allows you to save arbitrary Python variables. These get restored |
|
102 | 102 | when you run the :samp:`%store -r` command. |
|
103 | 103 | |
|
104 | 104 | * Automatic indentation and highlighting of code as you type (through the |
|
105 | 105 | `prompt_toolkit` library). |
|
106 | 106 | |
|
107 | 107 | * Macro system for quickly re-executing multiple lines of previous |
|
108 | 108 | input with a single name via the :samp:`%macro` command. Macros can be |
|
109 | 109 | stored persistently via :samp:`%store` and edited via :samp:`%edit`. |
|
110 | 110 | |
|
111 | 111 | * Session logging (you can then later use these logs as code in your |
|
112 | 112 | programs). Logs can optionally timestamp all input, and also store |
|
113 | 113 | session output (marked as comments, so the log remains valid |
|
114 | 114 | Python source code). |
|
115 | 115 | |
|
116 | 116 | * Session restoring: logs can be replayed to restore a previous |
|
117 | 117 | session to the state where you left it. |
|
118 | 118 | |
|
119 | 119 | * Verbose and colored exception traceback printouts. Easier to parse |
|
120 | 120 | visually, and in verbose mode they produce a lot of useful |
|
121 | 121 | debugging information (basically a terminal version of the cgitb |
|
122 | 122 | module). |
|
123 | 123 | |
|
124 | 124 | * Auto-parentheses via the :samp:`%autocall` command: callable objects can be |
|
125 | 125 | executed without parentheses: :samp:`sin 3` is automatically converted to |
|
126 | 126 | :samp:`sin(3)` |
|
127 | 127 | |
|
128 | 128 | * Auto-quoting: using :samp:`,`, or :samp:`;` as the first character forces |
|
129 | 129 | auto-quoting of the rest of the line: :samp:`,my_function a b` becomes |
|
130 | 130 | automatically :samp:`my_function("a","b")`, while :samp:`;my_function a b` |
|
131 | 131 | becomes :samp:`my_function("a b")`. |
|
132 | 132 | |
|
133 | 133 | * Extensible input syntax. You can define filters that pre-process |
|
134 | 134 | user input to simplify input in special situations. This allows |
|
135 | 135 | for example pasting multi-line code fragments which start with |
|
136 | 136 | :samp:`>>>` or :samp:`...` such as those from other python sessions or the |
|
137 | 137 | standard Python documentation. |
|
138 | 138 | |
|
139 | 139 | * Flexible :ref:`configuration system <config_overview>`. It uses a |
|
140 | 140 | configuration file which allows permanent setting of all command-line |
|
141 | 141 | options, module loading, code and file execution. The system allows |
|
142 | 142 | recursive file inclusion, so you can have a base file with defaults and |
|
143 | 143 | layers which load other customizations for particular projects. |
|
144 | 144 | |
|
145 | 145 | * Embeddable. You can call IPython as a python shell inside your own |
|
146 | 146 | python programs. This can be used both for debugging code or for |
|
147 | 147 | providing interactive abilities to your programs with knowledge |
|
148 | 148 | about the local namespaces (very useful in debugging and data |
|
149 | 149 | analysis situations). |
|
150 | 150 | |
|
151 | 151 | * Easy debugger access. You can set IPython to call up an enhanced version of |
|
152 | 152 | the Python debugger (pdb) every time there is an uncaught exception. This |
|
153 | 153 | drops you inside the code which triggered the exception with all the data |
|
154 | 154 | live and it is possible to navigate the stack to rapidly isolate the source |
|
155 | 155 | of a bug. The :samp:`%run` magic command (with the :samp:`-d` option) can run |
|
156 | 156 | any script under pdb's control, automatically setting initial breakpoints for |
|
157 | 157 | you. This version of pdb has IPython-specific improvements, including |
|
158 | 158 | tab-completion and traceback coloring support. For even easier debugger |
|
159 | 159 | access, try :samp:`%debug` after seeing an exception. |
|
160 | 160 | |
|
161 | 161 | * Profiler support. You can run single statements (similar to |
|
162 | 162 | :samp:`profile.run()`) or complete programs under the profiler's control. |
|
163 | 163 | While this is possible with standard cProfile or profile modules, |
|
164 | 164 | IPython wraps this functionality with magic commands (see :samp:`%prun` |
|
165 | 165 | and :samp:`%run -p`) convenient for rapid interactive work. |
|
166 | 166 | |
|
167 | 167 | * Simple timing information. You can use the :samp:`%timeit` command to get |
|
168 | 168 | the execution time of a Python statement or expression. This machinery is |
|
169 | 169 | intelligent enough to do more repetitions for commands that finish very |
|
170 | 170 | quickly in order to get a better estimate of their running time. |
|
171 | 171 | |
|
172 | 172 | .. sourcecode:: ipython |
|
173 | 173 | |
|
174 | 174 | In [1]: %timeit 1+1 |
|
175 | 175 | 10000000 loops, best of 3: 25.5 ns per loop |
|
176 | 176 | |
|
177 | 177 | In [2]: %timeit [math.sin(x) for x in range(5000)] |
|
178 | 178 | 1000 loops, best of 3: 719 µs per loop |
|
179 | 179 | |
|
180 | 180 | .. |
|
181 | 181 | |
|
182 | 182 | To get the timing information for more than one expression, use the |
|
183 | 183 | :samp:`%%timeit` cell magic command. |
|
184 | 184 | |
|
185 | 185 | |
|
186 | 186 | * Doctest support. The special :samp:`%doctest_mode` command toggles a mode |
|
187 | 187 | to use doctest-compatible prompts, so you can use IPython sessions as |
|
188 | 188 | doctest code. By default, IPython also allows you to paste existing |
|
189 | 189 | doctests, and strips out the leading :samp:`>>>` and :samp:`...` prompts in |
|
190 | 190 | them. |
|
191 | 191 | |
|
192 | 192 | .. _ipythonzmq: |
|
193 | 193 | |
|
194 | 194 | Decoupled two-process model |
|
195 | 195 | ============================== |
|
196 | 196 | |
|
197 | 197 | IPython has abstracted and extended the notion of a traditional |
|
198 | 198 | *Read-Evaluate-Print Loop* (REPL) environment by decoupling the *evaluation* |
|
199 | 199 | into its own process. We call this process a **kernel**: it receives execution |
|
200 | 200 | instructions from clients and communicates the results back to them. |
|
201 | 201 | |
|
202 | 202 | This decoupling allows us to have several clients connected to the same |
|
203 | 203 | kernel, and even allows clients and kernels to live on different machines. |
|
204 | 204 | With the exclusion of the traditional single process terminal-based IPython |
|
205 | 205 | (what you start if you run ``ipython`` without any subcommands), all |
|
206 | 206 | other IPython machinery uses this two-process model. Most of this is now part |
|
207 | 207 | of the `Jupyter` project, whis includes ``jupyter console``, ``jupyter |
|
208 | 208 | qtconsole``, and ``jupyter notebook``. |
|
209 | 209 | |
|
210 | 210 | As an example, this means that when you start ``jupyter qtconsole``, you're |
|
211 | 211 | really starting two processes, a kernel and a Qt-based client can send |
|
212 | 212 | commands to and receive results from that kernel. If there is already a kernel |
|
213 | 213 | running that you want to connect to, you can pass the ``--existing`` flag |
|
214 | 214 | which will skip initiating a new kernel and connect to the most recent kernel, |
|
215 | 215 | instead. To connect to a specific kernel once you have several kernels |
|
216 | 216 | running, use the ``%connect_info`` magic to get the unique connection file, |
|
217 | 217 | which will be something like ``--existing kernel-19732.json`` but with |
|
218 | 218 | different numbers which correspond to the Process ID of the kernel. |
|
219 | 219 | |
|
220 | 220 | You can read more about using `jupyter qtconsole |
|
221 | 221 | <http://jupyter.org/qtconsole/>`_, and |
|
222 | 222 | `jupyter notebook <http://jupyter-notebook.readthedocs.io/en/latest/>`_. There |
|
223 | 223 | is also a :ref:`message spec <messaging>` which documents the protocol for |
|
224 | 224 | communication between kernels |
|
225 | 225 | and clients. |
|
226 | 226 | |
|
227 | 227 | .. seealso:: |
|
228 | 228 | |
|
229 | 229 | `Frontend/Kernel Model`_ example notebook |
|
230 | 230 | |
|
231 | 231 | |
|
232 | 232 | Interactive parallel computing |
|
233 | 233 | ============================== |
|
234 | 234 | |
|
235 | .. note:: | |
|
236 | 235 | |
|
237 |
|
|
|
238 |
|
|
|
239 | ||
|
240 | Increasingly, parallel computer hardware, such as multicore CPUs, clusters and | |
|
241 | supercomputers, is becoming ubiquitous. Over the last several years, we have | |
|
242 | developed an architecture within IPython that allows such hardware to be used | |
|
243 | quickly and easily from Python. Moreover, this architecture is designed to | |
|
244 | support interactive and collaborative parallel computing. | |
|
245 | ||
|
246 | The main features of this system are: | |
|
247 | ||
|
248 | * Quickly parallelize Python code from an interactive Python/IPython session. | |
|
249 | ||
|
250 | * A flexible and dynamic process model that be deployed on anything from | |
|
251 | multicore workstations to supercomputers. | |
|
252 | ||
|
253 | * An architecture that supports many different styles of parallelism, from | |
|
254 | message passing to task farming. And all of these styles can be handled | |
|
255 | interactively. | |
|
256 | ||
|
257 | * Both blocking and fully asynchronous interfaces. | |
|
258 | ||
|
259 | * High level APIs that enable many things to be parallelized in a few lines | |
|
260 | of code. | |
|
261 | ||
|
262 | * Write parallel code that will run unchanged on everything from multicore | |
|
263 | workstations to supercomputers. | |
|
264 | ||
|
265 | * Full integration with Message Passing libraries (MPI). | |
|
266 | ||
|
267 | * Capabilities based security model with full encryption of network connections. | |
|
268 | ||
|
269 | * Share live parallel jobs with other users securely. We call this | |
|
270 | collaborative parallel computing. | |
|
271 | ||
|
272 | * Dynamically load balanced task farming system. | |
|
273 | ||
|
274 | * Robust error handling. Python exceptions raised in parallel execution are | |
|
275 | gathered and presented to the top-level code. | |
|
276 | ||
|
277 | For more information, see our :ref:`overview <parallel_index>` of using IPython | |
|
278 | for parallel computing. | |
|
236 | This functionality is optional and now part of the `ipyparallel | |
|
237 | <http://ipyparallel.readthedocs.io/>`_ project. | |
|
279 | 238 | |
|
280 | 239 | Portability and Python requirements |
|
281 | 240 | ----------------------------------- |
|
282 | 241 | |
|
283 | 242 | As of the 2.0 release, IPython works with Python 2.7 and 3.3 or above. |
|
284 | 243 | Version 1.0 additionally worked with Python 2.6 and 3.2. |
|
285 | 244 | Version 0.12 was the first version to fully support Python 3. |
|
286 | 245 | |
|
287 | 246 | IPython is known to work on the following operating systems: |
|
288 | 247 | |
|
289 | 248 | * Linux |
|
290 | 249 | * Most other Unix-like OSs (AIX, Solaris, BSD, etc.) |
|
291 | 250 | * Mac OS X |
|
292 | 251 | * Windows (CygWin, XP, Vista, etc.) |
|
293 | 252 | |
|
294 | 253 | See :ref:`here <install_index>` for instructions on how to install IPython. |
|
295 | 254 | |
|
296 | 255 | .. include:: links.txt |
@@ -1,45 +1,75 | |||
|
1 | 1 | .. _issues_list_5: |
|
2 | 2 | |
|
3 | 3 | Issues closed in the 5.x development cycle |
|
4 | 4 | ========================================== |
|
5 | 5 | |
|
6 | Issues closed in 5.1 | |
|
7 | -------------------- | |
|
8 | ||
|
9 | GitHub stats for 2016/07/08 - 2016/08/13 (tag: 5.0.0) | |
|
10 | ||
|
11 | These lists are automatically generated, and may be incomplete or contain duplicates. | |
|
12 | ||
|
13 | We closed 33 issues and merged 43 pull requests. | |
|
14 | The full list can be seen `on GitHub <https://github.com/ipython/ipython/issues?q=milestone%3A5.1+>`__ | |
|
15 | ||
|
16 | The following 17 authors contributed 129 commits. | |
|
17 | ||
|
18 | * Antony Lee | |
|
19 | * Benjamin Ragan-Kelley | |
|
20 | * Carol Willing | |
|
21 | * Danilo J. S. Bellini | |
|
22 | * 小明 (`dongweiming <https://github.com/dongweiming>`__) | |
|
23 | * Fernando Perez | |
|
24 | * Gavin Cooper | |
|
25 | * Gil Forsyth | |
|
26 | * Jacob Niehus | |
|
27 | * Julian Kuhlmann | |
|
28 | * Matthias Bussonnier | |
|
29 | * Michael Pacer | |
|
30 | * Nik Nyby | |
|
31 | * Pavol Juhas | |
|
32 | * Luke Deen Taylor | |
|
33 | * Thomas Kluyver | |
|
34 | * Tamir Bahar | |
|
35 | ||
|
6 | 36 | |
|
7 | 37 | Issues closed in 5.0 |
|
8 | 38 | -------------------- |
|
9 | 39 | |
|
10 | 40 | GitHub stats for 2016/07/05 - 2016/07/07 (tag: 5.0.0) |
|
11 | 41 | |
|
12 | 42 | These lists are automatically generated, and may be incomplete or contain duplicates. |
|
13 | 43 | |
|
14 | 44 | We closed 95 issues and merged 191 pull requests. |
|
15 | 45 | The full list can be seen `on GitHub <https://github.com/ipython/ipython/issues?q=milestone%3A5.0+>`__ |
|
16 | 46 | |
|
17 | 47 | The following 27 authors contributed 229 commits. |
|
18 | 48 | |
|
19 | 49 | * Adam Greenhall |
|
20 | 50 | * Adrian |
|
21 | 51 | * Antony Lee |
|
22 | 52 | * Benjamin Ragan-Kelley |
|
23 | 53 | * Carlos Cordoba |
|
24 | 54 | * Carol Willing |
|
25 | 55 | * Chris |
|
26 | 56 | * Craig Citro |
|
27 | 57 | * Dmitry Zotikov |
|
28 | 58 | * Fernando Perez |
|
29 | 59 | * Gil Forsyth |
|
30 | 60 | * Jason Grout |
|
31 | 61 | * Jonathan Frederic |
|
32 | 62 | * Jonathan Slenders |
|
33 | 63 | * Justin Zymbaluk |
|
34 | 64 | * Kelly Liu |
|
35 | 65 | * klonuo |
|
36 | 66 | * Matthias Bussonnier |
|
37 | 67 | * nvdv |
|
38 | 68 | * Pavol Juhas |
|
39 | 69 | * Pierre Gerold |
|
40 | 70 | * sukisuki |
|
41 | 71 | * Sylvain Corlay |
|
42 | 72 | * Thomas A Caswell |
|
43 | 73 | * Thomas Kluyver |
|
44 | 74 | * Trevor Bekolay |
|
45 | 75 | * Yuri Numerov |
@@ -1,288 +1,289 | |||
|
1 | 1 | #!/usr/bin/env python |
|
2 | 2 | # -*- coding: utf-8 -*- |
|
3 | 3 | """Setup script for IPython. |
|
4 | 4 | |
|
5 | 5 | Under Posix environments it works like a typical setup.py script. |
|
6 | 6 | Under Windows, the command sdist is not supported, since IPython |
|
7 | 7 | requires utilities which are not available under Windows.""" |
|
8 | 8 | |
|
9 | 9 | #----------------------------------------------------------------------------- |
|
10 | 10 | # Copyright (c) 2008-2011, IPython Development Team. |
|
11 | 11 | # Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.edu> |
|
12 | 12 | # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de> |
|
13 | 13 | # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu> |
|
14 | 14 | # |
|
15 | 15 | # Distributed under the terms of the Modified BSD License. |
|
16 | 16 | # |
|
17 | 17 | # The full license is in the file COPYING.rst, distributed with this software. |
|
18 | 18 | #----------------------------------------------------------------------------- |
|
19 | 19 | |
|
20 | 20 | #----------------------------------------------------------------------------- |
|
21 | 21 | # Minimal Python version sanity check |
|
22 | 22 | #----------------------------------------------------------------------------- |
|
23 | 23 | from __future__ import print_function |
|
24 | 24 | |
|
25 | 25 | import sys |
|
26 | 26 | |
|
27 | 27 | # This check is also made in IPython/__init__, don't forget to update both when |
|
28 | 28 | # changing Python version requirements. |
|
29 | 29 | v = sys.version_info |
|
30 | if v[:2] < (2,7) or (v[0] >= 3 and v[:2] < (3,3)): | |
|
31 |
error = "ERROR: IPython requires Python version |
|
|
30 | if v[:2] < (3,3): | |
|
31 | error = "ERROR: IPython requires Python version 3.3 or above." | |
|
32 | 32 | print(error, file=sys.stderr) |
|
33 | 33 | sys.exit(1) |
|
34 | 34 | |
|
35 | 35 | PY3 = (sys.version_info[0] >= 3) |
|
36 | 36 | |
|
37 | 37 | # At least we're on the python version we need, move on. |
|
38 | 38 | |
|
39 | 39 | #------------------------------------------------------------------------------- |
|
40 | 40 | # Imports |
|
41 | 41 | #------------------------------------------------------------------------------- |
|
42 | 42 | |
|
43 | 43 | # Stdlib imports |
|
44 | 44 | import os |
|
45 | 45 | |
|
46 | 46 | from glob import glob |
|
47 | 47 | |
|
48 | 48 | # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly |
|
49 | 49 | # update it when the contents of directories change. |
|
50 | 50 | if os.path.exists('MANIFEST'): os.remove('MANIFEST') |
|
51 | 51 | |
|
52 | 52 | from distutils.core import setup |
|
53 | 53 | |
|
54 | 54 | # Our own imports |
|
55 | 55 | from setupbase import target_update |
|
56 | 56 | |
|
57 | 57 | from setupbase import ( |
|
58 | 58 | setup_args, |
|
59 | 59 | find_packages, |
|
60 | 60 | find_package_data, |
|
61 | 61 | check_package_data_first, |
|
62 | 62 | find_entry_points, |
|
63 | 63 | build_scripts_entrypt, |
|
64 | 64 | find_data_files, |
|
65 | 65 | git_prebuild, |
|
66 | 66 | install_symlinked, |
|
67 | 67 | install_lib_symlink, |
|
68 | 68 | install_scripts_for_symlink, |
|
69 | 69 | unsymlink, |
|
70 | 70 | ) |
|
71 | 71 | |
|
72 | 72 | isfile = os.path.isfile |
|
73 | 73 | pjoin = os.path.join |
|
74 | 74 | |
|
75 | 75 | #------------------------------------------------------------------------------- |
|
76 | 76 | # Handle OS specific things |
|
77 | 77 | #------------------------------------------------------------------------------- |
|
78 | 78 | |
|
79 | 79 | if os.name in ('nt','dos'): |
|
80 | 80 | os_name = 'windows' |
|
81 | 81 | else: |
|
82 | 82 | os_name = os.name |
|
83 | 83 | |
|
84 | 84 | # Under Windows, 'sdist' has not been supported. Now that the docs build with |
|
85 | 85 | # Sphinx it might work, but let's not turn it on until someone confirms that it |
|
86 | 86 | # actually works. |
|
87 | 87 | if os_name == 'windows' and 'sdist' in sys.argv: |
|
88 | 88 | print('The sdist command is not available under Windows. Exiting.') |
|
89 | 89 | sys.exit(1) |
|
90 | 90 | |
|
91 | 91 | |
|
92 | 92 | #------------------------------------------------------------------------------- |
|
93 | 93 | # Things related to the IPython documentation |
|
94 | 94 | #------------------------------------------------------------------------------- |
|
95 | 95 | |
|
96 | 96 | # update the manuals when building a source dist |
|
97 | 97 | if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'): |
|
98 | 98 | |
|
99 | 99 | # List of things to be updated. Each entry is a triplet of args for |
|
100 | 100 | # target_update() |
|
101 | 101 | to_update = [ |
|
102 | 102 | ('docs/man/ipython.1.gz', |
|
103 | 103 | ['docs/man/ipython.1'], |
|
104 | 104 | 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'), |
|
105 | 105 | ] |
|
106 | 106 | |
|
107 | 107 | |
|
108 | 108 | [ target_update(*t) for t in to_update ] |
|
109 | 109 | |
|
110 | 110 | #--------------------------------------------------------------------------- |
|
111 | 111 | # Find all the packages, package data, and data_files |
|
112 | 112 | #--------------------------------------------------------------------------- |
|
113 | 113 | |
|
114 | 114 | packages = find_packages() |
|
115 | 115 | package_data = find_package_data() |
|
116 | 116 | |
|
117 | 117 | data_files = find_data_files() |
|
118 | 118 | |
|
119 | 119 | setup_args['packages'] = packages |
|
120 | 120 | setup_args['package_data'] = package_data |
|
121 | 121 | setup_args['data_files'] = data_files |
|
122 | 122 | |
|
123 | 123 | #--------------------------------------------------------------------------- |
|
124 | 124 | # custom distutils commands |
|
125 | 125 | #--------------------------------------------------------------------------- |
|
126 | 126 | # imports here, so they are after setuptools import if there was one |
|
127 | 127 | from distutils.command.sdist import sdist |
|
128 | 128 | from distutils.command.upload import upload |
|
129 | 129 | |
|
130 | 130 | class UploadWindowsInstallers(upload): |
|
131 | 131 | |
|
132 | 132 | description = "Upload Windows installers to PyPI (only used from tools/release_windows.py)" |
|
133 | 133 | user_options = upload.user_options + [ |
|
134 | 134 | ('files=', 'f', 'exe file (or glob) to upload') |
|
135 | 135 | ] |
|
136 | 136 | def initialize_options(self): |
|
137 | 137 | upload.initialize_options(self) |
|
138 | 138 | meta = self.distribution.metadata |
|
139 | 139 | base = '{name}-{version}'.format( |
|
140 | 140 | name=meta.get_name(), |
|
141 | 141 | version=meta.get_version() |
|
142 | 142 | ) |
|
143 | 143 | self.files = os.path.join('dist', '%s.*.exe' % base) |
|
144 | 144 | |
|
145 | 145 | def run(self): |
|
146 | 146 | for dist_file in glob(self.files): |
|
147 | 147 | self.upload_file('bdist_wininst', 'any', dist_file) |
|
148 | 148 | |
|
149 | 149 | setup_args['cmdclass'] = { |
|
150 | 150 | 'build_py': \ |
|
151 | 151 | check_package_data_first(git_prebuild('IPython')), |
|
152 | 152 | 'sdist' : git_prebuild('IPython', sdist), |
|
153 | 153 | 'upload_wininst' : UploadWindowsInstallers, |
|
154 | 154 | 'symlink': install_symlinked, |
|
155 | 155 | 'install_lib_symlink': install_lib_symlink, |
|
156 | 156 | 'install_scripts_sym': install_scripts_for_symlink, |
|
157 | 157 | 'unsymlink': unsymlink, |
|
158 | 158 | } |
|
159 | 159 | |
|
160 | 160 | |
|
161 | 161 | #--------------------------------------------------------------------------- |
|
162 | 162 | # Handle scripts, dependencies, and setuptools specific things |
|
163 | 163 | #--------------------------------------------------------------------------- |
|
164 | 164 | |
|
165 | 165 | # For some commands, use setuptools. Note that we do NOT list install here! |
|
166 | 166 | # If you want a setuptools-enhanced install, just run 'setupegg.py install' |
|
167 | 167 | needs_setuptools = set(('develop', 'release', 'bdist_egg', 'bdist_rpm', |
|
168 | 168 | 'bdist', 'bdist_dumb', 'bdist_wininst', 'bdist_wheel', |
|
169 | 169 | 'egg_info', 'easy_install', 'upload', 'install_egg_info', |
|
170 | 170 | )) |
|
171 | 171 | |
|
172 | 172 | if len(needs_setuptools.intersection(sys.argv)) > 0: |
|
173 | 173 | import setuptools |
|
174 | 174 | |
|
175 | 175 | # This dict is used for passing extra arguments that are setuptools |
|
176 | 176 | # specific to setup |
|
177 | 177 | setuptools_extra_args = {} |
|
178 | 178 | |
|
179 | 179 | # setuptools requirements |
|
180 | 180 | |
|
181 | 181 | extras_require = dict( |
|
182 | 182 | parallel = ['ipyparallel'], |
|
183 | 183 | qtconsole = ['qtconsole'], |
|
184 | 184 | doc = ['Sphinx>=1.3'], |
|
185 | 185 | test = ['nose>=0.10.1', 'requests', 'testpath', 'pygments', 'nbformat', 'ipykernel', 'numpy'], |
|
186 | 186 | terminal = [], |
|
187 | 187 | kernel = ['ipykernel'], |
|
188 | 188 | nbformat = ['nbformat'], |
|
189 | 189 | notebook = ['notebook', 'ipywidgets'], |
|
190 | 190 | nbconvert = ['nbconvert'], |
|
191 | 191 | ) |
|
192 | 192 | |
|
193 | 193 | install_requires = [ |
|
194 | 194 | 'setuptools>=18.5', |
|
195 | 195 | 'decorator', |
|
196 | 196 | 'pickleshare', |
|
197 | 197 | 'simplegeneric>0.8', |
|
198 | 198 | 'traitlets>=4.2', |
|
199 | 199 | 'prompt_toolkit>=1.0.3,<2.0.0', |
|
200 | 200 | 'pygments', |
|
201 | 201 | ] |
|
202 | 202 | |
|
203 | 203 | # Platform-specific dependencies: |
|
204 | 204 | # This is the correct way to specify these, |
|
205 | 205 | # but requires pip >= 6. pip < 6 ignores these. |
|
206 | 206 | |
|
207 | 207 | extras_require.update({ |
|
208 | 208 | ':python_version == "2.7"': ['backports.shutil_get_terminal_size'], |
|
209 | 209 | ':python_version == "2.7" or python_version == "3.3"': ['pathlib2'], |
|
210 | 210 | ':sys_platform != "win32"': ['pexpect'], |
|
211 | 211 | ':sys_platform == "darwin"': ['appnope'], |
|
212 | 212 | ':sys_platform == "win32"': ['colorama', 'win_unicode_console>=0.5'], |
|
213 | 213 | 'test:python_version == "2.7"': ['mock'], |
|
214 | 214 | }) |
|
215 | 215 | # FIXME: re-specify above platform dependencies for pip < 6 |
|
216 | 216 | # These would result in non-portable bdists. |
|
217 | 217 | if not any(arg.startswith('bdist') for arg in sys.argv): |
|
218 | 218 | if sys.version_info < (3, 3): |
|
219 | 219 | extras_require['test'].append('mock') |
|
220 | 220 | |
|
221 | 221 | if sys.platform == 'darwin': |
|
222 | 222 | install_requires.extend(['appnope']) |
|
223 | 223 | |
|
224 | 224 | if not sys.platform.startswith('win'): |
|
225 | 225 | install_requires.append('pexpect') |
|
226 | 226 | |
|
227 | 227 | # workaround pypa/setuptools#147, where setuptools misspells |
|
228 | 228 | # platform_python_implementation as python_implementation |
|
229 | 229 | if 'setuptools' in sys.modules: |
|
230 | 230 | for key in list(extras_require): |
|
231 | 231 | if 'platform_python_implementation' in key: |
|
232 | 232 | new_key = key.replace('platform_python_implementation', 'python_implementation') |
|
233 | 233 | extras_require[new_key] = extras_require.pop(key) |
|
234 | 234 | |
|
235 | 235 | everything = set() |
|
236 | 236 | for key, deps in extras_require.items(): |
|
237 | 237 | if ':' not in key: |
|
238 | 238 | everything.update(deps) |
|
239 | 239 | extras_require['all'] = everything |
|
240 | 240 | |
|
241 | 241 | if 'setuptools' in sys.modules: |
|
242 | setuptools_extra_args['python_requires'] = '>=3.3' | |
|
242 | 243 | setuptools_extra_args['zip_safe'] = False |
|
243 | 244 | setuptools_extra_args['entry_points'] = { |
|
244 | 245 | 'console_scripts': find_entry_points(), |
|
245 | 246 | 'pygments.lexers': [ |
|
246 | 247 | 'ipythonconsole = IPython.lib.lexers:IPythonConsoleLexer', |
|
247 | 248 | 'ipython = IPython.lib.lexers:IPythonLexer', |
|
248 | 249 | 'ipython3 = IPython.lib.lexers:IPython3Lexer', |
|
249 | 250 | ], |
|
250 | 251 | } |
|
251 | 252 | setup_args['extras_require'] = extras_require |
|
252 | 253 | requires = setup_args['install_requires'] = install_requires |
|
253 | 254 | |
|
254 | 255 | # Script to be run by the windows binary installer after the default setup |
|
255 | 256 | # routine, to add shortcuts and similar windows-only things. Windows |
|
256 | 257 | # post-install scripts MUST reside in the scripts/ dir, otherwise distutils |
|
257 | 258 | # doesn't find them. |
|
258 | 259 | if 'bdist_wininst' in sys.argv: |
|
259 | 260 | if len(sys.argv) > 2 and \ |
|
260 | 261 | ('sdist' in sys.argv or 'bdist_rpm' in sys.argv): |
|
261 | 262 | print("ERROR: bdist_wininst must be run alone. Exiting.", file=sys.stderr) |
|
262 | 263 | sys.exit(1) |
|
263 | 264 | setup_args['data_files'].append( |
|
264 | 265 | ['Scripts', ('scripts/ipython.ico', 'scripts/ipython_nb.ico')]) |
|
265 | 266 | setup_args['scripts'] = [pjoin('scripts','ipython_win_post_install.py')] |
|
266 | 267 | setup_args['options'] = {"bdist_wininst": |
|
267 | 268 | {"install_script": |
|
268 | 269 | "ipython_win_post_install.py"}} |
|
269 | 270 | |
|
270 | 271 | else: |
|
271 | 272 | # scripts has to be a non-empty list, or install_scripts isn't called |
|
272 | 273 | setup_args['scripts'] = [e.split('=')[0].strip() for e in find_entry_points()] |
|
273 | 274 | |
|
274 | 275 | setup_args['cmdclass']['build_scripts'] = build_scripts_entrypt |
|
275 | 276 | |
|
276 | 277 | #--------------------------------------------------------------------------- |
|
277 | 278 | # Do the actual setup now |
|
278 | 279 | #--------------------------------------------------------------------------- |
|
279 | 280 | |
|
280 | 281 | setup_args.update(setuptools_extra_args) |
|
281 | 282 | |
|
282 | 283 | |
|
283 | 284 | |
|
284 | 285 | def main(): |
|
285 | 286 | setup(**setup_args) |
|
286 | 287 | |
|
287 | 288 | if __name__ == '__main__': |
|
288 | 289 | main() |
@@ -1,56 +1,56 | |||
|
1 | 1 | """Various utilities common to IPython release and maintenance tools. |
|
2 | 2 | """ |
|
3 | 3 | from __future__ import print_function |
|
4 | 4 | |
|
5 | 5 | # Library imports |
|
6 | 6 | import os |
|
7 | 7 | |
|
8 | 8 | # Useful shorthands |
|
9 | 9 | pjoin = os.path.join |
|
10 | 10 | cd = os.chdir |
|
11 | 11 | |
|
12 | 12 | # Constants |
|
13 | 13 | |
|
14 | 14 | # SSH root address of the archive site |
|
15 | 15 | archive_user = 'ipython@archive.ipython.org' |
|
16 | 16 | archive_dir = 'archive.ipython.org' |
|
17 | 17 | archive = '%s:%s' % (archive_user, archive_dir) |
|
18 | 18 | |
|
19 | 19 | # Build commands |
|
20 | 20 | # Source dists |
|
21 | 21 | sdists = './setup.py sdist --formats=gztar,zip' |
|
22 | 22 | # Binary dists |
|
23 | 23 | def buildwheels(): |
|
24 | sh('python setupegg.py bdist_wheel') | |
|
24 | sh('python3 setupegg.py bdist_wheel' % py) | |
|
25 | 25 | |
|
26 | 26 | # Utility functions |
|
27 | 27 | def sh(cmd): |
|
28 | 28 | """Run system command in shell, raise SystemExit if it returns an error.""" |
|
29 | 29 | print("$", cmd) |
|
30 | 30 | stat = os.system(cmd) |
|
31 | 31 | #stat = 0 # Uncomment this and comment previous to run in debug mode |
|
32 | 32 | if stat: |
|
33 | 33 | raise SystemExit("Command %s failed with code: %s" % (cmd, stat)) |
|
34 | 34 | |
|
35 | 35 | # Backwards compatibility |
|
36 | 36 | c = sh |
|
37 | 37 | |
|
38 | 38 | def get_ipdir(): |
|
39 | 39 | """Get IPython directory from command line, or assume it's the one above.""" |
|
40 | 40 | |
|
41 | 41 | # Initialize arguments and check location |
|
42 | 42 | ipdir = pjoin(os.path.dirname(__file__), os.pardir) |
|
43 | 43 | |
|
44 | 44 | ipdir = os.path.abspath(ipdir) |
|
45 | 45 | |
|
46 | 46 | cd(ipdir) |
|
47 | 47 | if not os.path.isdir('IPython') and os.path.isfile('setup.py'): |
|
48 | 48 | raise SystemExit('Invalid ipython directory: %s' % ipdir) |
|
49 | 49 | return ipdir |
|
50 | 50 | |
|
51 | 51 | try: |
|
52 | 52 | execfile = execfile |
|
53 | 53 | except NameError: |
|
54 | 54 | def execfile(fname, globs, locs=None): |
|
55 | 55 | locs = locs or globs |
|
56 | 56 | exec(compile(open(fname).read(), fname, "exec"), globs, locs) |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now