Show More
@@ -1,151 +1,151 b'' | |||
|
1 | 1 | # encoding: utf-8 |
|
2 | 2 | """ |
|
3 | 3 | IPython: tools for interactive and parallel computing in Python. |
|
4 | 4 | |
|
5 | 5 | https://ipython.org |
|
6 | 6 | """ |
|
7 | 7 | #----------------------------------------------------------------------------- |
|
8 | 8 | # Copyright (c) 2008-2011, IPython Development Team. |
|
9 | 9 | # Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.edu> |
|
10 | 10 | # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de> |
|
11 | 11 | # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu> |
|
12 | 12 | # |
|
13 | 13 | # Distributed under the terms of the Modified BSD License. |
|
14 | 14 | # |
|
15 | 15 | # The full license is in the file COPYING.txt, distributed with this software. |
|
16 | 16 | #----------------------------------------------------------------------------- |
|
17 | 17 | |
|
18 | 18 | #----------------------------------------------------------------------------- |
|
19 | 19 | # Imports |
|
20 | 20 | #----------------------------------------------------------------------------- |
|
21 | 21 | |
|
22 | 22 | import os |
|
23 | 23 | import sys |
|
24 | 24 | |
|
25 | 25 | #----------------------------------------------------------------------------- |
|
26 | 26 | # Setup everything |
|
27 | 27 | #----------------------------------------------------------------------------- |
|
28 | 28 | |
|
29 | 29 | # Don't forget to also update setup.py when this changes! |
|
30 | 30 | if sys.version_info < (3, 5): |
|
31 | 31 | raise ImportError( |
|
32 | 32 | """ |
|
33 | 33 | IPython 7.0+ supports Python 3.5 and above. |
|
34 | 34 | When using Python 2.7, please install IPython 5.x LTS Long Term Support version. |
|
35 | 35 | Python 3.3 and 3.4 were supported up to IPython 6.x. |
|
36 | 36 | |
|
37 | 37 | See IPython `README.rst` file for more information: |
|
38 | 38 | |
|
39 | 39 | https://github.com/ipython/ipython/blob/master/README.rst |
|
40 | 40 | |
|
41 | 41 | """) |
|
42 | 42 | |
|
43 | 43 | # Make it easy to import extensions - they are always directly on pythonpath. |
|
44 | 44 | # Therefore, non-IPython modules can be added to extensions directory. |
|
45 | 45 | # This should probably be in ipapp.py. |
|
46 | 46 | sys.path.append(os.path.join(os.path.dirname(__file__), "extensions")) |
|
47 | 47 | |
|
48 | 48 | #----------------------------------------------------------------------------- |
|
49 | 49 | # Setup the top level names |
|
50 | 50 | #----------------------------------------------------------------------------- |
|
51 | 51 | |
|
52 | 52 | from .core.getipython import get_ipython |
|
53 | 53 | from .core import release |
|
54 | 54 | from .core.application import Application |
|
55 | 55 | from .terminal.embed import embed |
|
56 | 56 | |
|
57 | 57 | from .core.interactiveshell import InteractiveShell |
|
58 | 58 | from .testing import test |
|
59 | 59 | from .utils.sysinfo import sys_info |
|
60 | 60 | from .utils.frame import extract_module_locals |
|
61 | 61 | |
|
62 | 62 | # Release data |
|
63 | 63 | __author__ = '%s <%s>' % (release.author, release.author_email) |
|
64 | 64 | __license__ = release.license |
|
65 | 65 | __version__ = release.version |
|
66 | 66 | version_info = release.version_info |
|
67 | 67 | |
|
68 | 68 | def embed_kernel(module=None, local_ns=None, **kwargs): |
|
69 | 69 | """Embed and start an IPython kernel in a given scope. |
|
70 | 70 | |
|
71 | 71 | If you don't want the kernel to initialize the namespace |
|
72 | 72 | from the scope of the surrounding function, |
|
73 | 73 | and/or you want to load full IPython configuration, |
|
74 | 74 | you probably want `IPython.start_kernel()` instead. |
|
75 | 75 | |
|
76 | 76 | Parameters |
|
77 | 77 | ---------- |
|
78 | module : ModuleType, optional | |
|
78 | module : types.ModuleType, optional | |
|
79 | 79 | The module to load into IPython globals (default: caller) |
|
80 | 80 | local_ns : dict, optional |
|
81 | 81 | The namespace to load into IPython user namespace (default: caller) |
|
82 | 82 | |
|
83 | 83 | kwargs : various, optional |
|
84 | 84 | Further keyword args are relayed to the IPKernelApp constructor, |
|
85 | 85 | allowing configuration of the Kernel. Will only have an effect |
|
86 | 86 | on the first embed_kernel call for a given process. |
|
87 | 87 | """ |
|
88 | 88 | |
|
89 | 89 | (caller_module, caller_locals) = extract_module_locals(1) |
|
90 | 90 | if module is None: |
|
91 | 91 | module = caller_module |
|
92 | 92 | if local_ns is None: |
|
93 | 93 | local_ns = caller_locals |
|
94 | 94 | |
|
95 | 95 | # Only import .zmq when we really need it |
|
96 | 96 | from ipykernel.embed import embed_kernel as real_embed_kernel |
|
97 | 97 | real_embed_kernel(module=module, local_ns=local_ns, **kwargs) |
|
98 | 98 | |
|
99 | 99 | def start_ipython(argv=None, **kwargs): |
|
100 | 100 | """Launch a normal IPython instance (as opposed to embedded) |
|
101 | 101 | |
|
102 | 102 | `IPython.embed()` puts a shell in a particular calling scope, |
|
103 | 103 | such as a function or method for debugging purposes, |
|
104 | 104 | which is often not desirable. |
|
105 | 105 | |
|
106 | 106 | `start_ipython()` does full, regular IPython initialization, |
|
107 | 107 | including loading startup files, configuration, etc. |
|
108 | 108 | much of which is skipped by `embed()`. |
|
109 | 109 | |
|
110 | 110 | This is a public API method, and will survive implementation changes. |
|
111 | 111 | |
|
112 | 112 | Parameters |
|
113 | 113 | ---------- |
|
114 | 114 | |
|
115 | 115 | argv : list or None, optional |
|
116 | 116 | If unspecified or None, IPython will parse command-line options from sys.argv. |
|
117 | 117 | To prevent any command-line parsing, pass an empty list: `argv=[]`. |
|
118 | 118 | user_ns : dict, optional |
|
119 | 119 | specify this dictionary to initialize the IPython user namespace with particular values. |
|
120 | 120 | kwargs : various, optional |
|
121 | 121 | Any other kwargs will be passed to the Application constructor, |
|
122 | 122 | such as `config`. |
|
123 | 123 | """ |
|
124 | 124 | from IPython.terminal.ipapp import launch_new_instance |
|
125 | 125 | return launch_new_instance(argv=argv, **kwargs) |
|
126 | 126 | |
|
127 | 127 | def start_kernel(argv=None, **kwargs): |
|
128 | 128 | """Launch a normal IPython kernel instance (as opposed to embedded) |
|
129 | 129 | |
|
130 | 130 | `IPython.embed_kernel()` puts a shell in a particular calling scope, |
|
131 | 131 | such as a function or method for debugging purposes, |
|
132 | 132 | which is often not desirable. |
|
133 | 133 | |
|
134 | 134 | `start_kernel()` does full, regular IPython initialization, |
|
135 | 135 | including loading startup files, configuration, etc. |
|
136 | 136 | much of which is skipped by `embed()`. |
|
137 | 137 | |
|
138 | 138 | Parameters |
|
139 | 139 | ---------- |
|
140 | 140 | |
|
141 | 141 | argv : list or None, optional |
|
142 | 142 | If unspecified or None, IPython will parse command-line options from sys.argv. |
|
143 | 143 | To prevent any command-line parsing, pass an empty list: `argv=[]`. |
|
144 | 144 | user_ns : dict, optional |
|
145 | 145 | specify this dictionary to initialize the IPython user namespace with particular values. |
|
146 | 146 | kwargs : various, optional |
|
147 | 147 | Any other kwargs will be passed to the Application constructor, |
|
148 | 148 | such as `config`. |
|
149 | 149 | """ |
|
150 | 150 | from IPython.kernel.zmq.kernelapp import launch_new_instance |
|
151 | 151 | return launch_new_instance(argv=argv, **kwargs) |
@@ -1,296 +1,298 b'' | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | # |
|
3 | 3 | # IPython documentation build configuration file. |
|
4 | 4 | |
|
5 | 5 | # NOTE: This file has been edited manually from the auto-generated one from |
|
6 | 6 | # sphinx. Do NOT delete and re-generate. If any changes from sphinx are |
|
7 | 7 | # needed, generate a scratch one and merge by hand any new fields needed. |
|
8 | 8 | |
|
9 | 9 | # |
|
10 | 10 | # This file is execfile()d with the current directory set to its containing dir. |
|
11 | 11 | # |
|
12 | 12 | # The contents of this file are pickled, so don't put values in the namespace |
|
13 | 13 | # that aren't pickleable (module imports are okay, they're removed automatically). |
|
14 | 14 | # |
|
15 | 15 | # All configuration values have a default value; values that are commented out |
|
16 | 16 | # serve to show the default value. |
|
17 | 17 | |
|
18 | 18 | import sys, os |
|
19 | 19 | |
|
20 | 20 | # http://read-the-docs.readthedocs.io/en/latest/faq.html |
|
21 | 21 | ON_RTD = os.environ.get('READTHEDOCS', None) == 'True' |
|
22 | 22 | |
|
23 | 23 | if ON_RTD: |
|
24 | 24 | tags.add('rtd') |
|
25 | 25 | |
|
26 | 26 | # RTD doesn't use the Makefile, so re-run autogen_{things}.py here. |
|
27 | 27 | for name in ('config', 'api', 'magics', 'shortcuts'): |
|
28 | 28 | fname = 'autogen_{}.py'.format(name) |
|
29 | 29 | fpath = os.path.abspath(os.path.join('..', fname)) |
|
30 | 30 | with open(fpath) as f: |
|
31 | 31 | exec(compile(f.read(), fname, 'exec'), { |
|
32 | 32 | '__file__': fpath, |
|
33 | 33 | '__name__': '__main__', |
|
34 | 34 | }) |
|
35 | 35 | else: |
|
36 | 36 | import sphinx_rtd_theme |
|
37 | 37 | html_theme = "sphinx_rtd_theme" |
|
38 | 38 | html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] |
|
39 | 39 | |
|
40 | 40 | # If your extensions are in another directory, add it here. If the directory |
|
41 | 41 | # is relative to the documentation root, use os.path.abspath to make it |
|
42 | 42 | # absolute, like shown here. |
|
43 | 43 | sys.path.insert(0, os.path.abspath('../sphinxext')) |
|
44 | 44 | |
|
45 | 45 | # We load the ipython release info into a dict by explicit execution |
|
46 | 46 | iprelease = {} |
|
47 | 47 | exec(compile(open('../../IPython/core/release.py').read(), '../../IPython/core/release.py', 'exec'),iprelease) |
|
48 | 48 | |
|
49 | 49 | # General configuration |
|
50 | 50 | # --------------------- |
|
51 | 51 | |
|
52 | 52 | # Add any Sphinx extension module names here, as strings. They can be extensions |
|
53 | 53 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. |
|
54 | 54 | extensions = [ |
|
55 | 55 | 'sphinx.ext.autodoc', |
|
56 | 56 | 'sphinx.ext.autosummary', |
|
57 | 57 | 'sphinx.ext.doctest', |
|
58 | 58 | 'sphinx.ext.inheritance_diagram', |
|
59 | 59 | 'sphinx.ext.intersphinx', |
|
60 | 60 | 'sphinx.ext.graphviz', |
|
61 | 61 | 'IPython.sphinxext.ipython_console_highlighting', |
|
62 | 62 | 'IPython.sphinxext.ipython_directive', |
|
63 | 63 | 'sphinx.ext.napoleon', # to preprocess docstrings |
|
64 | 64 | 'github', # for easy GitHub links |
|
65 | 65 | 'magics', |
|
66 | 66 | 'configtraits', |
|
67 | 67 | ] |
|
68 | 68 | |
|
69 | nitpicky = True | |
|
70 | ||
|
69 | 71 | # Add any paths that contain templates here, relative to this directory. |
|
70 | 72 | templates_path = ['_templates'] |
|
71 | 73 | |
|
72 | 74 | # The suffix of source filenames. |
|
73 | 75 | source_suffix = '.rst' |
|
74 | 76 | |
|
75 | 77 | rst_prolog = '' |
|
76 | 78 | |
|
77 | 79 | def is_stable(extra): |
|
78 | 80 | for ext in {'dev', 'b', 'rc'}: |
|
79 | 81 | if ext in extra: |
|
80 | 82 | return False |
|
81 | 83 | return True |
|
82 | 84 | |
|
83 | 85 | if is_stable(iprelease['_version_extra']): |
|
84 | 86 | tags.add('ipystable') |
|
85 | 87 | print('Adding Tag: ipystable') |
|
86 | 88 | else: |
|
87 | 89 | tags.add('ipydev') |
|
88 | 90 | print('Adding Tag: ipydev') |
|
89 | 91 | rst_prolog += """ |
|
90 | 92 | .. warning:: |
|
91 | 93 | |
|
92 | 94 | This documentation covers a development version of IPython. The development |
|
93 | 95 | version may differ significantly from the latest stable release. |
|
94 | 96 | """ |
|
95 | 97 | |
|
96 | 98 | rst_prolog += """ |
|
97 | 99 | .. important:: |
|
98 | 100 | |
|
99 | 101 | This documentation covers IPython versions 6.0 and higher. Beginning with |
|
100 | 102 | version 6.0, IPython stopped supporting compatibility with Python versions |
|
101 | 103 | lower than 3.3 including all versions of Python 2.7. |
|
102 | 104 | |
|
103 | 105 | If you are looking for an IPython version compatible with Python 2.7, |
|
104 | 106 | please use the IPython 5.x LTS release and refer to its documentation (LTS |
|
105 | 107 | is the long term support release). |
|
106 | 108 | |
|
107 | 109 | """ |
|
108 | 110 | |
|
109 | 111 | # The master toctree document. |
|
110 | 112 | master_doc = 'index' |
|
111 | 113 | |
|
112 | 114 | # General substitutions. |
|
113 | 115 | project = 'IPython' |
|
114 | 116 | copyright = 'The IPython Development Team' |
|
115 | 117 | |
|
116 | 118 | # ghissue config |
|
117 | 119 | github_project_url = "https://github.com/ipython/ipython" |
|
118 | 120 | |
|
119 | 121 | # numpydoc config |
|
120 | 122 | numpydoc_show_class_members = False # Otherwise Sphinx emits thousands of warnings |
|
121 | 123 | numpydoc_class_members_toctree = False |
|
122 | 124 | warning_is_error = True |
|
123 | 125 | |
|
124 | 126 | # The default replacements for |version| and |release|, also used in various |
|
125 | 127 | # other places throughout the built documents. |
|
126 | 128 | # |
|
127 | 129 | # The full version, including alpha/beta/rc tags. |
|
128 | 130 | release = "%s" % iprelease['version'] |
|
129 | 131 | # Just the X.Y.Z part, no '-dev' |
|
130 | 132 | version = iprelease['version'].split('-', 1)[0] |
|
131 | 133 | |
|
132 | 134 | |
|
133 | 135 | # There are two options for replacing |today|: either, you set today to some |
|
134 | 136 | # non-false value, then it is used: |
|
135 | 137 | #today = '' |
|
136 | 138 | # Else, today_fmt is used as the format for a strftime call. |
|
137 | 139 | today_fmt = '%B %d, %Y' |
|
138 | 140 | |
|
139 | 141 | # List of documents that shouldn't be included in the build. |
|
140 | 142 | #unused_docs = [] |
|
141 | 143 | |
|
142 | 144 | # Exclude these glob-style patterns when looking for source files. They are |
|
143 | 145 | # relative to the source/ directory. |
|
144 | 146 | exclude_patterns = [] |
|
145 | 147 | |
|
146 | 148 | |
|
147 | 149 | # If true, '()' will be appended to :func: etc. cross-reference text. |
|
148 | 150 | #add_function_parentheses = True |
|
149 | 151 | |
|
150 | 152 | # If true, the current module name will be prepended to all description |
|
151 | 153 | # unit titles (such as .. function::). |
|
152 | 154 | #add_module_names = True |
|
153 | 155 | |
|
154 | 156 | # If true, sectionauthor and moduleauthor directives will be shown in the |
|
155 | 157 | # output. They are ignored by default. |
|
156 | 158 | #show_authors = False |
|
157 | 159 | |
|
158 | 160 | # The name of the Pygments (syntax highlighting) style to use. |
|
159 | 161 | pygments_style = 'sphinx' |
|
160 | 162 | |
|
161 | 163 | # Set the default role so we can use `foo` instead of ``foo`` |
|
162 | 164 | default_role = 'literal' |
|
163 | 165 | |
|
164 | 166 | # Options for HTML output |
|
165 | 167 | # ----------------------- |
|
166 | 168 | |
|
167 | 169 | # The style sheet to use for HTML and HTML Help pages. A file of that name |
|
168 | 170 | # must exist either in Sphinx' static/ path, or in one of the custom paths |
|
169 | 171 | # given in html_static_path. |
|
170 | 172 | # html_style = 'default.css' |
|
171 | 173 | |
|
172 | 174 | |
|
173 | 175 | # The name for this set of Sphinx documents. If None, it defaults to |
|
174 | 176 | # "<project> v<release> documentation". |
|
175 | 177 | #html_title = None |
|
176 | 178 | |
|
177 | 179 | # The name of an image file (within the static path) to place at the top of |
|
178 | 180 | # the sidebar. |
|
179 | 181 | #html_logo = None |
|
180 | 182 | |
|
181 | 183 | # Add any paths that contain custom static files (such as style sheets) here, |
|
182 | 184 | # relative to this directory. They are copied after the builtin static files, |
|
183 | 185 | # so a file named "default.css" will overwrite the builtin "default.css". |
|
184 | 186 | html_static_path = ['_static'] |
|
185 | 187 | |
|
186 | 188 | # Favicon needs the directory name |
|
187 | 189 | html_favicon = '_static/favicon.ico' |
|
188 | 190 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, |
|
189 | 191 | # using the given strftime format. |
|
190 | 192 | html_last_updated_fmt = '%b %d, %Y' |
|
191 | 193 | |
|
192 | 194 | # If true, SmartyPants will be used to convert quotes and dashes to |
|
193 | 195 | # typographically correct entities. |
|
194 | 196 | #html_use_smartypants = True |
|
195 | 197 | |
|
196 | 198 | # Custom sidebar templates, maps document names to template names. |
|
197 | 199 | #html_sidebars = {} |
|
198 | 200 | |
|
199 | 201 | # Additional templates that should be rendered to pages, maps page names to |
|
200 | 202 | # template names. |
|
201 | 203 | html_additional_pages = { |
|
202 | 204 | 'interactive/htmlnotebook': 'notebook_redirect.html', |
|
203 | 205 | 'interactive/notebook': 'notebook_redirect.html', |
|
204 | 206 | 'interactive/nbconvert': 'notebook_redirect.html', |
|
205 | 207 | 'interactive/public_server': 'notebook_redirect.html', |
|
206 | 208 | } |
|
207 | 209 | |
|
208 | 210 | # If false, no module index is generated. |
|
209 | 211 | #html_use_modindex = True |
|
210 | 212 | |
|
211 | 213 | # If true, the reST sources are included in the HTML build as _sources/<name>. |
|
212 | 214 | #html_copy_source = True |
|
213 | 215 | |
|
214 | 216 | # If true, an OpenSearch description file will be output, and all pages will |
|
215 | 217 | # contain a <link> tag referring to it. The value of this option must be the |
|
216 | 218 | # base URL from which the finished HTML is served. |
|
217 | 219 | #html_use_opensearch = '' |
|
218 | 220 | |
|
219 | 221 | # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). |
|
220 | 222 | #html_file_suffix = '' |
|
221 | 223 | |
|
222 | 224 | # Output file base name for HTML help builder. |
|
223 | 225 | htmlhelp_basename = 'ipythondoc' |
|
224 | 226 | |
|
225 | 227 | intersphinx_mapping = {'python': ('https://docs.python.org/3/', None), |
|
226 | 228 | 'rpy2': ('https://rpy2.readthedocs.io/en/version_2.8.x/', None), |
|
227 | 229 | 'traitlets': ('https://traitlets.readthedocs.io/en/latest/', None), |
|
228 | 230 | 'jupyterclient': ('https://jupyter-client.readthedocs.io/en/latest/', None), |
|
229 | 231 | 'ipyparallel': ('https://ipyparallel.readthedocs.io/en/latest/', None), |
|
230 | 232 | 'jupyter': ('https://jupyter.readthedocs.io/en/latest/', None), |
|
231 | 233 | 'jedi': ('https://jedi.readthedocs.io/en/latest/', None), |
|
232 | 234 | 'traitlets': ('https://traitlets.readthedocs.io/en/latest/', None), |
|
233 | 235 | 'ipykernel': ('https://ipykernel.readthedocs.io/en/latest/', None), |
|
234 | 236 | 'prompt_toolkit' : ('https://python-prompt-toolkit.readthedocs.io/en/stable/', None), |
|
235 | 237 | 'ipywidgets': ('https://ipywidgets.readthedocs.io/en/stable/', None), |
|
236 | 238 | 'ipyparallel': ('https://ipyparallel.readthedocs.io/en/stable/', None) |
|
237 | 239 | } |
|
238 | 240 | |
|
239 | 241 | # Options for LaTeX output |
|
240 | 242 | # ------------------------ |
|
241 | 243 | |
|
242 | 244 | # The paper size ('letter' or 'a4'). |
|
243 | 245 | latex_paper_size = 'letter' |
|
244 | 246 | |
|
245 | 247 | # The font size ('10pt', '11pt' or '12pt'). |
|
246 | 248 | latex_font_size = '11pt' |
|
247 | 249 | |
|
248 | 250 | # Grouping the document tree into LaTeX files. List of tuples |
|
249 | 251 | # (source start file, target name, title, author, document class [howto/manual]). |
|
250 | 252 | |
|
251 | 253 | latex_documents = [ |
|
252 | 254 | ('index', 'ipython.tex', 'IPython Documentation', |
|
253 | 255 | u"""The IPython Development Team""", 'manual', True), |
|
254 | 256 | ('parallel/winhpc_index', 'winhpc_whitepaper.tex', |
|
255 | 257 | 'Using IPython on Windows HPC Server 2008', |
|
256 | 258 | u"Brian E. Granger", 'manual', True) |
|
257 | 259 | ] |
|
258 | 260 | |
|
259 | 261 | # The name of an image file (relative to this directory) to place at the top of |
|
260 | 262 | # the title page. |
|
261 | 263 | #latex_logo = None |
|
262 | 264 | |
|
263 | 265 | # For "manual" documents, if this is true, then toplevel headings are parts, |
|
264 | 266 | # not chapters. |
|
265 | 267 | #latex_use_parts = False |
|
266 | 268 | |
|
267 | 269 | # Additional stuff for the LaTeX preamble. |
|
268 | 270 | #latex_preamble = '' |
|
269 | 271 | |
|
270 | 272 | # Documents to append as an appendix to all manuals. |
|
271 | 273 | #latex_appendices = [] |
|
272 | 274 | |
|
273 | 275 | # If false, no module index is generated. |
|
274 | 276 | latex_use_modindex = True |
|
275 | 277 | |
|
276 | 278 | |
|
277 | 279 | # Options for texinfo output |
|
278 | 280 | # -------------------------- |
|
279 | 281 | |
|
280 | 282 | texinfo_documents = [ |
|
281 | 283 | (master_doc, 'ipython', 'IPython Documentation', |
|
282 | 284 | 'The IPython Development Team', |
|
283 | 285 | 'IPython', |
|
284 | 286 | 'IPython Documentation', |
|
285 | 287 | 'Programming', |
|
286 | 288 | 1), |
|
287 | 289 | ] |
|
288 | 290 | |
|
289 | 291 | modindex_common_prefix = ['IPython.'] |
|
290 | 292 | |
|
291 | 293 | |
|
292 | 294 | # Cleanup |
|
293 | 295 | # ------- |
|
294 | 296 | # delete release info to avoid pickling errors from sphinx |
|
295 | 297 | |
|
296 | 298 | del iprelease |
@@ -1,230 +1,230 b'' | |||
|
1 | 1 | ============ |
|
2 | 2 | 7.x Series |
|
3 | 3 | ============ |
|
4 | 4 | |
|
5 | 5 | .. _whatsnew700: |
|
6 | 6 | |
|
7 | 7 | IPython 7.0.0 |
|
8 | 8 | ============= |
|
9 | 9 | |
|
10 | 10 | Released Thursday September 27th, 2018 |
|
11 | 11 | |
|
12 | 12 | IPython 7 include major features improvement as you can read in the following |
|
13 | 13 | changelog. This is also the second major version of IPython to support only |
|
14 | 14 | Python 3 βΒ starting at Python 3.4. Python 2 is still community supported |
|
15 | 15 | on the bugfix only 5.x branch, but we remind you that Python 2 "end of life" |
|
16 | 16 | is on Jan 1st 2020. |
|
17 | 17 | |
|
18 | 18 | We were able to backport bug fixes to the 5.x branch thanks to our backport bot which |
|
19 | 19 | backported more than `70 Pull-Requests |
|
20 | 20 | <https://github.com/ipython/ipython/pulls?page=3&q=is%3Apr+sort%3Aupdated-desc+author%3Aapp%2Fmeeseeksdev++5.x&utf8=%E2%9C%93>`_, but there are still many PRs that required manually work, and this is an area of the project were you can easily contribute by looking for `PRs still needed backport <https://github.com/ipython/ipython/issues?q=label%3A%22Still+Needs+Manual+Backport%22+is%3Aclosed+sort%3Aupdated-desc>`_ |
|
21 | 21 | |
|
22 | 22 | IPython 6.x branch will likely not see any further release unless critical |
|
23 | 23 | bugs are found. |
|
24 | 24 | |
|
25 | 25 | Make sure you have pip > 9.0 before upgrading. You should be able to update by simply running |
|
26 | 26 | |
|
27 | 27 | .. code:: |
|
28 | 28 | |
|
29 | 29 | pip install ipython --upgrade |
|
30 | 30 | |
|
31 | 31 | .. only:: ipydev |
|
32 | 32 | |
|
33 | 33 | If you are trying to install or update an ``alpha``, ``beta``, or ``rc`` |
|
34 | 34 | version, use pip ``--pre`` flag. |
|
35 | 35 | |
|
36 | 36 | .. code:: |
|
37 | 37 | |
|
38 | 38 | pip install ipython --upgrade --pre |
|
39 | 39 | |
|
40 | 40 | |
|
41 | 41 | Or if you have conda installed: |
|
42 | 42 | |
|
43 | 43 | .. code:: |
|
44 | 44 | |
|
45 | 45 | conda install ipython |
|
46 | 46 | |
|
47 | 47 | |
|
48 | 48 | |
|
49 | 49 | Prompt Toolkit 2.0 |
|
50 | 50 | ------------------ |
|
51 | 51 | |
|
52 | 52 | IPython 7.0+ now uses ``prompt_toolkit 2.0``, if you still need to use earlier |
|
53 | 53 | ``prompt_toolkit`` version you may need to pin IPython to ``<7.0``. |
|
54 | 54 | |
|
55 | 55 | Autowait: Asynchronous REPL |
|
56 | 56 | --------------------------- |
|
57 | 57 | |
|
58 | 58 | Staring with IPython 7.0 and on Python 3.6+, IPython can automatically await |
|
59 | 59 | code at top level, you should not need to access an event loop or runner |
|
60 | 60 | yourself. To know more read the :ref:`autoawait` section of our docs, see |
|
61 | 61 | :ghpull:`11265` or try the following code:: |
|
62 | 62 | |
|
63 | 63 | Python 3.6.0 |
|
64 | 64 | Type 'copyright', 'credits' or 'license' for more information |
|
65 | 65 | IPython 7.0.0 -- An enhanced Interactive Python. Type '?' for help. |
|
66 | 66 | |
|
67 | 67 | In [1]: import aiohttp |
|
68 | 68 | ...: result = aiohttp.get('https://api.github.com') |
|
69 | 69 | |
|
70 | 70 | In [2]: response = await result |
|
71 | 71 | <pause for a few 100s ms> |
|
72 | 72 | |
|
73 | 73 | In [3]: await response.json() |
|
74 | 74 | Out[3]: |
|
75 | 75 | {'authorizations_url': 'https://api.github.com/authorizations', |
|
76 | 76 | 'code_search_url': 'https://api.github.com/search/code?q={query}{&page,per_page,sort,order}', |
|
77 | 77 | ... |
|
78 | 78 | } |
|
79 | 79 | |
|
80 | 80 | .. note:: |
|
81 | 81 | |
|
82 | 82 | Async integration is experimental code, behavior may change or be removed |
|
83 | 83 | between Python and IPython versions without warnings. |
|
84 | 84 | |
|
85 | 85 | Integration is by default with `asyncio`, but other libraries can be configured, |
|
86 | 86 | like ``curio`` or ``trio``, to improve concurrency in the REPL:: |
|
87 | 87 | |
|
88 | 88 | In [1]: %autoawait trio |
|
89 | 89 | |
|
90 | 90 | In [2]: import trio |
|
91 | 91 | |
|
92 | 92 | In [3]: async def child(i): |
|
93 | 93 | ...: print(" child %s goes to sleep"%i) |
|
94 | 94 | ...: await trio.sleep(2) |
|
95 | 95 | ...: print(" child %s wakes up"%i) |
|
96 | 96 | |
|
97 | 97 | In [4]: print('parent start') |
|
98 | 98 | ...: async with trio.open_nursery() as n: |
|
99 | 99 | ...: for i in range(3): |
|
100 | 100 | ...: n.spawn(child, i) |
|
101 | 101 | ...: print('parent end') |
|
102 | 102 | parent start |
|
103 | 103 | child 2 goes to sleep |
|
104 | 104 | child 0 goes to sleep |
|
105 | 105 | child 1 goes to sleep |
|
106 | 106 | <about 2 seconds pause> |
|
107 | 107 | child 2 wakes up |
|
108 | 108 | child 1 wakes up |
|
109 | 109 | child 0 wakes up |
|
110 | 110 | parent end |
|
111 | 111 | |
|
112 | 112 | See :ref:`autoawait` for more information. |
|
113 | 113 | |
|
114 | 114 | |
|
115 | 115 | Asynchronous code in a Notebook interface or any other frontend using the |
|
116 | 116 | Jupyter Protocol will need further updates of the IPykernel package. |
|
117 | 117 | |
|
118 | 118 | Non-Asynchronous code |
|
119 | 119 | ~~~~~~~~~~~~~~~~~~~~~ |
|
120 | 120 | |
|
121 | 121 | As the internal API of IPython is now asynchronous, IPython needs to run under |
|
122 | 122 | an event loop. In order to allow many workflows, (like using the :magic:`%run` |
|
123 | 123 | magic, or copy_pasting code that explicitly starts/stop event loop), when |
|
124 | 124 | top-level code is detected as not being asynchronous, IPython code is advanced |
|
125 | 125 | via a pseudo-synchronous runner, and may not advance pending tasks. |
|
126 | 126 | |
|
127 | 127 | Change to Nested Embed |
|
128 | 128 | ~~~~~~~~~~~~~~~~~~~~~~ |
|
129 | 129 | |
|
130 | 130 | The introduction of the ability to run async code had some effect on the |
|
131 | 131 | ``IPython.embed()`` API. By default embed will not allow you to run asynchronous |
|
132 | 132 | code unless a event loop is specified. |
|
133 | 133 | |
|
134 | 134 | Effects on Magics |
|
135 | 135 | ~~~~~~~~~~~~~~~~~ |
|
136 | 136 | |
|
137 | 137 | Some magics will not work with Async, and will need updates. Contribution |
|
138 | 138 | welcome. |
|
139 | 139 | |
|
140 | 140 | Expected Future changes |
|
141 | 141 | ~~~~~~~~~~~~~~~~~~~~~~~ |
|
142 | 142 | |
|
143 | 143 | We expect more internal but public IPython function to become ``async``, and |
|
144 | 144 | will likely end up having a persisting event loop while IPython is running. |
|
145 | 145 | |
|
146 | 146 | Thanks |
|
147 | 147 | ~~~~~~ |
|
148 | 148 | |
|
149 | 149 | This took more than a year in the making, and the code was rebased a number of |
|
150 | 150 | time leading to commit authorship that may have been lost in the final |
|
151 | 151 | Pull-Request. Huge thanks to many people for contribution, discussion, code, |
|
152 | 152 | documentation, use-case: dalejung, danielballan, ellisonbg, fperez, gnestor, |
|
153 | 153 | minrk, njsmith, pganssle, tacaswell, takluyver , vidartf ... And many others. |
|
154 | 154 | |
|
155 | 155 | |
|
156 | 156 | Autoreload Improvement |
|
157 | 157 | ---------------------- |
|
158 | 158 | |
|
159 | 159 | The magic :magic:`%autoreload 2 <autoreload>` now captures new methods added to |
|
160 | 160 | classes. Earlier, only methods existing as of the initial import were being |
|
161 | 161 | tracked and updated. |
|
162 | 162 | |
|
163 | 163 | This new feature helps dual environment development - Jupyter+IDE - where the |
|
164 | 164 | code gradually moves from notebook cells to package files, as it gets |
|
165 | 165 | structured. |
|
166 | 166 | |
|
167 | 167 | **Example**: An instance of the class ``MyClass`` will be able to access the |
|
168 | 168 | method ``cube()`` after it is uncommented and the file ``file1.py`` saved on |
|
169 | 169 | disk. |
|
170 | 170 | |
|
171 | 171 | |
|
172 | 172 | ..code:: |
|
173 | 173 | |
|
174 | 174 | # notebook |
|
175 | 175 | |
|
176 | 176 | from mymodule import MyClass |
|
177 | 177 | first = MyClass(5) |
|
178 | 178 | |
|
179 | 179 | .. code:: |
|
180 | 180 | |
|
181 | 181 | # mymodule/file1.py |
|
182 | 182 | |
|
183 | 183 | class MyClass: |
|
184 | 184 | |
|
185 | 185 | def __init__(self, a=10): |
|
186 | 186 | self.a = a |
|
187 | 187 | |
|
188 | 188 | def square(self): |
|
189 | 189 | print('compute square') |
|
190 | 190 | return self.a*self.a |
|
191 | 191 | |
|
192 | 192 | # def cube(self): |
|
193 | 193 | # print('compute cube') |
|
194 | 194 | # return self.a*self.a*self.a |
|
195 | 195 | |
|
196 | 196 | |
|
197 | 197 | |
|
198 | 198 | |
|
199 | 199 | Misc |
|
200 | 200 | ---- |
|
201 | 201 | |
|
202 | 202 | The autoindent feature that was deprecated in 5.x was re-enabled and |
|
203 | 203 | un-deprecated in :ghpull:`11257` |
|
204 | 204 | |
|
205 | 205 | Make :magic:`%run -n -i ... <run>` work correctly. Earlier, if :magic:`%run` was |
|
206 | 206 | passed both arguments, ``-n`` would be silently ignored. See :ghpull:`10308` |
|
207 | 207 | |
|
208 | 208 | |
|
209 |
The :cellmagic:`%%script` |
|
|
210 |
:cellmagic:`%%ruby` |
|
|
209 | The :cellmagic:`%%script` (as well as :cellmagic:`%%bash`, | |
|
210 | :cellmagic:`%%ruby`... ) cell magics now raise by default if the return code of | |
|
211 | 211 | the given code is non-zero (thus halting execution of further cells in a |
|
212 | 212 | notebook). The behavior can be disable by passing the ``--no-raise-error`` flag. |
|
213 | 213 | |
|
214 | 214 | |
|
215 | 215 | Deprecations |
|
216 | 216 | ------------ |
|
217 | 217 | |
|
218 | 218 | A couple of unused function and methods have been deprecated and will be removed |
|
219 | 219 | in future versions: |
|
220 | 220 | |
|
221 | 221 | - ``IPython.utils.io.raw_print_err`` |
|
222 | 222 | - ``IPython.utils.io.raw_print`` |
|
223 | 223 | |
|
224 | 224 | |
|
225 | 225 | Backwards incompatible changes |
|
226 | 226 | ------------------------------ |
|
227 | 227 | |
|
228 | 228 | * The API for transforming input before it is parsed as Python code has been |
|
229 | 229 | completely redesigned, and any custom input transformations will need to be |
|
230 | 230 | rewritten. See :doc:`/config/inputtransforms` for details of the new API. |
General Comments 0
You need to be logged in to leave comments.
Login now