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