Show More
@@ -0,0 +1,56 b'' | |||
|
1 | """ | |
|
2 | Test that CVEs stay fixed. | |
|
3 | """ | |
|
4 | ||
|
5 | from IPython.utils.tempdir import TemporaryDirectory, TemporaryWorkingDirectory | |
|
6 | from pathlib import Path | |
|
7 | import random | |
|
8 | import sys | |
|
9 | import os | |
|
10 | import string | |
|
11 | import subprocess | |
|
12 | import time | |
|
13 | ||
|
14 | def test_cve_2022_21699(): | |
|
15 | """ | |
|
16 | Here we test CVE-2022-21699. | |
|
17 | ||
|
18 | We create a temporary directory, cd into it. | |
|
19 | Make a profile file that should not be executed and start IPython in a subprocess, | |
|
20 | checking for the value. | |
|
21 | ||
|
22 | ||
|
23 | ||
|
24 | """ | |
|
25 | ||
|
26 | dangerous_profile_dir = Path('profile_default') | |
|
27 | ||
|
28 | dangerous_startup_dir = dangerous_profile_dir / 'startup' | |
|
29 | dangerous_expected = 'CVE-2022-21699-'+''.join([random.choice(string.ascii_letters) for i in range(10)]) | |
|
30 | ||
|
31 | with TemporaryWorkingDirectory() as t: | |
|
32 | dangerous_startup_dir.mkdir(parents=True) | |
|
33 | (dangerous_startup_dir/ 'foo.py').write_text(f'print("{dangerous_expected}")') | |
|
34 | # 1 sec to make sure FS is flushed. | |
|
35 | #time.sleep(1) | |
|
36 | cmd = [sys.executable,'-m', 'IPython'] | |
|
37 | env = os.environ.copy() | |
|
38 | env['IPY_TEST_SIMPLE_PROMPT'] = '1' | |
|
39 | ||
|
40 | ||
|
41 | # First we fake old behavior, making sure the profile is/was actually dangerous | |
|
42 | p_dangerous = subprocess.Popen(cmd + [f'--profile-dir={dangerous_profile_dir}'], env=env, stdin=subprocess.PIPE, | |
|
43 | stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
|
44 | out_dangerous, err_dangerouns = p_dangerous.communicate(b"exit\r") | |
|
45 | assert dangerous_expected in out_dangerous.decode() | |
|
46 | ||
|
47 | # Now that we know it _would_ have been dangerous, we test it's not loaded | |
|
48 | p = subprocess.Popen(cmd, env=env, stdin=subprocess.PIPE, | |
|
49 | stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
|
50 | out, err = p.communicate(b"exit\r") | |
|
51 | assert b'IPython' in out | |
|
52 | assert dangerous_expected not in out.decode() | |
|
53 | assert err == b'' | |
|
54 | ||
|
55 | ||
|
56 |
@@ -1,152 +1,156 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, 6): |
|
31 | 31 | raise ImportError( |
|
32 | 32 | """ |
|
33 | 33 | IPython 7.10+ supports Python 3.6 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 | Python 3.5 was supported with IPython 7.0 to 7.9. |
|
37 | 37 | |
|
38 | 38 | See IPython `README.rst` file for more information: |
|
39 | 39 | |
|
40 | 40 | https://github.com/ipython/ipython/blob/master/README.rst |
|
41 | 41 | |
|
42 | 42 | """) |
|
43 | 43 | |
|
44 | 44 | # Make it easy to import extensions - they are always directly on pythonpath. |
|
45 | 45 | # Therefore, non-IPython modules can be added to extensions directory. |
|
46 | 46 | # This should probably be in ipapp.py. |
|
47 | 47 | sys.path.append(os.path.join(os.path.dirname(__file__), "extensions")) |
|
48 | 48 | |
|
49 | 49 | #----------------------------------------------------------------------------- |
|
50 | 50 | # Setup the top level names |
|
51 | 51 | #----------------------------------------------------------------------------- |
|
52 | 52 | |
|
53 | 53 | from .core.getipython import get_ipython |
|
54 | 54 | from .core import release |
|
55 | 55 | from .core.application import Application |
|
56 | 56 | from .terminal.embed import embed |
|
57 | 57 | |
|
58 | 58 | from .core.interactiveshell import InteractiveShell |
|
59 | 59 | from .testing import test |
|
60 | 60 | from .utils.sysinfo import sys_info |
|
61 | 61 | from .utils.frame import extract_module_locals |
|
62 | 62 | |
|
63 | 63 | # Release data |
|
64 | 64 | __author__ = '%s <%s>' % (release.author, release.author_email) |
|
65 | 65 | __license__ = release.license |
|
66 | 66 | __version__ = release.version |
|
67 | 67 | version_info = release.version_info |
|
68 | # list of CVEs that should have been patched in this release. | |
|
69 | # this is informational and should not be relied upon. | |
|
70 | __patched_cves__ = {"CVE-2022-21699"} | |
|
71 | ||
|
68 | 72 | |
|
69 | 73 | def embed_kernel(module=None, local_ns=None, **kwargs): |
|
70 | 74 | """Embed and start an IPython kernel in a given scope. |
|
71 | 75 | |
|
72 | 76 | If you don't want the kernel to initialize the namespace |
|
73 | 77 | from the scope of the surrounding function, |
|
74 | 78 | and/or you want to load full IPython configuration, |
|
75 | 79 | you probably want `IPython.start_kernel()` instead. |
|
76 | 80 | |
|
77 | 81 | Parameters |
|
78 | 82 | ---------- |
|
79 | 83 | module : types.ModuleType, optional |
|
80 | 84 | The module to load into IPython globals (default: caller) |
|
81 | 85 | local_ns : dict, optional |
|
82 | 86 | The namespace to load into IPython user namespace (default: caller) |
|
83 | 87 | |
|
84 | 88 | kwargs : various, optional |
|
85 | 89 | Further keyword args are relayed to the IPKernelApp constructor, |
|
86 | 90 | allowing configuration of the Kernel. Will only have an effect |
|
87 | 91 | on the first embed_kernel call for a given process. |
|
88 | 92 | """ |
|
89 | 93 | |
|
90 | 94 | (caller_module, caller_locals) = extract_module_locals(1) |
|
91 | 95 | if module is None: |
|
92 | 96 | module = caller_module |
|
93 | 97 | if local_ns is None: |
|
94 | 98 | local_ns = caller_locals |
|
95 | 99 | |
|
96 | 100 | # Only import .zmq when we really need it |
|
97 | 101 | from ipykernel.embed import embed_kernel as real_embed_kernel |
|
98 | 102 | real_embed_kernel(module=module, local_ns=local_ns, **kwargs) |
|
99 | 103 | |
|
100 | 104 | def start_ipython(argv=None, **kwargs): |
|
101 | 105 | """Launch a normal IPython instance (as opposed to embedded) |
|
102 | 106 | |
|
103 | 107 | `IPython.embed()` puts a shell in a particular calling scope, |
|
104 | 108 | such as a function or method for debugging purposes, |
|
105 | 109 | which is often not desirable. |
|
106 | 110 | |
|
107 | 111 | `start_ipython()` does full, regular IPython initialization, |
|
108 | 112 | including loading startup files, configuration, etc. |
|
109 | 113 | much of which is skipped by `embed()`. |
|
110 | 114 | |
|
111 | 115 | This is a public API method, and will survive implementation changes. |
|
112 | 116 | |
|
113 | 117 | Parameters |
|
114 | 118 | ---------- |
|
115 | 119 | |
|
116 | 120 | argv : list or None, optional |
|
117 | 121 | If unspecified or None, IPython will parse command-line options from sys.argv. |
|
118 | 122 | To prevent any command-line parsing, pass an empty list: `argv=[]`. |
|
119 | 123 | user_ns : dict, optional |
|
120 | 124 | specify this dictionary to initialize the IPython user namespace with particular values. |
|
121 | 125 | kwargs : various, optional |
|
122 | 126 | Any other kwargs will be passed to the Application constructor, |
|
123 | 127 | such as `config`. |
|
124 | 128 | """ |
|
125 | 129 | from IPython.terminal.ipapp import launch_new_instance |
|
126 | 130 | return launch_new_instance(argv=argv, **kwargs) |
|
127 | 131 | |
|
128 | 132 | def start_kernel(argv=None, **kwargs): |
|
129 | 133 | """Launch a normal IPython kernel instance (as opposed to embedded) |
|
130 | 134 | |
|
131 | 135 | `IPython.embed_kernel()` puts a shell in a particular calling scope, |
|
132 | 136 | such as a function or method for debugging purposes, |
|
133 | 137 | which is often not desirable. |
|
134 | 138 | |
|
135 | 139 | `start_kernel()` does full, regular IPython initialization, |
|
136 | 140 | including loading startup files, configuration, etc. |
|
137 | 141 | much of which is skipped by `embed()`. |
|
138 | 142 | |
|
139 | 143 | Parameters |
|
140 | 144 | ---------- |
|
141 | 145 | |
|
142 | 146 | argv : list or None, optional |
|
143 | 147 | If unspecified or None, IPython will parse command-line options from sys.argv. |
|
144 | 148 | To prevent any command-line parsing, pass an empty list: `argv=[]`. |
|
145 | 149 | user_ns : dict, optional |
|
146 | 150 | specify this dictionary to initialize the IPython user namespace with particular values. |
|
147 | 151 | kwargs : various, optional |
|
148 | 152 | Any other kwargs will be passed to the Application constructor, |
|
149 | 153 | such as `config`. |
|
150 | 154 | """ |
|
151 | 155 | from IPython.kernel.zmq.kernelapp import launch_new_instance |
|
152 | 156 | return launch_new_instance(argv=argv, **kwargs) |
@@ -1,462 +1,462 b'' | |||
|
1 | 1 | # encoding: utf-8 |
|
2 | 2 | """ |
|
3 | 3 | An application for IPython. |
|
4 | 4 | |
|
5 | 5 | All top-level applications should use the classes in this module for |
|
6 | 6 | handling configuration and creating configurables. |
|
7 | 7 | |
|
8 | 8 | The job of an :class:`Application` is to create the master configuration |
|
9 | 9 | object and then create the configurable objects, passing the config to them. |
|
10 | 10 | """ |
|
11 | 11 | |
|
12 | 12 | # Copyright (c) IPython Development Team. |
|
13 | 13 | # Distributed under the terms of the Modified BSD License. |
|
14 | 14 | |
|
15 | 15 | import atexit |
|
16 | 16 | from copy import deepcopy |
|
17 | 17 | import glob |
|
18 | 18 | import logging |
|
19 | 19 | import os |
|
20 | 20 | import shutil |
|
21 | 21 | import sys |
|
22 | 22 | |
|
23 | 23 | from traitlets.config.application import Application, catch_config_error |
|
24 | 24 | from traitlets.config.loader import ConfigFileNotFound, PyFileConfigLoader |
|
25 | 25 | from IPython.core import release, crashhandler |
|
26 | 26 | from IPython.core.profiledir import ProfileDir, ProfileDirError |
|
27 | 27 | from IPython.paths import get_ipython_dir, get_ipython_package_dir |
|
28 | 28 | from IPython.utils.path import ensure_dir_exists |
|
29 | 29 | from traitlets import ( |
|
30 | 30 | List, Unicode, Type, Bool, Set, Instance, Undefined, |
|
31 | 31 | default, observe, |
|
32 | 32 | ) |
|
33 | 33 | |
|
34 | 34 | if os.name == 'nt': |
|
35 | 35 | programdata = os.environ.get('PROGRAMDATA', None) |
|
36 | 36 | if programdata: |
|
37 | 37 | SYSTEM_CONFIG_DIRS = [os.path.join(programdata, 'ipython')] |
|
38 | 38 | else: # PROGRAMDATA is not defined by default on XP. |
|
39 | 39 | SYSTEM_CONFIG_DIRS = [] |
|
40 | 40 | else: |
|
41 | 41 | SYSTEM_CONFIG_DIRS = [ |
|
42 | 42 | "/usr/local/etc/ipython", |
|
43 | 43 | "/etc/ipython", |
|
44 | 44 | ] |
|
45 | 45 | |
|
46 | 46 | |
|
47 | 47 | ENV_CONFIG_DIRS = [] |
|
48 | 48 | _env_config_dir = os.path.join(sys.prefix, 'etc', 'ipython') |
|
49 | 49 | if _env_config_dir not in SYSTEM_CONFIG_DIRS: |
|
50 | 50 | # only add ENV_CONFIG if sys.prefix is not already included |
|
51 | 51 | ENV_CONFIG_DIRS.append(_env_config_dir) |
|
52 | 52 | |
|
53 | 53 | |
|
54 | 54 | _envvar = os.environ.get('IPYTHON_SUPPRESS_CONFIG_ERRORS') |
|
55 | 55 | if _envvar in {None, ''}: |
|
56 | 56 | IPYTHON_SUPPRESS_CONFIG_ERRORS = None |
|
57 | 57 | else: |
|
58 | 58 | if _envvar.lower() in {'1','true'}: |
|
59 | 59 | IPYTHON_SUPPRESS_CONFIG_ERRORS = True |
|
60 | 60 | elif _envvar.lower() in {'0','false'} : |
|
61 | 61 | IPYTHON_SUPPRESS_CONFIG_ERRORS = False |
|
62 | 62 | else: |
|
63 | 63 | sys.exit("Unsupported value for environment variable: 'IPYTHON_SUPPRESS_CONFIG_ERRORS' is set to '%s' which is none of {'0', '1', 'false', 'true', ''}."% _envvar ) |
|
64 | 64 | |
|
65 | 65 | # aliases and flags |
|
66 | 66 | |
|
67 | 67 | base_aliases = { |
|
68 | 68 | 'profile-dir' : 'ProfileDir.location', |
|
69 | 69 | 'profile' : 'BaseIPythonApplication.profile', |
|
70 | 70 | 'ipython-dir' : 'BaseIPythonApplication.ipython_dir', |
|
71 | 71 | 'log-level' : 'Application.log_level', |
|
72 | 72 | 'config' : 'BaseIPythonApplication.extra_config_file', |
|
73 | 73 | } |
|
74 | 74 | |
|
75 | 75 | base_flags = dict( |
|
76 | 76 | debug = ({'Application' : {'log_level' : logging.DEBUG}}, |
|
77 | 77 | "set log level to logging.DEBUG (maximize logging output)"), |
|
78 | 78 | quiet = ({'Application' : {'log_level' : logging.CRITICAL}}, |
|
79 | 79 | "set log level to logging.CRITICAL (minimize logging output)"), |
|
80 | 80 | init = ({'BaseIPythonApplication' : { |
|
81 | 81 | 'copy_config_files' : True, |
|
82 | 82 | 'auto_create' : True} |
|
83 | 83 | }, """Initialize profile with default config files. This is equivalent |
|
84 | 84 | to running `ipython profile create <profile>` prior to startup. |
|
85 | 85 | """) |
|
86 | 86 | ) |
|
87 | 87 | |
|
88 | 88 | class ProfileAwareConfigLoader(PyFileConfigLoader): |
|
89 | 89 | """A Python file config loader that is aware of IPython profiles.""" |
|
90 | 90 | def load_subconfig(self, fname, path=None, profile=None): |
|
91 | 91 | if profile is not None: |
|
92 | 92 | try: |
|
93 | 93 | profile_dir = ProfileDir.find_profile_dir_by_name( |
|
94 | 94 | get_ipython_dir(), |
|
95 | 95 | profile, |
|
96 | 96 | ) |
|
97 | 97 | except ProfileDirError: |
|
98 | 98 | return |
|
99 | 99 | path = profile_dir.location |
|
100 | 100 | return super(ProfileAwareConfigLoader, self).load_subconfig(fname, path=path) |
|
101 | 101 | |
|
102 | 102 | class BaseIPythonApplication(Application): |
|
103 | 103 | |
|
104 | 104 | name = u'ipython' |
|
105 | 105 | description = Unicode(u'IPython: an enhanced interactive Python shell.') |
|
106 | 106 | version = Unicode(release.version) |
|
107 | 107 | |
|
108 | 108 | aliases = base_aliases |
|
109 | 109 | flags = base_flags |
|
110 | 110 | classes = List([ProfileDir]) |
|
111 | 111 | |
|
112 | 112 | # enable `load_subconfig('cfg.py', profile='name')` |
|
113 | 113 | python_config_loader_class = ProfileAwareConfigLoader |
|
114 | 114 | |
|
115 | 115 | # Track whether the config_file has changed, |
|
116 | 116 | # because some logic happens only if we aren't using the default. |
|
117 | 117 | config_file_specified = Set() |
|
118 | 118 | |
|
119 | 119 | config_file_name = Unicode() |
|
120 | 120 | @default('config_file_name') |
|
121 | 121 | def _config_file_name_default(self): |
|
122 | 122 | return self.name.replace('-','_') + u'_config.py' |
|
123 | 123 | @observe('config_file_name') |
|
124 | 124 | def _config_file_name_changed(self, change): |
|
125 | 125 | if change['new'] != change['old']: |
|
126 | 126 | self.config_file_specified.add(change['new']) |
|
127 | 127 | |
|
128 | 128 | # The directory that contains IPython's builtin profiles. |
|
129 | 129 | builtin_profile_dir = Unicode( |
|
130 | 130 | os.path.join(get_ipython_package_dir(), u'config', u'profile', u'default') |
|
131 | 131 | ) |
|
132 | 132 | |
|
133 | 133 | config_file_paths = List(Unicode()) |
|
134 | 134 | @default('config_file_paths') |
|
135 | 135 | def _config_file_paths_default(self): |
|
136 |
return [ |
|
|
136 | return [] | |
|
137 | 137 | |
|
138 | 138 | extra_config_file = Unicode( |
|
139 | 139 | help="""Path to an extra config file to load. |
|
140 | 140 | |
|
141 | 141 | If specified, load this config file in addition to any other IPython config. |
|
142 | 142 | """).tag(config=True) |
|
143 | 143 | @observe('extra_config_file') |
|
144 | 144 | def _extra_config_file_changed(self, change): |
|
145 | 145 | old = change['old'] |
|
146 | 146 | new = change['new'] |
|
147 | 147 | try: |
|
148 | 148 | self.config_files.remove(old) |
|
149 | 149 | except ValueError: |
|
150 | 150 | pass |
|
151 | 151 | self.config_file_specified.add(new) |
|
152 | 152 | self.config_files.append(new) |
|
153 | 153 | |
|
154 | 154 | profile = Unicode(u'default', |
|
155 | 155 | help="""The IPython profile to use.""" |
|
156 | 156 | ).tag(config=True) |
|
157 | 157 | |
|
158 | 158 | @observe('profile') |
|
159 | 159 | def _profile_changed(self, change): |
|
160 | 160 | self.builtin_profile_dir = os.path.join( |
|
161 | 161 | get_ipython_package_dir(), u'config', u'profile', change['new'] |
|
162 | 162 | ) |
|
163 | 163 | |
|
164 | 164 | ipython_dir = Unicode( |
|
165 | 165 | help=""" |
|
166 | 166 | The name of the IPython directory. This directory is used for logging |
|
167 | 167 | configuration (through profiles), history storage, etc. The default |
|
168 | 168 | is usually $HOME/.ipython. This option can also be specified through |
|
169 | 169 | the environment variable IPYTHONDIR. |
|
170 | 170 | """ |
|
171 | 171 | ).tag(config=True) |
|
172 | 172 | @default('ipython_dir') |
|
173 | 173 | def _ipython_dir_default(self): |
|
174 | 174 | d = get_ipython_dir() |
|
175 | 175 | self._ipython_dir_changed({ |
|
176 | 176 | 'name': 'ipython_dir', |
|
177 | 177 | 'old': d, |
|
178 | 178 | 'new': d, |
|
179 | 179 | }) |
|
180 | 180 | return d |
|
181 | 181 | |
|
182 | 182 | _in_init_profile_dir = False |
|
183 | 183 | profile_dir = Instance(ProfileDir, allow_none=True) |
|
184 | 184 | @default('profile_dir') |
|
185 | 185 | def _profile_dir_default(self): |
|
186 | 186 | # avoid recursion |
|
187 | 187 | if self._in_init_profile_dir: |
|
188 | 188 | return |
|
189 | 189 | # profile_dir requested early, force initialization |
|
190 | 190 | self.init_profile_dir() |
|
191 | 191 | return self.profile_dir |
|
192 | 192 | |
|
193 | 193 | overwrite = Bool(False, |
|
194 | 194 | help="""Whether to overwrite existing config files when copying""" |
|
195 | 195 | ).tag(config=True) |
|
196 | 196 | auto_create = Bool(False, |
|
197 | 197 | help="""Whether to create profile dir if it doesn't exist""" |
|
198 | 198 | ).tag(config=True) |
|
199 | 199 | |
|
200 | 200 | config_files = List(Unicode()) |
|
201 | 201 | @default('config_files') |
|
202 | 202 | def _config_files_default(self): |
|
203 | 203 | return [self.config_file_name] |
|
204 | 204 | |
|
205 | 205 | copy_config_files = Bool(False, |
|
206 | 206 | help="""Whether to install the default config files into the profile dir. |
|
207 | 207 | If a new profile is being created, and IPython contains config files for that |
|
208 | 208 | profile, then they will be staged into the new directory. Otherwise, |
|
209 | 209 | default config files will be automatically generated. |
|
210 | 210 | """).tag(config=True) |
|
211 | 211 | |
|
212 | 212 | verbose_crash = Bool(False, |
|
213 | 213 | help="""Create a massive crash report when IPython encounters what may be an |
|
214 | 214 | internal error. The default is to append a short message to the |
|
215 | 215 | usual traceback""").tag(config=True) |
|
216 | 216 | |
|
217 | 217 | # The class to use as the crash handler. |
|
218 | 218 | crash_handler_class = Type(crashhandler.CrashHandler) |
|
219 | 219 | |
|
220 | 220 | @catch_config_error |
|
221 | 221 | def __init__(self, **kwargs): |
|
222 | 222 | super(BaseIPythonApplication, self).__init__(**kwargs) |
|
223 | 223 | # ensure current working directory exists |
|
224 | 224 | try: |
|
225 | 225 | os.getcwd() |
|
226 | 226 | except: |
|
227 | 227 | # exit if cwd doesn't exist |
|
228 | 228 | self.log.error("Current working directory doesn't exist.") |
|
229 | 229 | self.exit(1) |
|
230 | 230 | |
|
231 | 231 | #------------------------------------------------------------------------- |
|
232 | 232 | # Various stages of Application creation |
|
233 | 233 | #------------------------------------------------------------------------- |
|
234 | 234 | |
|
235 | 235 | deprecated_subcommands = {} |
|
236 | 236 | |
|
237 | 237 | def initialize_subcommand(self, subc, argv=None): |
|
238 | 238 | if subc in self.deprecated_subcommands: |
|
239 | 239 | self.log.warning("Subcommand `ipython {sub}` is deprecated and will be removed " |
|
240 | 240 | "in future versions.".format(sub=subc)) |
|
241 | 241 | self.log.warning("You likely want to use `jupyter {sub}` in the " |
|
242 | 242 | "future".format(sub=subc)) |
|
243 | 243 | return super(BaseIPythonApplication, self).initialize_subcommand(subc, argv) |
|
244 | 244 | |
|
245 | 245 | def init_crash_handler(self): |
|
246 | 246 | """Create a crash handler, typically setting sys.excepthook to it.""" |
|
247 | 247 | self.crash_handler = self.crash_handler_class(self) |
|
248 | 248 | sys.excepthook = self.excepthook |
|
249 | 249 | def unset_crashhandler(): |
|
250 | 250 | sys.excepthook = sys.__excepthook__ |
|
251 | 251 | atexit.register(unset_crashhandler) |
|
252 | 252 | |
|
253 | 253 | def excepthook(self, etype, evalue, tb): |
|
254 | 254 | """this is sys.excepthook after init_crashhandler |
|
255 | 255 | |
|
256 | 256 | set self.verbose_crash=True to use our full crashhandler, instead of |
|
257 | 257 | a regular traceback with a short message (crash_handler_lite) |
|
258 | 258 | """ |
|
259 | 259 | |
|
260 | 260 | if self.verbose_crash: |
|
261 | 261 | return self.crash_handler(etype, evalue, tb) |
|
262 | 262 | else: |
|
263 | 263 | return crashhandler.crash_handler_lite(etype, evalue, tb) |
|
264 | 264 | |
|
265 | 265 | @observe('ipython_dir') |
|
266 | 266 | def _ipython_dir_changed(self, change): |
|
267 | 267 | old = change['old'] |
|
268 | 268 | new = change['new'] |
|
269 | 269 | if old is not Undefined: |
|
270 | 270 | str_old = os.path.abspath(old) |
|
271 | 271 | if str_old in sys.path: |
|
272 | 272 | sys.path.remove(str_old) |
|
273 | 273 | str_path = os.path.abspath(new) |
|
274 | 274 | sys.path.append(str_path) |
|
275 | 275 | ensure_dir_exists(new) |
|
276 | 276 | readme = os.path.join(new, 'README') |
|
277 | 277 | readme_src = os.path.join(get_ipython_package_dir(), u'config', u'profile', 'README') |
|
278 | 278 | if not os.path.exists(readme) and os.path.exists(readme_src): |
|
279 | 279 | shutil.copy(readme_src, readme) |
|
280 | 280 | for d in ('extensions', 'nbextensions'): |
|
281 | 281 | path = os.path.join(new, d) |
|
282 | 282 | try: |
|
283 | 283 | ensure_dir_exists(path) |
|
284 | 284 | except OSError as e: |
|
285 | 285 | # this will not be EEXIST |
|
286 | 286 | self.log.error("couldn't create path %s: %s", path, e) |
|
287 | 287 | self.log.debug("IPYTHONDIR set to: %s" % new) |
|
288 | 288 | |
|
289 | 289 | def load_config_file(self, suppress_errors=IPYTHON_SUPPRESS_CONFIG_ERRORS): |
|
290 | 290 | """Load the config file. |
|
291 | 291 | |
|
292 | 292 | By default, errors in loading config are handled, and a warning |
|
293 | 293 | printed on screen. For testing, the suppress_errors option is set |
|
294 | 294 | to False, so errors will make tests fail. |
|
295 | 295 | |
|
296 | 296 | `suppress_errors` default value is to be `None` in which case the |
|
297 | 297 | behavior default to the one of `traitlets.Application`. |
|
298 | 298 | |
|
299 | 299 | The default value can be set : |
|
300 | 300 | - to `False` by setting 'IPYTHON_SUPPRESS_CONFIG_ERRORS' environment variable to '0', or 'false' (case insensitive). |
|
301 | 301 | - to `True` by setting 'IPYTHON_SUPPRESS_CONFIG_ERRORS' environment variable to '1' or 'true' (case insensitive). |
|
302 | 302 | - to `None` by setting 'IPYTHON_SUPPRESS_CONFIG_ERRORS' environment variable to '' (empty string) or leaving it unset. |
|
303 | 303 | |
|
304 | 304 | Any other value are invalid, and will make IPython exit with a non-zero return code. |
|
305 | 305 | """ |
|
306 | 306 | |
|
307 | 307 | |
|
308 | 308 | self.log.debug("Searching path %s for config files", self.config_file_paths) |
|
309 | 309 | base_config = 'ipython_config.py' |
|
310 | 310 | self.log.debug("Attempting to load config file: %s" % |
|
311 | 311 | base_config) |
|
312 | 312 | try: |
|
313 | 313 | if suppress_errors is not None: |
|
314 | 314 | old_value = Application.raise_config_file_errors |
|
315 | 315 | Application.raise_config_file_errors = not suppress_errors; |
|
316 | 316 | Application.load_config_file( |
|
317 | 317 | self, |
|
318 | 318 | base_config, |
|
319 | 319 | path=self.config_file_paths |
|
320 | 320 | ) |
|
321 | 321 | except ConfigFileNotFound: |
|
322 | 322 | # ignore errors loading parent |
|
323 | 323 | self.log.debug("Config file %s not found", base_config) |
|
324 | 324 | pass |
|
325 | 325 | if suppress_errors is not None: |
|
326 | 326 | Application.raise_config_file_errors = old_value |
|
327 | 327 | |
|
328 | 328 | for config_file_name in self.config_files: |
|
329 | 329 | if not config_file_name or config_file_name == base_config: |
|
330 | 330 | continue |
|
331 | 331 | self.log.debug("Attempting to load config file: %s" % |
|
332 | 332 | self.config_file_name) |
|
333 | 333 | try: |
|
334 | 334 | Application.load_config_file( |
|
335 | 335 | self, |
|
336 | 336 | config_file_name, |
|
337 | 337 | path=self.config_file_paths |
|
338 | 338 | ) |
|
339 | 339 | except ConfigFileNotFound: |
|
340 | 340 | # Only warn if the default config file was NOT being used. |
|
341 | 341 | if config_file_name in self.config_file_specified: |
|
342 | 342 | msg = self.log.warning |
|
343 | 343 | else: |
|
344 | 344 | msg = self.log.debug |
|
345 | 345 | msg("Config file not found, skipping: %s", config_file_name) |
|
346 | 346 | except Exception: |
|
347 | 347 | # For testing purposes. |
|
348 | 348 | if not suppress_errors: |
|
349 | 349 | raise |
|
350 | 350 | self.log.warning("Error loading config file: %s" % |
|
351 | 351 | self.config_file_name, exc_info=True) |
|
352 | 352 | |
|
353 | 353 | def init_profile_dir(self): |
|
354 | 354 | """initialize the profile dir""" |
|
355 | 355 | self._in_init_profile_dir = True |
|
356 | 356 | if self.profile_dir is not None: |
|
357 | 357 | # already ran |
|
358 | 358 | return |
|
359 | 359 | if 'ProfileDir.location' not in self.config: |
|
360 | 360 | # location not specified, find by profile name |
|
361 | 361 | try: |
|
362 | 362 | p = ProfileDir.find_profile_dir_by_name(self.ipython_dir, self.profile, self.config) |
|
363 | 363 | except ProfileDirError: |
|
364 | 364 | # not found, maybe create it (always create default profile) |
|
365 | 365 | if self.auto_create or self.profile == 'default': |
|
366 | 366 | try: |
|
367 | 367 | p = ProfileDir.create_profile_dir_by_name(self.ipython_dir, self.profile, self.config) |
|
368 | 368 | except ProfileDirError: |
|
369 | 369 | self.log.fatal("Could not create profile: %r"%self.profile) |
|
370 | 370 | self.exit(1) |
|
371 | 371 | else: |
|
372 | 372 | self.log.info("Created profile dir: %r"%p.location) |
|
373 | 373 | else: |
|
374 | 374 | self.log.fatal("Profile %r not found."%self.profile) |
|
375 | 375 | self.exit(1) |
|
376 | 376 | else: |
|
377 | 377 | self.log.debug(f"Using existing profile dir: {p.location!r}") |
|
378 | 378 | else: |
|
379 | 379 | location = self.config.ProfileDir.location |
|
380 | 380 | # location is fully specified |
|
381 | 381 | try: |
|
382 | 382 | p = ProfileDir.find_profile_dir(location, self.config) |
|
383 | 383 | except ProfileDirError: |
|
384 | 384 | # not found, maybe create it |
|
385 | 385 | if self.auto_create: |
|
386 | 386 | try: |
|
387 | 387 | p = ProfileDir.create_profile_dir(location, self.config) |
|
388 | 388 | except ProfileDirError: |
|
389 | 389 | self.log.fatal("Could not create profile directory: %r"%location) |
|
390 | 390 | self.exit(1) |
|
391 | 391 | else: |
|
392 | 392 | self.log.debug("Creating new profile dir: %r"%location) |
|
393 | 393 | else: |
|
394 | 394 | self.log.fatal("Profile directory %r not found."%location) |
|
395 | 395 | self.exit(1) |
|
396 | 396 | else: |
|
397 | 397 | self.log.debug(f"Using existing profile dir: {p.location!r}") |
|
398 | 398 | # if profile_dir is specified explicitly, set profile name |
|
399 | 399 | dir_name = os.path.basename(p.location) |
|
400 | 400 | if dir_name.startswith('profile_'): |
|
401 | 401 | self.profile = dir_name[8:] |
|
402 | 402 | |
|
403 | 403 | self.profile_dir = p |
|
404 | 404 | self.config_file_paths.append(p.location) |
|
405 | 405 | self._in_init_profile_dir = False |
|
406 | 406 | |
|
407 | 407 | def init_config_files(self): |
|
408 | 408 | """[optionally] copy default config files into profile dir.""" |
|
409 | 409 | self.config_file_paths.extend(ENV_CONFIG_DIRS) |
|
410 | 410 | self.config_file_paths.extend(SYSTEM_CONFIG_DIRS) |
|
411 | 411 | # copy config files |
|
412 | 412 | path = self.builtin_profile_dir |
|
413 | 413 | if self.copy_config_files: |
|
414 | 414 | src = self.profile |
|
415 | 415 | |
|
416 | 416 | cfg = self.config_file_name |
|
417 | 417 | if path and os.path.exists(os.path.join(path, cfg)): |
|
418 | 418 | self.log.warning("Staging %r from %s into %r [overwrite=%s]"%( |
|
419 | 419 | cfg, src, self.profile_dir.location, self.overwrite) |
|
420 | 420 | ) |
|
421 | 421 | self.profile_dir.copy_config_file(cfg, path=path, overwrite=self.overwrite) |
|
422 | 422 | else: |
|
423 | 423 | self.stage_default_config_file() |
|
424 | 424 | else: |
|
425 | 425 | # Still stage *bundled* config files, but not generated ones |
|
426 | 426 | # This is necessary for `ipython profile=sympy` to load the profile |
|
427 | 427 | # on the first go |
|
428 | 428 | files = glob.glob(os.path.join(path, '*.py')) |
|
429 | 429 | for fullpath in files: |
|
430 | 430 | cfg = os.path.basename(fullpath) |
|
431 | 431 | if self.profile_dir.copy_config_file(cfg, path=path, overwrite=False): |
|
432 | 432 | # file was copied |
|
433 | 433 | self.log.warning("Staging bundled %s from %s into %r"%( |
|
434 | 434 | cfg, self.profile, self.profile_dir.location) |
|
435 | 435 | ) |
|
436 | 436 | |
|
437 | 437 | |
|
438 | 438 | def stage_default_config_file(self): |
|
439 | 439 | """auto generate default config file, and stage it into the profile.""" |
|
440 | 440 | s = self.generate_config_file() |
|
441 | 441 | fname = os.path.join(self.profile_dir.location, self.config_file_name) |
|
442 | 442 | if self.overwrite or not os.path.exists(fname): |
|
443 | 443 | self.log.warning("Generating default config file: %r"%(fname)) |
|
444 | 444 | with open(fname, 'w') as f: |
|
445 | 445 | f.write(s) |
|
446 | 446 | |
|
447 | 447 | @catch_config_error |
|
448 | 448 | def initialize(self, argv=None): |
|
449 | 449 | # don't hook up crash handler before parsing command-line |
|
450 | 450 | self.parse_command_line(argv) |
|
451 | 451 | self.init_crash_handler() |
|
452 | 452 | if self.subapp is not None: |
|
453 | 453 | # stop here if subapp is taking over |
|
454 | 454 | return |
|
455 | 455 | # save a copy of CLI config to re-load after config files |
|
456 | 456 | # so that it has highest priority |
|
457 | 457 | cl_config = deepcopy(self.config) |
|
458 | 458 | self.init_profile_dir() |
|
459 | 459 | self.init_config_files() |
|
460 | 460 | self.load_config_file() |
|
461 | 461 | # enforce cl-opts override configfile opts: |
|
462 | 462 | self.update_config(cl_config) |
@@ -1,311 +1,312 b'' | |||
|
1 | 1 | # encoding: utf-8 |
|
2 | 2 | """ |
|
3 | 3 | An application for managing IPython profiles. |
|
4 | 4 | |
|
5 | 5 | To be invoked as the `ipython profile` subcommand. |
|
6 | 6 | |
|
7 | 7 | Authors: |
|
8 | 8 | |
|
9 | 9 | * Min RK |
|
10 | 10 | |
|
11 | 11 | """ |
|
12 | 12 | |
|
13 | 13 | #----------------------------------------------------------------------------- |
|
14 | 14 | # Copyright (C) 2008 The IPython Development Team |
|
15 | 15 | # |
|
16 | 16 | # Distributed under the terms of the BSD License. The full license is in |
|
17 | 17 | # the file COPYING, distributed as part of this software. |
|
18 | 18 | #----------------------------------------------------------------------------- |
|
19 | 19 | |
|
20 | 20 | #----------------------------------------------------------------------------- |
|
21 | 21 | # Imports |
|
22 | 22 | #----------------------------------------------------------------------------- |
|
23 | 23 | |
|
24 | 24 | import os |
|
25 | 25 | |
|
26 | 26 | from traitlets.config.application import Application |
|
27 | 27 | from IPython.core.application import ( |
|
28 | 28 | BaseIPythonApplication, base_flags |
|
29 | 29 | ) |
|
30 | 30 | from IPython.core.profiledir import ProfileDir |
|
31 | 31 | from IPython.utils.importstring import import_item |
|
32 | 32 | from IPython.paths import get_ipython_dir, get_ipython_package_dir |
|
33 | 33 | from traitlets import Unicode, Bool, Dict, observe |
|
34 | 34 | |
|
35 | 35 | #----------------------------------------------------------------------------- |
|
36 | 36 | # Constants |
|
37 | 37 | #----------------------------------------------------------------------------- |
|
38 | 38 | |
|
39 | 39 | create_help = """Create an IPython profile by name |
|
40 | 40 | |
|
41 | 41 | Create an ipython profile directory by its name or |
|
42 | 42 | profile directory path. Profile directories contain |
|
43 | 43 | configuration, log and security related files and are named |
|
44 | 44 | using the convention 'profile_<name>'. By default they are |
|
45 | 45 | located in your ipython directory. Once created, you will |
|
46 | 46 | can edit the configuration files in the profile |
|
47 | 47 | directory to configure IPython. Most users will create a |
|
48 | 48 | profile directory by name, |
|
49 | 49 | `ipython profile create myprofile`, which will put the directory |
|
50 | 50 | in `<ipython_dir>/profile_myprofile`. |
|
51 | 51 | """ |
|
52 | 52 | list_help = """List available IPython profiles |
|
53 | 53 | |
|
54 | 54 | List all available profiles, by profile location, that can |
|
55 | 55 | be found in the current working directly or in the ipython |
|
56 | 56 | directory. Profile directories are named using the convention |
|
57 | 57 | 'profile_<profile>'. |
|
58 | 58 | """ |
|
59 | 59 | profile_help = """Manage IPython profiles |
|
60 | 60 | |
|
61 | 61 | Profile directories contain |
|
62 | 62 | configuration, log and security related files and are named |
|
63 | 63 | using the convention 'profile_<name>'. By default they are |
|
64 | 64 | located in your ipython directory. You can create profiles |
|
65 | 65 | with `ipython profile create <name>`, or see the profiles you |
|
66 | 66 | already have with `ipython profile list` |
|
67 | 67 | |
|
68 | 68 | To get started configuring IPython, simply do: |
|
69 | 69 | |
|
70 | 70 | $> ipython profile create |
|
71 | 71 | |
|
72 | 72 | and IPython will create the default profile in <ipython_dir>/profile_default, |
|
73 | 73 | where you can edit ipython_config.py to start configuring IPython. |
|
74 | 74 | |
|
75 | 75 | """ |
|
76 | 76 | |
|
77 | 77 | _list_examples = "ipython profile list # list all profiles" |
|
78 | 78 | |
|
79 | 79 | _create_examples = """ |
|
80 | 80 | ipython profile create foo # create profile foo w/ default config files |
|
81 | 81 | ipython profile create foo --reset # restage default config files over current |
|
82 | 82 | ipython profile create foo --parallel # also stage parallel config files |
|
83 | 83 | """ |
|
84 | 84 | |
|
85 | 85 | _main_examples = """ |
|
86 | 86 | ipython profile create -h # show the help string for the create subcommand |
|
87 | 87 | ipython profile list -h # show the help string for the list subcommand |
|
88 | 88 | |
|
89 | 89 | ipython locate profile foo # print the path to the directory for profile 'foo' |
|
90 | 90 | """ |
|
91 | 91 | |
|
92 | 92 | #----------------------------------------------------------------------------- |
|
93 | 93 | # Profile Application Class (for `ipython profile` subcommand) |
|
94 | 94 | #----------------------------------------------------------------------------- |
|
95 | 95 | |
|
96 | 96 | |
|
97 | 97 | def list_profiles_in(path): |
|
98 | 98 | """list profiles in a given root directory""" |
|
99 | 99 | profiles = [] |
|
100 | 100 | |
|
101 | 101 | # for python 3.6+ rewrite to: with os.scandir(path) as dirlist: |
|
102 | 102 | files = os.scandir(path) |
|
103 | 103 | for f in files: |
|
104 | 104 | if f.is_dir() and f.name.startswith('profile_'): |
|
105 | 105 | profiles.append(f.name.split('_', 1)[-1]) |
|
106 | 106 | return profiles |
|
107 | 107 | |
|
108 | 108 | |
|
109 | 109 | def list_bundled_profiles(): |
|
110 | 110 | """list profiles that are bundled with IPython.""" |
|
111 | 111 | path = os.path.join(get_ipython_package_dir(), u'core', u'profile') |
|
112 | 112 | profiles = [] |
|
113 | 113 | |
|
114 | 114 | # for python 3.6+ rewrite to: with os.scandir(path) as dirlist: |
|
115 | 115 | files = os.scandir(path) |
|
116 | 116 | for profile in files: |
|
117 | 117 | if profile.is_dir() and profile.name != "__pycache__": |
|
118 | 118 | profiles.append(profile.name) |
|
119 | 119 | return profiles |
|
120 | 120 | |
|
121 | 121 | |
|
122 | 122 | class ProfileLocate(BaseIPythonApplication): |
|
123 | 123 | description = """print the path to an IPython profile dir""" |
|
124 | 124 | |
|
125 | 125 | def parse_command_line(self, argv=None): |
|
126 | 126 | super(ProfileLocate, self).parse_command_line(argv) |
|
127 | 127 | if self.extra_args: |
|
128 | 128 | self.profile = self.extra_args[0] |
|
129 | 129 | |
|
130 | 130 | def start(self): |
|
131 | 131 | print(self.profile_dir.location) |
|
132 | 132 | |
|
133 | 133 | |
|
134 | 134 | class ProfileList(Application): |
|
135 | 135 | name = u'ipython-profile' |
|
136 | 136 | description = list_help |
|
137 | 137 | examples = _list_examples |
|
138 | 138 | |
|
139 | 139 | aliases = Dict({ |
|
140 | 140 | 'ipython-dir' : 'ProfileList.ipython_dir', |
|
141 | 141 | 'log-level' : 'Application.log_level', |
|
142 | 142 | }) |
|
143 | 143 | flags = Dict(dict( |
|
144 | 144 | debug = ({'Application' : {'log_level' : 0}}, |
|
145 | 145 | "Set Application.log_level to 0, maximizing log output." |
|
146 | 146 | ) |
|
147 | 147 | )) |
|
148 | 148 | |
|
149 | 149 | ipython_dir = Unicode(get_ipython_dir(), |
|
150 | 150 | help=""" |
|
151 | 151 | The name of the IPython directory. This directory is used for logging |
|
152 | 152 | configuration (through profiles), history storage, etc. The default |
|
153 | 153 | is usually $HOME/.ipython. This options can also be specified through |
|
154 | 154 | the environment variable IPYTHONDIR. |
|
155 | 155 | """ |
|
156 | 156 | ).tag(config=True) |
|
157 | 157 | |
|
158 | 158 | |
|
159 | 159 | def _print_profiles(self, profiles): |
|
160 | 160 | """print list of profiles, indented.""" |
|
161 | 161 | for profile in profiles: |
|
162 | 162 | print(' %s' % profile) |
|
163 | 163 | |
|
164 | 164 | def list_profile_dirs(self): |
|
165 | 165 | profiles = list_bundled_profiles() |
|
166 | 166 | if profiles: |
|
167 | 167 | print() |
|
168 | 168 | print("Available profiles in IPython:") |
|
169 | 169 | self._print_profiles(profiles) |
|
170 | 170 | print() |
|
171 | 171 | print(" The first request for a bundled profile will copy it") |
|
172 | 172 | print(" into your IPython directory (%s)," % self.ipython_dir) |
|
173 | 173 | print(" where you can customize it.") |
|
174 | 174 | |
|
175 | 175 | profiles = list_profiles_in(self.ipython_dir) |
|
176 | 176 | if profiles: |
|
177 | 177 | print() |
|
178 | 178 | print("Available profiles in %s:" % self.ipython_dir) |
|
179 | 179 | self._print_profiles(profiles) |
|
180 | 180 | |
|
181 | 181 | profiles = list_profiles_in(os.getcwd()) |
|
182 | 182 | if profiles: |
|
183 | 183 | print() |
|
184 | print("Available profiles in current directory (%s):" % os.getcwd()) | |
|
185 | self._print_profiles(profiles) | |
|
186 | ||
|
184 | print( | |
|
185 | "Profiles from CWD have been removed for security reason, see CVE-2022-21699:" | |
|
186 | ) | |
|
187 | ||
|
187 | 188 | print() |
|
188 | 189 | print("To use any of the above profiles, start IPython with:") |
|
189 | 190 | print(" ipython --profile=<name>") |
|
190 | 191 | print() |
|
191 | 192 | |
|
192 | 193 | def start(self): |
|
193 | 194 | self.list_profile_dirs() |
|
194 | 195 | |
|
195 | 196 | |
|
196 | 197 | create_flags = {} |
|
197 | 198 | create_flags.update(base_flags) |
|
198 | 199 | # don't include '--init' flag, which implies running profile create in other apps |
|
199 | 200 | create_flags.pop('init') |
|
200 | 201 | create_flags['reset'] = ({'ProfileCreate': {'overwrite' : True}}, |
|
201 | 202 | "reset config files in this profile to the defaults.") |
|
202 | 203 | create_flags['parallel'] = ({'ProfileCreate': {'parallel' : True}}, |
|
203 | 204 | "Include the config files for parallel " |
|
204 | 205 | "computing apps (ipengine, ipcontroller, etc.)") |
|
205 | 206 | |
|
206 | 207 | |
|
207 | 208 | class ProfileCreate(BaseIPythonApplication): |
|
208 | 209 | name = u'ipython-profile' |
|
209 | 210 | description = create_help |
|
210 | 211 | examples = _create_examples |
|
211 | 212 | auto_create = Bool(True) |
|
212 | 213 | def _log_format_default(self): |
|
213 | 214 | return "[%(name)s] %(message)s" |
|
214 | 215 | |
|
215 | 216 | def _copy_config_files_default(self): |
|
216 | 217 | return True |
|
217 | 218 | |
|
218 | 219 | parallel = Bool(False, |
|
219 | 220 | help="whether to include parallel computing config files" |
|
220 | 221 | ).tag(config=True) |
|
221 | 222 | |
|
222 | 223 | @observe('parallel') |
|
223 | 224 | def _parallel_changed(self, change): |
|
224 | 225 | parallel_files = [ 'ipcontroller_config.py', |
|
225 | 226 | 'ipengine_config.py', |
|
226 | 227 | 'ipcluster_config.py' |
|
227 | 228 | ] |
|
228 | 229 | if change['new']: |
|
229 | 230 | for cf in parallel_files: |
|
230 | 231 | self.config_files.append(cf) |
|
231 | 232 | else: |
|
232 | 233 | for cf in parallel_files: |
|
233 | 234 | if cf in self.config_files: |
|
234 | 235 | self.config_files.remove(cf) |
|
235 | 236 | |
|
236 | 237 | def parse_command_line(self, argv): |
|
237 | 238 | super(ProfileCreate, self).parse_command_line(argv) |
|
238 | 239 | # accept positional arg as profile name |
|
239 | 240 | if self.extra_args: |
|
240 | 241 | self.profile = self.extra_args[0] |
|
241 | 242 | |
|
242 | 243 | flags = Dict(create_flags) |
|
243 | 244 | |
|
244 | 245 | classes = [ProfileDir] |
|
245 | 246 | |
|
246 | 247 | def _import_app(self, app_path): |
|
247 | 248 | """import an app class""" |
|
248 | 249 | app = None |
|
249 | 250 | name = app_path.rsplit('.', 1)[-1] |
|
250 | 251 | try: |
|
251 | 252 | app = import_item(app_path) |
|
252 | 253 | except ImportError: |
|
253 | 254 | self.log.info("Couldn't import %s, config file will be excluded", name) |
|
254 | 255 | except Exception: |
|
255 | 256 | self.log.warning('Unexpected error importing %s', name, exc_info=True) |
|
256 | 257 | return app |
|
257 | 258 | |
|
258 | 259 | def init_config_files(self): |
|
259 | 260 | super(ProfileCreate, self).init_config_files() |
|
260 | 261 | # use local imports, since these classes may import from here |
|
261 | 262 | from IPython.terminal.ipapp import TerminalIPythonApp |
|
262 | 263 | apps = [TerminalIPythonApp] |
|
263 | 264 | for app_path in ( |
|
264 | 265 | 'ipykernel.kernelapp.IPKernelApp', |
|
265 | 266 | ): |
|
266 | 267 | app = self._import_app(app_path) |
|
267 | 268 | if app is not None: |
|
268 | 269 | apps.append(app) |
|
269 | 270 | if self.parallel: |
|
270 | 271 | from ipyparallel.apps.ipcontrollerapp import IPControllerApp |
|
271 | 272 | from ipyparallel.apps.ipengineapp import IPEngineApp |
|
272 | 273 | from ipyparallel.apps.ipclusterapp import IPClusterStart |
|
273 | 274 | apps.extend([ |
|
274 | 275 | IPControllerApp, |
|
275 | 276 | IPEngineApp, |
|
276 | 277 | IPClusterStart, |
|
277 | 278 | ]) |
|
278 | 279 | for App in apps: |
|
279 | 280 | app = App() |
|
280 | 281 | app.config.update(self.config) |
|
281 | 282 | app.log = self.log |
|
282 | 283 | app.overwrite = self.overwrite |
|
283 | 284 | app.copy_config_files=True |
|
284 | 285 | app.ipython_dir=self.ipython_dir |
|
285 | 286 | app.profile_dir=self.profile_dir |
|
286 | 287 | app.init_config_files() |
|
287 | 288 | |
|
288 | 289 | def stage_default_config_file(self): |
|
289 | 290 | pass |
|
290 | 291 | |
|
291 | 292 | |
|
292 | 293 | class ProfileApp(Application): |
|
293 | 294 | name = u'ipython profile' |
|
294 | 295 | description = profile_help |
|
295 | 296 | examples = _main_examples |
|
296 | 297 | |
|
297 | 298 | subcommands = Dict(dict( |
|
298 | 299 | create = (ProfileCreate, ProfileCreate.description.splitlines()[0]), |
|
299 | 300 | list = (ProfileList, ProfileList.description.splitlines()[0]), |
|
300 | 301 | locate = (ProfileLocate, ProfileLocate.description.splitlines()[0]), |
|
301 | 302 | )) |
|
302 | 303 | |
|
303 | 304 | def start(self): |
|
304 | 305 | if self.subapp is None: |
|
305 | 306 | print("No subcommand specified. Must specify one of: %s"%(self.subcommands.keys())) |
|
306 | 307 | print() |
|
307 | 308 | self.print_description() |
|
308 | 309 | self.print_subcommands() |
|
309 | 310 | self.exit(1) |
|
310 | 311 | else: |
|
311 | 312 | return self.subapp.start() |
@@ -1,223 +1,223 b'' | |||
|
1 | 1 | # encoding: utf-8 |
|
2 | 2 | """An object for managing IPython profile directories.""" |
|
3 | 3 | |
|
4 | 4 | # Copyright (c) IPython Development Team. |
|
5 | 5 | # Distributed under the terms of the Modified BSD License. |
|
6 | 6 | |
|
7 | 7 | import os |
|
8 | 8 | import shutil |
|
9 | 9 | import errno |
|
10 | 10 | |
|
11 | 11 | from traitlets.config.configurable import LoggingConfigurable |
|
12 | 12 | from ..paths import get_ipython_package_dir |
|
13 | 13 | from ..utils.path import expand_path, ensure_dir_exists |
|
14 | 14 | from traitlets import Unicode, Bool, observe |
|
15 | 15 | |
|
16 | 16 | #----------------------------------------------------------------------------- |
|
17 | 17 | # Module errors |
|
18 | 18 | #----------------------------------------------------------------------------- |
|
19 | 19 | |
|
20 | 20 | class ProfileDirError(Exception): |
|
21 | 21 | pass |
|
22 | 22 | |
|
23 | 23 | |
|
24 | 24 | #----------------------------------------------------------------------------- |
|
25 | 25 | # Class for managing profile directories |
|
26 | 26 | #----------------------------------------------------------------------------- |
|
27 | 27 | |
|
28 | 28 | class ProfileDir(LoggingConfigurable): |
|
29 | 29 | """An object to manage the profile directory and its resources. |
|
30 | 30 | |
|
31 | 31 | The profile directory is used by all IPython applications, to manage |
|
32 | 32 | configuration, logging and security. |
|
33 | 33 | |
|
34 | 34 | This object knows how to find, create and manage these directories. This |
|
35 | 35 | should be used by any code that wants to handle profiles. |
|
36 | 36 | """ |
|
37 | 37 | |
|
38 | 38 | security_dir_name = Unicode('security') |
|
39 | 39 | log_dir_name = Unicode('log') |
|
40 | 40 | startup_dir_name = Unicode('startup') |
|
41 | 41 | pid_dir_name = Unicode('pid') |
|
42 | 42 | static_dir_name = Unicode('static') |
|
43 | 43 | security_dir = Unicode(u'') |
|
44 | 44 | log_dir = Unicode(u'') |
|
45 | 45 | startup_dir = Unicode(u'') |
|
46 | 46 | pid_dir = Unicode(u'') |
|
47 | 47 | static_dir = Unicode(u'') |
|
48 | 48 | |
|
49 | 49 | location = Unicode(u'', |
|
50 | 50 | help="""Set the profile location directly. This overrides the logic used by the |
|
51 | 51 | `profile` option.""", |
|
52 | 52 | ).tag(config=True) |
|
53 | 53 | |
|
54 | 54 | _location_isset = Bool(False) # flag for detecting multiply set location |
|
55 | 55 | @observe('location') |
|
56 | 56 | def _location_changed(self, change): |
|
57 | 57 | if self._location_isset: |
|
58 | 58 | raise RuntimeError("Cannot set profile location more than once.") |
|
59 | 59 | self._location_isset = True |
|
60 | 60 | new = change['new'] |
|
61 | 61 | ensure_dir_exists(new) |
|
62 | 62 | |
|
63 | 63 | # ensure config files exist: |
|
64 | 64 | self.security_dir = os.path.join(new, self.security_dir_name) |
|
65 | 65 | self.log_dir = os.path.join(new, self.log_dir_name) |
|
66 | 66 | self.startup_dir = os.path.join(new, self.startup_dir_name) |
|
67 | 67 | self.pid_dir = os.path.join(new, self.pid_dir_name) |
|
68 | 68 | self.static_dir = os.path.join(new, self.static_dir_name) |
|
69 | 69 | self.check_dirs() |
|
70 | 70 | |
|
71 | 71 | def _mkdir(self, path, mode=None): |
|
72 | 72 | """ensure a directory exists at a given path |
|
73 | 73 | |
|
74 | 74 | This is a version of os.mkdir, with the following differences: |
|
75 | 75 | |
|
76 | 76 | - returns True if it created the directory, False otherwise |
|
77 | 77 | - ignores EEXIST, protecting against race conditions where |
|
78 | 78 | the dir may have been created in between the check and |
|
79 | 79 | the creation |
|
80 | 80 | - sets permissions if requested and the dir already exists |
|
81 | 81 | """ |
|
82 | 82 | if os.path.exists(path): |
|
83 | 83 | if mode and os.stat(path).st_mode != mode: |
|
84 | 84 | try: |
|
85 | 85 | os.chmod(path, mode) |
|
86 | 86 | except OSError: |
|
87 | 87 | self.log.warning( |
|
88 | 88 | "Could not set permissions on %s", |
|
89 | 89 | path |
|
90 | 90 | ) |
|
91 | 91 | return False |
|
92 | 92 | try: |
|
93 | 93 | if mode: |
|
94 | 94 | os.mkdir(path, mode) |
|
95 | 95 | else: |
|
96 | 96 | os.mkdir(path) |
|
97 | 97 | except OSError as e: |
|
98 | 98 | if e.errno == errno.EEXIST: |
|
99 | 99 | return False |
|
100 | 100 | else: |
|
101 | 101 | raise |
|
102 | 102 | |
|
103 | 103 | return True |
|
104 | 104 | |
|
105 | 105 | @observe('log_dir') |
|
106 | 106 | def check_log_dir(self, change=None): |
|
107 | 107 | self._mkdir(self.log_dir) |
|
108 | 108 | |
|
109 | 109 | @observe('startup_dir') |
|
110 | 110 | def check_startup_dir(self, change=None): |
|
111 | 111 | self._mkdir(self.startup_dir) |
|
112 | 112 | |
|
113 | 113 | readme = os.path.join(self.startup_dir, 'README') |
|
114 | 114 | src = os.path.join(get_ipython_package_dir(), u'core', u'profile', u'README_STARTUP') |
|
115 | 115 | |
|
116 | 116 | if not os.path.exists(src): |
|
117 | 117 | self.log.warning("Could not copy README_STARTUP to startup dir. Source file %s does not exist.", src) |
|
118 | 118 | |
|
119 | 119 | if os.path.exists(src) and not os.path.exists(readme): |
|
120 | 120 | shutil.copy(src, readme) |
|
121 | 121 | |
|
122 | 122 | @observe('security_dir') |
|
123 | 123 | def check_security_dir(self, change=None): |
|
124 | 124 | self._mkdir(self.security_dir, 0o40700) |
|
125 | 125 | |
|
126 | 126 | @observe('pid_dir') |
|
127 | 127 | def check_pid_dir(self, change=None): |
|
128 | 128 | self._mkdir(self.pid_dir, 0o40700) |
|
129 | 129 | |
|
130 | 130 | def check_dirs(self): |
|
131 | 131 | self.check_security_dir() |
|
132 | 132 | self.check_log_dir() |
|
133 | 133 | self.check_pid_dir() |
|
134 | 134 | self.check_startup_dir() |
|
135 | 135 | |
|
136 | 136 | def copy_config_file(self, config_file, path=None, overwrite=False): |
|
137 | 137 | """Copy a default config file into the active profile directory. |
|
138 | 138 | |
|
139 | 139 | Default configuration files are kept in :mod:`IPython.core.profile`. |
|
140 | 140 | This function moves these from that location to the working profile |
|
141 | 141 | directory. |
|
142 | 142 | """ |
|
143 | 143 | dst = os.path.join(self.location, config_file) |
|
144 | 144 | if os.path.isfile(dst) and not overwrite: |
|
145 | 145 | return False |
|
146 | 146 | if path is None: |
|
147 | 147 | path = os.path.join(get_ipython_package_dir(), u'core', u'profile', u'default') |
|
148 | 148 | src = os.path.join(path, config_file) |
|
149 | 149 | shutil.copy(src, dst) |
|
150 | 150 | return True |
|
151 | 151 | |
|
152 | 152 | @classmethod |
|
153 | 153 | def create_profile_dir(cls, profile_dir, config=None): |
|
154 | 154 | """Create a new profile directory given a full path. |
|
155 | 155 | |
|
156 | 156 | Parameters |
|
157 | 157 | ---------- |
|
158 | 158 | profile_dir : str |
|
159 | 159 | The full path to the profile directory. If it does exist, it will |
|
160 | 160 | be used. If not, it will be created. |
|
161 | 161 | """ |
|
162 | 162 | return cls(location=profile_dir, config=config) |
|
163 | 163 | |
|
164 | 164 | @classmethod |
|
165 | 165 | def create_profile_dir_by_name(cls, path, name=u'default', config=None): |
|
166 | 166 | """Create a profile dir by profile name and path. |
|
167 | 167 | |
|
168 | 168 | Parameters |
|
169 | 169 | ---------- |
|
170 | 170 | path : unicode |
|
171 | 171 | The path (directory) to put the profile directory in. |
|
172 | 172 | name : unicode |
|
173 | 173 | The name of the profile. The name of the profile directory will |
|
174 | 174 | be "profile_<profile>". |
|
175 | 175 | """ |
|
176 | 176 | if not os.path.isdir(path): |
|
177 | 177 | raise ProfileDirError('Directory not found: %s' % path) |
|
178 | 178 | profile_dir = os.path.join(path, u'profile_' + name) |
|
179 | 179 | return cls(location=profile_dir, config=config) |
|
180 | 180 | |
|
181 | 181 | @classmethod |
|
182 | 182 | def find_profile_dir_by_name(cls, ipython_dir, name=u'default', config=None): |
|
183 | 183 | """Find an existing profile dir by profile name, return its ProfileDir. |
|
184 | 184 | |
|
185 | 185 | This searches through a sequence of paths for a profile dir. If it |
|
186 | 186 | is not found, a :class:`ProfileDirError` exception will be raised. |
|
187 | 187 | |
|
188 | 188 | The search path algorithm is: |
|
189 | 1. ``os.getcwd()`` | |
|
189 | 1. ``os.getcwd()`` # removed for security reason. | |
|
190 | 190 | 2. ``ipython_dir`` |
|
191 | 191 | |
|
192 | 192 | Parameters |
|
193 | 193 | ---------- |
|
194 | 194 | ipython_dir : unicode or str |
|
195 | 195 | The IPython directory to use. |
|
196 | 196 | name : unicode or str |
|
197 | 197 | The name of the profile. The name of the profile directory |
|
198 | 198 | will be "profile_<profile>". |
|
199 | 199 | """ |
|
200 | 200 | dirname = u'profile_' + name |
|
201 |
paths = [ |
|
|
201 | paths = [ipython_dir] | |
|
202 | 202 | for p in paths: |
|
203 | 203 | profile_dir = os.path.join(p, dirname) |
|
204 | 204 | if os.path.isdir(profile_dir): |
|
205 | 205 | return cls(location=profile_dir, config=config) |
|
206 | 206 | else: |
|
207 | 207 | raise ProfileDirError('Profile directory not found in paths: %s' % dirname) |
|
208 | 208 | |
|
209 | 209 | @classmethod |
|
210 | 210 | def find_profile_dir(cls, profile_dir, config=None): |
|
211 | 211 | """Find/create a profile dir and return its ProfileDir. |
|
212 | 212 | |
|
213 | 213 | This will create the profile directory if it doesn't exist. |
|
214 | 214 | |
|
215 | 215 | Parameters |
|
216 | 216 | ---------- |
|
217 | 217 | profile_dir : unicode or str |
|
218 | 218 | The path of the profile directory. |
|
219 | 219 | """ |
|
220 | 220 | profile_dir = expand_path(profile_dir) |
|
221 | 221 | if not os.path.isdir(profile_dir): |
|
222 | 222 | raise ProfileDirError('Profile directory not found: %s' % profile_dir) |
|
223 | 223 | return cls(location=profile_dir, config=config) |
@@ -1,1740 +1,1747 b'' | |||
|
1 | 1 | ============ |
|
2 | 2 | 7.x Series |
|
3 | 3 | ============ |
|
4 | 4 | |
|
5 | .. _version 7.31.1: | |
|
6 | ||
|
7 | IPython 7.31.1 (CVE-2022-21699) | |
|
8 | =============================== | |
|
9 | ||
|
10 | Fixed CVE-2022-21699, see IPython 8.0.1 release notes for informations. | |
|
11 | ||
|
5 | 12 | |
|
6 | 13 | .. _version 7.31: |
|
7 | 14 | |
|
8 | 15 | IPython 7.31 |
|
9 | 16 | ============ |
|
10 | 17 | |
|
11 | 18 | IPython 7.31 brings a couple of backports and fixes from the 8.0 branches, |
|
12 | 19 | it is likely one of the last releases of the 7.x series, as 8.0 will probably be released |
|
13 | 20 | between this release and what would have been 7.32. |
|
14 | 21 | |
|
15 | 22 | Please test 8.0 beta/rc releases in addition to this release. |
|
16 | 23 | |
|
17 | 24 | This Releases: |
|
18 | 25 | - Backport some fixes for Python 3.10 (:ghpull:`13412`) |
|
19 | 26 | - use full-alpha transparency on dvipng rendered LaTeX (:ghpull:`13372`) |
|
20 | 27 | |
|
21 | 28 | Many thanks to all the contributors to this release. You can find all individual |
|
22 | 29 | contributions to this milestone `on github |
|
23 | 30 | <https://github.com/ipython/ipython/milestone/95>`__. |
|
24 | 31 | |
|
25 | 32 | Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring |
|
26 | 33 | work on IPython and related libraries. |
|
27 | 34 | |
|
28 | 35 | |
|
29 | 36 | .. _version 7.30: |
|
30 | 37 | |
|
31 | 38 | IPython 7.30 |
|
32 | 39 | ============ |
|
33 | 40 | |
|
34 | 41 | IPython 7.30 fixes a couple of bugs introduce in previous releases (in |
|
35 | 42 | particular with respect to path handling), and introduce a few features and |
|
36 | 43 | improvements: |
|
37 | 44 | |
|
38 | 45 | Notably we will highlight :ghpull:`13267` "Document that ``%run`` can execute |
|
39 | 46 | notebooks and ipy scripts.", which is the first commit of Fernando PΓ©rez since |
|
40 | 47 | mid 2016 (IPython 5.1). If you are new to IPython, Fernando created IPython in |
|
41 | 48 | 2001. The other most recent contribution of Fernando to IPython itself was |
|
42 | 49 | May 2018, by reviewing and merging PRs. I want to note that Fernando is still |
|
43 | 50 | active but mostly as a mentor and leader of the whole Jupyter organisation, but |
|
44 | 51 | we're still happy to see him contribute code ! |
|
45 | 52 | |
|
46 | 53 | :ghpull:`13290` "Use sphinxify (if available) in object_inspect_mime path" |
|
47 | 54 | should allow richer Repr of docstrings when using jupyterlab inspector. |
|
48 | 55 | |
|
49 | 56 | :ghpull:`13311` make the debugger use ``ThreadPoolExecutor`` for debugger cmdloop. |
|
50 | 57 | This should fix some issues/infinite loop, but let us know if you come across |
|
51 | 58 | any regressions. In particular this fixes issues with `kmaork/madbg <https://github.com/kmaork/madbg>`_, |
|
52 | 59 | a remote debugger for IPython. |
|
53 | 60 | |
|
54 | 61 | Note that this is likely the ante-penultimate release of IPython 7.x as a stable |
|
55 | 62 | branch, as I hope to release IPython 8.0 as well as IPython 7.31 next |
|
56 | 63 | month/early 2022. |
|
57 | 64 | |
|
58 | 65 | IPython 8.0 will drop support for Python 3.7, removed nose as a dependency, and |
|
59 | 66 | 7.x will only get critical bug fixes with 8.x becoming the new stable. This will |
|
60 | 67 | not be possible without `NumFOCUS Small Development Grants |
|
61 | 68 | <https://numfocus.org/programs/small-development-grants>`_ Which allowed us to |
|
62 | 69 | hire `Nikita Kniazev <https://github.com/Kojoley>`_ who provide Python and C++ |
|
63 | 70 | help and contracting work. |
|
64 | 71 | |
|
65 | 72 | |
|
66 | 73 | Many thanks to all the contributors to this release. You can find all individual |
|
67 | 74 | contributions to this milestone `on github |
|
68 | 75 | <https://github.com/ipython/ipython/milestone/94?closed=1>`__. |
|
69 | 76 | |
|
70 | 77 | Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring |
|
71 | 78 | work on IPython and related libraries. |
|
72 | 79 | |
|
73 | 80 | |
|
74 | 81 | .. _version 7.29: |
|
75 | 82 | |
|
76 | 83 | IPython 7.29 |
|
77 | 84 | ============ |
|
78 | 85 | |
|
79 | 86 | |
|
80 | 87 | IPython 7.29 brings a couple of new functionalities to IPython and a number of bugfixes. |
|
81 | 88 | It is one of the largest recent release, relatively speaking, with close to 15 Pull Requests. |
|
82 | 89 | |
|
83 | 90 | |
|
84 | 91 | - fix an issue where base64 was returned instead of bytes when showing figures :ghpull:`13162` |
|
85 | 92 | - fix compatibility with PyQt6, PySide 6 :ghpull:`13172`. This may be of |
|
86 | 93 | interest if you are running on Apple Silicon as only qt6.2+ is natively |
|
87 | 94 | compatible. |
|
88 | 95 | - fix matplotlib qtagg eventloop :ghpull:`13179` |
|
89 | 96 | - Multiple docs fixes, typos, ... etc. |
|
90 | 97 | - Debugger will now exit by default on SigInt :ghpull:`13218`, this will be |
|
91 | 98 | useful in notebook/lab if you forgot to exit the debugger. "Interrupt Kernel" |
|
92 | 99 | will now exist the debugger. |
|
93 | 100 | |
|
94 | 101 | It give Pdb the ability to skip code in decorators. If functions contain a |
|
95 | 102 | special value names ``__debuggerskip__ = True|False``, the function will not be |
|
96 | 103 | stepped into, and Pdb will step into lower frames only if the value is set to |
|
97 | 104 | ``False``. The exact behavior is still likely to have corner cases and will be |
|
98 | 105 | refined in subsequent releases. Feedback welcome. See the debugger module |
|
99 | 106 | documentation for more info. Thanks to the `D. E. Shaw |
|
100 | 107 | group <https://deshaw.com/>`__ for funding this feature. |
|
101 | 108 | |
|
102 | 109 | The main branch of IPython is receiving a number of changes as we received a |
|
103 | 110 | `NumFOCUS SDG <https://numfocus.org/programs/small-development-grants>`__ |
|
104 | 111 | ($4800), to help us finish replacing ``nose`` by ``pytest``, and make IPython |
|
105 | 112 | future proof with an 8.0 release. |
|
106 | 113 | |
|
107 | 114 | |
|
108 | 115 | Many thanks to all the contributors to this release. You can find all individual |
|
109 | 116 | contributions to this milestone `on github |
|
110 | 117 | <https://github.com/ipython/ipython/milestone/93>`__. |
|
111 | 118 | |
|
112 | 119 | Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring |
|
113 | 120 | work on IPython and related libraries. |
|
114 | 121 | |
|
115 | 122 | |
|
116 | 123 | .. _version 7.28: |
|
117 | 124 | |
|
118 | 125 | IPython 7.28 |
|
119 | 126 | ============ |
|
120 | 127 | |
|
121 | 128 | |
|
122 | 129 | IPython 7.28 is again a minor release that mostly bring bugfixes, and couple of |
|
123 | 130 | improvement. Many thanks to MrMino, who again did all the work this month, and |
|
124 | 131 | made a number of documentation improvements. |
|
125 | 132 | |
|
126 | 133 | Here is a non-exhaustive list of changes, |
|
127 | 134 | |
|
128 | 135 | Fixes: |
|
129 | 136 | |
|
130 | 137 | - async with doesn't allow newlines :ghpull:`13090` |
|
131 | 138 | - Dynamically changing to vi mode via %config magic) :ghpull:`13091` |
|
132 | 139 | |
|
133 | 140 | Virtualenv handling fixes: |
|
134 | 141 | |
|
135 | 142 | - init_virtualenv now uses Pathlib :ghpull:`12548` |
|
136 | 143 | - Fix Improper path comparison of virtualenv directories :ghpull:`13140` |
|
137 | 144 | - Fix virtual environment user warning for lower case pathes :ghpull:`13094` |
|
138 | 145 | - Adapt to all sorts of drive names for cygwin :ghpull:`13153` |
|
139 | 146 | |
|
140 | 147 | New Features: |
|
141 | 148 | |
|
142 | 149 | - enable autoplay in embed YouTube player :ghpull:`13133` |
|
143 | 150 | |
|
144 | 151 | Documentation: |
|
145 | 152 | |
|
146 | 153 | - Fix formatting for the core.interactiveshell documentation :ghpull:`13118` |
|
147 | 154 | - Fix broken ipyparallel's refs :ghpull:`13138` |
|
148 | 155 | - Improve formatting of %time documentation :ghpull:`13125` |
|
149 | 156 | - Reword the YouTubeVideo autoplay WN :ghpull:`13147` |
|
150 | 157 | |
|
151 | 158 | |
|
152 | 159 | Highlighted features |
|
153 | 160 | -------------------- |
|
154 | 161 | |
|
155 | 162 | |
|
156 | 163 | ``YouTubeVideo`` autoplay and the ability to add extra attributes to ``IFrame`` |
|
157 | 164 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
158 | 165 | |
|
159 | 166 | You can add any extra attributes to the ``<iframe>`` tag using the new |
|
160 | 167 | ``extras`` argument in the ``IFrame`` class. For example:: |
|
161 | 168 | |
|
162 | 169 | In [1]: from IPython.display import IFrame |
|
163 | 170 | |
|
164 | 171 | In [2]: IFrame(src="src", width=300, height=300, extras=['loading="eager"']) |
|
165 | 172 | |
|
166 | 173 | The above cells will result in the following HTML code being displayed in a |
|
167 | 174 | notebook:: |
|
168 | 175 | |
|
169 | 176 | <iframe |
|
170 | 177 | width="300" |
|
171 | 178 | height="300" |
|
172 | 179 | src="src" |
|
173 | 180 | frameborder="0" |
|
174 | 181 | allowfullscreen |
|
175 | 182 | loading="eager" |
|
176 | 183 | ></iframe> |
|
177 | 184 | |
|
178 | 185 | Related to the above, the ``YouTubeVideo`` class now takes an |
|
179 | 186 | ``allow_autoplay`` flag, which sets up the iframe of the embedded YouTube video |
|
180 | 187 | such that it allows autoplay. |
|
181 | 188 | |
|
182 | 189 | .. note:: |
|
183 | 190 | Whether this works depends on the autoplay policy of the browser rendering |
|
184 | 191 | the HTML allowing it. It also could get blocked by some browser extensions. |
|
185 | 192 | |
|
186 | 193 | Try it out! |
|
187 | 194 | :: |
|
188 | 195 | |
|
189 | 196 | In [1]: from IPython.display import YouTubeVideo |
|
190 | 197 | |
|
191 | 198 | In [2]: YouTubeVideo("dQw4w9WgXcQ", allow_autoplay=True) |
|
192 | 199 | |
|
193 | 200 | |
|
194 | 201 | |
|
195 | 202 | Thanks |
|
196 | 203 | ------ |
|
197 | 204 | |
|
198 | 205 | Many thanks to all the contributors to this release. You can find all individual |
|
199 | 206 | contributions to this milestone `on github |
|
200 | 207 | <https://github.com/ipython/ipython/milestone/92>`__. |
|
201 | 208 | |
|
202 | 209 | Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring |
|
203 | 210 | work on IPython and related libraries. |
|
204 | 211 | |
|
205 | 212 | |
|
206 | 213 | .. _version 7.27: |
|
207 | 214 | |
|
208 | 215 | IPython 7.27 |
|
209 | 216 | ============ |
|
210 | 217 | |
|
211 | 218 | IPython 7.27 is a minor release that fixes a couple of issues and compatibility. |
|
212 | 219 | |
|
213 | 220 | - Add support for GTK4 :ghpull:`131011` |
|
214 | 221 | - Add support for Qt6 :ghpull:`13085` |
|
215 | 222 | - Fix an issue with pip magic on windows :ghpull:`13093` |
|
216 | 223 | |
|
217 | 224 | Thanks |
|
218 | 225 | ------ |
|
219 | 226 | |
|
220 | 227 | Many thanks to all the contributors to this release. You can find all individual |
|
221 | 228 | contributions to this milestone `on github |
|
222 | 229 | <https://github.com/ipython/ipython/milestone/91>`__. |
|
223 | 230 | |
|
224 | 231 | Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring |
|
225 | 232 | work on IPython and related libraries. |
|
226 | 233 | |
|
227 | 234 | .. _version 7.26: |
|
228 | 235 | |
|
229 | 236 | IPython 7.26 |
|
230 | 237 | ============ |
|
231 | 238 | |
|
232 | 239 | IPython 7.26 is a minor release that fixes a couple of issues, updates in API |
|
233 | 240 | and Copyright/Licenses issues around various part of the codebase. |
|
234 | 241 | |
|
235 | 242 | We'll highlight `this issue <https://github.com/ipython/ipython/issues/13039>` |
|
236 | 243 | pointing out we were including and refereeing to code from Stack Overflow which |
|
237 | 244 | was CC-BY-SA, hence incompatible with the BSD license of IPython. This lead us |
|
238 | 245 | to a rewriting of the corresponding logic which in our case was done in a more |
|
239 | 246 | efficient way (in our case we were searching string prefixes instead of full |
|
240 | 247 | strings). |
|
241 | 248 | |
|
242 | 249 | You will notice also a number of documentation improvements and cleanup. |
|
243 | 250 | |
|
244 | 251 | Of particular interest are the following Pull-requests: |
|
245 | 252 | |
|
246 | 253 | |
|
247 | 254 | - The IPython directive now uses Sphinx logging for warnings. :ghpull:`13030`. |
|
248 | 255 | - Add expiry days option to pastebin magic and change http protocol to https. |
|
249 | 256 | :ghpull:`13056` |
|
250 | 257 | - Make Ipython.utils.timing work with jupyterlite :ghpull:`13050`. |
|
251 | 258 | |
|
252 | 259 | Pastebin magic expiry days option |
|
253 | 260 | --------------------------------- |
|
254 | 261 | |
|
255 | 262 | The Pastebin magic now has ``-e`` option to determine |
|
256 | 263 | the number of days for paste expiration. For example |
|
257 | 264 | the paste that created with ``%pastebin -e 20 1`` magic will |
|
258 | 265 | be available for next 20 days. |
|
259 | 266 | |
|
260 | 267 | |
|
261 | 268 | |
|
262 | 269 | |
|
263 | 270 | |
|
264 | 271 | Thanks |
|
265 | 272 | ------ |
|
266 | 273 | |
|
267 | 274 | Many thanks to all the contributors to this release and in particular MrMino who |
|
268 | 275 | is doing most of the work those days. You can find all individual contributions |
|
269 | 276 | to this milestone `on github <https://github.com/ipython/ipython/milestone/90>`__. |
|
270 | 277 | |
|
271 | 278 | Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring |
|
272 | 279 | work on IPython and related libraries. |
|
273 | 280 | |
|
274 | 281 | |
|
275 | 282 | .. _version 7.25: |
|
276 | 283 | |
|
277 | 284 | IPython 7.25 |
|
278 | 285 | ============ |
|
279 | 286 | |
|
280 | 287 | IPython 7.25 is a minor release that contains a single bugfix, which is highly |
|
281 | 288 | recommended for all users of ipdb, ipython debugger %debug magic and similar. |
|
282 | 289 | |
|
283 | 290 | Issuing commands like ``where`` from within the debugger would reset the |
|
284 | 291 | local variables changes made by the user. It is interesting to look at the root |
|
285 | 292 | cause of the issue as accessing an attribute (``frame.f_locals``) would trigger |
|
286 | 293 | this side effects. |
|
287 | 294 | |
|
288 | 295 | Thanks in particular to the patience from the reporters at D.E. Shaw for their |
|
289 | 296 | initial bug report that was due to a similar coding oversight in an extension, |
|
290 | 297 | and who took time to debug and narrow down the problem. |
|
291 | 298 | |
|
292 | 299 | Thanks |
|
293 | 300 | ------ |
|
294 | 301 | |
|
295 | 302 | Many thanks to all the contributors to this release you can find all individual |
|
296 | 303 | contributions to this milestone `on github <https://github.com/ipython/ipython/milestone/89>`__. |
|
297 | 304 | |
|
298 | 305 | Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring |
|
299 | 306 | work on IPython and related libraries. |
|
300 | 307 | |
|
301 | 308 | |
|
302 | 309 | .. _version 7.24: |
|
303 | 310 | |
|
304 | 311 | IPython 7.24 |
|
305 | 312 | ============ |
|
306 | 313 | |
|
307 | 314 | Third release of IPython for 2021, mostly containing bug fixes. A couple of not |
|
308 | 315 | typical updates: |
|
309 | 316 | |
|
310 | 317 | Misc |
|
311 | 318 | ---- |
|
312 | 319 | |
|
313 | 320 | |
|
314 | 321 | - Fix an issue where ``%recall`` would both succeeded and print an error message |
|
315 | 322 | it failed. :ghpull:`12952` |
|
316 | 323 | - Drop support for NumPy 1.16 β practically has no effect beyond indicating in |
|
317 | 324 | package metadata that we do not support it. :ghpull:`12937` |
|
318 | 325 | |
|
319 | 326 | Debugger improvements |
|
320 | 327 | --------------------- |
|
321 | 328 | |
|
322 | 329 | The debugger (and ``%debug`` magic) have been improved and can skip or hide frames |
|
323 | 330 | originating from files that are not writable to the user, as these are less |
|
324 | 331 | likely to be the source of errors, or be part of system files this can be a useful |
|
325 | 332 | addition when debugging long errors. |
|
326 | 333 | |
|
327 | 334 | In addition to the global ``skip_hidden True|False`` command, the debugger has |
|
328 | 335 | gained finer grained control of predicates as to whether to a frame should be |
|
329 | 336 | considered hidden. So far 3 predicates are available : |
|
330 | 337 | |
|
331 | 338 | - ``tbhide``: frames containing the local variable ``__tracebackhide__`` set to |
|
332 | 339 | True. |
|
333 | 340 | - ``readonly``: frames originating from readonly files, set to False. |
|
334 | 341 | - ``ipython_internal``: frames that are likely to be from IPython internal |
|
335 | 342 | code, set to True. |
|
336 | 343 | |
|
337 | 344 | You can toggle individual predicates during a session with |
|
338 | 345 | |
|
339 | 346 | .. code-block:: |
|
340 | 347 | |
|
341 | 348 | ipdb> skip_predicates readonly True |
|
342 | 349 | |
|
343 | 350 | Read-only files will now be considered hidden frames. |
|
344 | 351 | |
|
345 | 352 | |
|
346 | 353 | You can call ``skip_predicates`` without arguments to see the states of current |
|
347 | 354 | predicates: |
|
348 | 355 | |
|
349 | 356 | .. code-block:: |
|
350 | 357 | |
|
351 | 358 | ipdb> skip_predicates |
|
352 | 359 | current predicates: |
|
353 | 360 | tbhide : True |
|
354 | 361 | readonly : False |
|
355 | 362 | ipython_internal : True |
|
356 | 363 | |
|
357 | 364 | If all predicates are set to ``False``, ``skip_hidden`` will practically have |
|
358 | 365 | no effect. We attempt to warn you when all predicates are False. |
|
359 | 366 | |
|
360 | 367 | Note that the ``readonly`` predicate may increase disk access as we check for |
|
361 | 368 | file access permission for all frames on many command invocation, but is usually |
|
362 | 369 | cached by operating systems. Let us know if you encounter any issues. |
|
363 | 370 | |
|
364 | 371 | As the IPython debugger does not use the traitlets infrastructure for |
|
365 | 372 | configuration, by editing your ``.pdbrc`` files and appending commands you would |
|
366 | 373 | like to be executed just before entering the interactive prompt. For example: |
|
367 | 374 | |
|
368 | 375 | |
|
369 | 376 | .. code:: |
|
370 | 377 | |
|
371 | 378 | # file : ~/.pdbrc |
|
372 | 379 | skip_predicates readonly True |
|
373 | 380 | skip_predicates tbhide False |
|
374 | 381 | |
|
375 | 382 | Will hide read only frames by default and show frames marked with |
|
376 | 383 | ``__tracebackhide__``. |
|
377 | 384 | |
|
378 | 385 | |
|
379 | 386 | |
|
380 | 387 | |
|
381 | 388 | Thanks |
|
382 | 389 | ------ |
|
383 | 390 | |
|
384 | 391 | Many thanks to all the contributors to this release you can find all individual |
|
385 | 392 | contributions to this milestone `on github <https://github.com/ipython/ipython/milestone/87>`__. |
|
386 | 393 | |
|
387 | 394 | Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring |
|
388 | 395 | work on IPython and related libraries, in particular above mentioned |
|
389 | 396 | improvements to the debugger. |
|
390 | 397 | |
|
391 | 398 | |
|
392 | 399 | |
|
393 | 400 | |
|
394 | 401 | .. _version 7.23: |
|
395 | 402 | |
|
396 | 403 | IPython 7.23 and 7.23.1 |
|
397 | 404 | ======================= |
|
398 | 405 | |
|
399 | 406 | |
|
400 | 407 | Third release of IPython for 2021, mostly containing bug fixes. A couple of not |
|
401 | 408 | typical updates: |
|
402 | 409 | |
|
403 | 410 | - We moved to GitHub actions away from Travis-CI, the transition may not be |
|
404 | 411 | 100% complete (not testing on nightly anymore), but as we ran out of |
|
405 | 412 | Travis-Ci hours on the IPython organisation that was a necessary step. |
|
406 | 413 | :ghpull:`12900`. |
|
407 | 414 | |
|
408 | 415 | - We have a new dependency: ``matplotlib-inline``, which try to extract |
|
409 | 416 | matplotlib inline backend specific behavior. It is available on PyPI and |
|
410 | 417 | conda-forge thus should not be a problem to upgrade to this version. If you |
|
411 | 418 | are a package maintainer that might be an extra dependency to package first. |
|
412 | 419 | :ghpull:`12817` (IPython 7.23.1 fix a typo that made this change fail) |
|
413 | 420 | |
|
414 | 421 | In the addition/new feature category, ``display()`` now have a ``clear=True`` |
|
415 | 422 | option to clear the display if any further outputs arrives, allowing users to |
|
416 | 423 | avoid having to use ``clear_output()`` directly. :ghpull:`12823`. |
|
417 | 424 | |
|
418 | 425 | In bug fixes category, this release fix an issue when printing tracebacks |
|
419 | 426 | containing Unicode characters :ghpull:`12758`. |
|
420 | 427 | |
|
421 | 428 | In code cleanup category :ghpull:`12932` remove usage of some deprecated |
|
422 | 429 | functionality for compatibility with Python 3.10. |
|
423 | 430 | |
|
424 | 431 | |
|
425 | 432 | |
|
426 | 433 | Thanks |
|
427 | 434 | ------ |
|
428 | 435 | |
|
429 | 436 | Many thanks to all the contributors to this release you can find all individual |
|
430 | 437 | contributions to this milestone `on github <https://github.com/ipython/ipython/milestone/86>`__. |
|
431 | 438 | In particular MrMino for responding to almost all new issues, and triaging many |
|
432 | 439 | of the old ones, as well as takluyver, minrk, willingc for reacting quikly when |
|
433 | 440 | we ran out of CI Hours. |
|
434 | 441 | |
|
435 | 442 | Thanks as well to organisations, QuantStack (martinRenou and SylvainCorlay) for |
|
436 | 443 | extracting matplotlib inline backend into its own package, and the `D. E. Shaw group |
|
437 | 444 | <https://deshaw.com/>`__ for sponsoring work on IPython and related libraries. |
|
438 | 445 | |
|
439 | 446 | |
|
440 | 447 | .. _version 7.22: |
|
441 | 448 | |
|
442 | 449 | IPython 7.22 |
|
443 | 450 | ============ |
|
444 | 451 | |
|
445 | 452 | Second release of IPython for 2021, mostly containing bug fixes. Here is a quick |
|
446 | 453 | rundown of the few changes. |
|
447 | 454 | |
|
448 | 455 | - Fix some ``sys.excepthook`` shenanigan when embedding with qt, recommended if |
|
449 | 456 | you β for example β use `napari <https://napari.org>`__. :ghpull:`12842`. |
|
450 | 457 | - Fix bug when using the new ipdb ``%context`` magic :ghpull:`12844` |
|
451 | 458 | - Couples of deprecation cleanup :ghpull:`12868` |
|
452 | 459 | - Update for new dpast.com api if you use the ``%pastbin`` magic. :ghpull:`12712` |
|
453 | 460 | - Remove support for numpy before 1.16. :ghpull:`12836` |
|
454 | 461 | |
|
455 | 462 | |
|
456 | 463 | Thanks |
|
457 | 464 | ------ |
|
458 | 465 | |
|
459 | 466 | We have a new team member that you should see more often on the IPython |
|
460 | 467 | repository, BΕaΕΌej Michalik (@MrMino) have been doing regular contributions to |
|
461 | 468 | IPython, and spent time replying to many issues and guiding new users to the |
|
462 | 469 | codebase; they now have triage permissions to the IPython repository and we'll |
|
463 | 470 | work toward giving them more permission in the future. |
|
464 | 471 | |
|
465 | 472 | Many thanks to all the contributors to this release you can find all individual |
|
466 | 473 | contributions to this milestone `on github <https://github.com/ipython/ipython/milestone/84>`__. |
|
467 | 474 | |
|
468 | 475 | Thanks as well to organisations, QuantStack for working on debugger |
|
469 | 476 | compatibility for Xeus_python, and the `D. E. Shaw group |
|
470 | 477 | <https://deshaw.com/>`__ for sponsoring work on IPython and related libraries. |
|
471 | 478 | |
|
472 | 479 | .. _version 721: |
|
473 | 480 | |
|
474 | 481 | IPython 7.21 |
|
475 | 482 | ============ |
|
476 | 483 | |
|
477 | 484 | IPython 7.21 is the first release we have back on schedule of one release every |
|
478 | 485 | month; it contains a number of minor fixes and improvements, notably, the new |
|
479 | 486 | context command for ipdb |
|
480 | 487 | |
|
481 | 488 | |
|
482 | 489 | New "context" command in ipdb |
|
483 | 490 | ----------------------------- |
|
484 | 491 | |
|
485 | 492 | It is now possible to change the number of lines shown in the backtrace |
|
486 | 493 | information in ipdb using "context" command. :ghpull:`12826` |
|
487 | 494 | |
|
488 | 495 | (thanks @MrMino, there are other improvement from them on master). |
|
489 | 496 | |
|
490 | 497 | Other notable changes in IPython 7.21 |
|
491 | 498 | ------------------------------------- |
|
492 | 499 | |
|
493 | 500 | - Fix some issues on new osx-arm64 :ghpull:`12804`, :ghpull:`12807`. |
|
494 | 501 | - Compatibility with Xeus-Python for debugger protocol, :ghpull:`12809` |
|
495 | 502 | - Misc docs fixes for compatibility and uniformity with Numpydoc. |
|
496 | 503 | :ghpull:`12824` |
|
497 | 504 | |
|
498 | 505 | |
|
499 | 506 | Thanks |
|
500 | 507 | ------ |
|
501 | 508 | |
|
502 | 509 | Many thanks to all the contributors to this release you can find all individual |
|
503 | 510 | contribution to this milestone `on github <https://github.com/ipython/ipython/milestone/83>`__. |
|
504 | 511 | |
|
505 | 512 | |
|
506 | 513 | .. _version 720: |
|
507 | 514 | |
|
508 | 515 | IPython 7.20 |
|
509 | 516 | ============ |
|
510 | 517 | |
|
511 | 518 | IPython 7.20 is the accumulation of 3 month of work on IPython, spacing between |
|
512 | 519 | IPython release have been increased from the usual once a month for various |
|
513 | 520 | reason. |
|
514 | 521 | |
|
515 | 522 | - Mainly as I'm too busy and the effectively sole maintainer, and |
|
516 | 523 | - Second because not much changes happened before mid December. |
|
517 | 524 | |
|
518 | 525 | The main driver for this release was the new version of Jedi 0.18 breaking API; |
|
519 | 526 | which was taken care of in the master branch early in 2020 but not in 7.x as I |
|
520 | 527 | though that by now 8.0 would be out. |
|
521 | 528 | |
|
522 | 529 | The inclusion of a resolver in pip did not help and actually made things worse. |
|
523 | 530 | If usually I would have simply pinned Jedi to ``<0.18``; this is not a solution |
|
524 | 531 | anymore as now pip is free to install Jedi 0.18, and downgrade IPython. |
|
525 | 532 | |
|
526 | 533 | I'll do my best to keep the regular release, but as the 8.0-dev branch and 7.x |
|
527 | 534 | are starting to diverge this is becoming difficult in particular with my limited |
|
528 | 535 | time, so if you have any cycles to spare I'll appreciate your help to respond to |
|
529 | 536 | issues and pushing 8.0 forward. |
|
530 | 537 | |
|
531 | 538 | Here are thus some of the changes for IPython 7.20. |
|
532 | 539 | |
|
533 | 540 | - Support for PyQt5 >= 5.11 :ghpull:`12715` |
|
534 | 541 | - ``%reset`` remove imports more agressively :ghpull:`12718` |
|
535 | 542 | - fix the ``%conda`` magic :ghpull:`12739` |
|
536 | 543 | - compatibility with Jedi 0.18, and bump minimum Jedi version. :ghpull:`12793` |
|
537 | 544 | |
|
538 | 545 | |
|
539 | 546 | .. _version 719: |
|
540 | 547 | |
|
541 | 548 | IPython 7.19 |
|
542 | 549 | ============ |
|
543 | 550 | |
|
544 | 551 | IPython 7.19 accumulative two month of works, bug fixes and improvements, there |
|
545 | 552 | was exceptionally no release last month. |
|
546 | 553 | |
|
547 | 554 | - Fix to restore the ability to specify more than one extension using command |
|
548 | 555 | line flags when using traitlets 5.0 :ghpull:`12543` |
|
549 | 556 | - Docs docs formatting that make the install commands work on zsh |
|
550 | 557 | :ghpull:`12587` |
|
551 | 558 | - Always display the last frame in tracebacks even if hidden with |
|
552 | 559 | ``__tracebackhide__`` :ghpull:`12601` |
|
553 | 560 | - Avoid an issue where a callback can be registered multiple times. |
|
554 | 561 | :ghpull:`12625` |
|
555 | 562 | - Avoid an issue in debugger mode where frames changes could be lost. |
|
556 | 563 | :ghpull:`12627` |
|
557 | 564 | |
|
558 | 565 | - Never hide the frames that invoke a debugger, even if marked as hidden by |
|
559 | 566 | ``__tracebackhide__`` :ghpull:`12631` |
|
560 | 567 | - Fix calling the debugger in a recursive manner :ghpull:`12659` |
|
561 | 568 | |
|
562 | 569 | |
|
563 | 570 | A number of code changes have landed on master and we are getting close to |
|
564 | 571 | enough new features and codebase improvement that a 8.0 start to make sens. |
|
565 | 572 | For downstream packages, please start working on migrating downstream testing |
|
566 | 573 | away from iptest and using pytest, as nose will not work on Python 3.10 and we |
|
567 | 574 | will likely start removing it as a dependency for testing. |
|
568 | 575 | |
|
569 | 576 | .. _version 718: |
|
570 | 577 | |
|
571 | 578 | IPython 7.18 |
|
572 | 579 | ============ |
|
573 | 580 | |
|
574 | 581 | IPython 7.18 is a minor release that mostly contains bugfixes. |
|
575 | 582 | |
|
576 | 583 | - ``CRLF`` is now handled by magics my default; solving some issues due to copy |
|
577 | 584 | pasting on windows. :ghpull:`12475` |
|
578 | 585 | |
|
579 | 586 | - Requiring pexpect ``>=4.3`` as we are Python 3.7+ only and earlier version of |
|
580 | 587 | pexpect will be incompatible. :ghpull:`12510` |
|
581 | 588 | |
|
582 | 589 | - Minimum jedi version is now 0.16. :ghpull:`12488` |
|
583 | 590 | |
|
584 | 591 | |
|
585 | 592 | |
|
586 | 593 | .. _version 717: |
|
587 | 594 | |
|
588 | 595 | IPython 7.17 |
|
589 | 596 | ============ |
|
590 | 597 | |
|
591 | 598 | IPython 7.17 brings a couple of new improvements to API and a couple of user |
|
592 | 599 | facing changes to make the terminal experience more user friendly. |
|
593 | 600 | |
|
594 | 601 | :ghpull:`12407` introduces the ability to pass extra argument to the IPython |
|
595 | 602 | debugger class; this is to help a new project from ``kmaork`` |
|
596 | 603 | (https://github.com/kmaork/madbg) to feature a fully remote debugger. |
|
597 | 604 | |
|
598 | 605 | :ghpull:`12410` finally remove support for 3.6, while the codebase is still |
|
599 | 606 | technically compatible; IPython will not install on Python 3.6. |
|
600 | 607 | |
|
601 | 608 | lots of work on the debugger and hidden frames from ``@impact27`` in |
|
602 | 609 | :ghpull:`12437`, :ghpull:`12445`, :ghpull:`12460` and in particular |
|
603 | 610 | :ghpull:`12453` which make the debug magic more robust at handling spaces. |
|
604 | 611 | |
|
605 | 612 | Biggest API addition is code transformation which is done before code execution; |
|
606 | 613 | IPython allows a number of hooks to catch non-valid Python syntax (magic, prompt |
|
607 | 614 | stripping...etc). Transformers are usually called many time; typically: |
|
608 | 615 | |
|
609 | 616 | - When trying to figure out whether the code is complete and valid (should we |
|
610 | 617 | insert a new line or execute ?) |
|
611 | 618 | - During actual code execution pass before giving the code to Python's |
|
612 | 619 | ``exec``. |
|
613 | 620 | |
|
614 | 621 | This lead to issues when transformer might have had side effects; or do external |
|
615 | 622 | queries. Starting with IPython 7.17 you can expect your transformer to be called |
|
616 | 623 | less time. |
|
617 | 624 | |
|
618 | 625 | Input transformers are now called only once in the execution path of |
|
619 | 626 | `InteractiveShell`, allowing to register transformer that potentially have side |
|
620 | 627 | effects (note that this is not recommended). Internal methods `should_run_async`, and |
|
621 | 628 | `run_cell_async` now take a recommended optional `transformed_cell`, and |
|
622 | 629 | `preprocessing_exc_tuple` parameters that will become mandatory at some point in |
|
623 | 630 | the future; that is to say cells need to be explicitly transformed to be valid |
|
624 | 631 | Python syntax ahead of trying to run them. :ghpull:`12440`; |
|
625 | 632 | |
|
626 | 633 | ``input_transformers`` can now also have an attribute ``has_side_effects`` set |
|
627 | 634 | to `True`, when this attribute is present; this will prevent the transformers |
|
628 | 635 | from being ran when IPython is trying to guess whether the user input is |
|
629 | 636 | complete. Note that this may means you will need to explicitly execute in some |
|
630 | 637 | case where your transformations are now not ran; but will not affect users with |
|
631 | 638 | no custom extensions. |
|
632 | 639 | |
|
633 | 640 | |
|
634 | 641 | API Changes |
|
635 | 642 | ----------- |
|
636 | 643 | |
|
637 | 644 | Change of API and exposed objects automatically detected using `frappuccino |
|
638 | 645 | <https://pypi.org/project/frappuccino/>`_ |
|
639 | 646 | |
|
640 | 647 | |
|
641 | 648 | The following items are new since 7.16.0:: |
|
642 | 649 | |
|
643 | 650 | + IPython.core.interactiveshell.InteractiveShell.get_local_scope(self, stack_depth) |
|
644 | 651 | |
|
645 | 652 | The following signatures differ since 7.16.0:: |
|
646 | 653 | |
|
647 | 654 | - IPython.core.interactiveshell.InteractiveShell.run_cell_async(self, raw_cell, store_history=False, silent=False, shell_futures=True) |
|
648 | 655 | + IPython.core.interactiveshell.InteractiveShell.run_cell_async(self, raw_cell, store_history=False, silent=False, shell_futures=True, *, transformed_cell=None, preprocessing_exc_tuple=None) |
|
649 | 656 | |
|
650 | 657 | - IPython.core.interactiveshell.InteractiveShell.should_run_async(self, raw_cell) |
|
651 | 658 | + IPython.core.interactiveshell.InteractiveShell.should_run_async(self, raw_cell, *, transformed_cell=None, preprocessing_exc_tuple=None) |
|
652 | 659 | |
|
653 | 660 | - IPython.terminal.debugger.TerminalPdb.pt_init(self) |
|
654 | 661 | + IPython.terminal.debugger.TerminalPdb.pt_init(self, pt_session_options=None) |
|
655 | 662 | |
|
656 | 663 | This method was added:: |
|
657 | 664 | |
|
658 | 665 | + IPython.core.interactiveshell.InteractiveShell.get_local_scope |
|
659 | 666 | |
|
660 | 667 | Which is now also present on subclasses:: |
|
661 | 668 | |
|
662 | 669 | + IPython.terminal.embed.InteractiveShellEmbed.get_local_scope |
|
663 | 670 | + IPython.terminal.interactiveshell.TerminalInteractiveShell.get_local_scope |
|
664 | 671 | |
|
665 | 672 | |
|
666 | 673 | .. _version 716: |
|
667 | 674 | |
|
668 | 675 | IPython 7.16.1, 7.16.2 |
|
669 | 676 | ====================== |
|
670 | 677 | |
|
671 | 678 | IPython 7.16.1 was release immediately after 7.16.0 to fix a conda packaging issue. |
|
672 | 679 | The source is identical to 7.16.0 but the file permissions in the tar are different. |
|
673 | 680 | |
|
674 | 681 | IPython 7.16.2 pins jedi dependency to "<=0.17.2" which should prevent some |
|
675 | 682 | issues for users still on python 3.6. This may not be sufficient as pip may |
|
676 | 683 | still allow to downgrade IPython. |
|
677 | 684 | |
|
678 | 685 | Compatibility with Jedi > 0.17.2 was not added as this would have meant bumping |
|
679 | 686 | the minimal version to >0.16. |
|
680 | 687 | |
|
681 | 688 | IPython 7.16 |
|
682 | 689 | ============ |
|
683 | 690 | |
|
684 | 691 | |
|
685 | 692 | The default traceback mode will now skip frames that are marked with |
|
686 | 693 | ``__tracebackhide__ = True`` and show how many traceback frames have been |
|
687 | 694 | skipped. This can be toggled by using :magic:`xmode` with the ``--show`` or |
|
688 | 695 | ``--hide`` attribute. It will have no effect on non verbose traceback modes. |
|
689 | 696 | |
|
690 | 697 | The ipython debugger also now understands ``__tracebackhide__`` as well and will |
|
691 | 698 | skip hidden frames when displaying. Movement up and down the stack will skip the |
|
692 | 699 | hidden frames and will show how many frames were hidden. Internal IPython frames |
|
693 | 700 | are also now hidden by default. The behavior can be changed with the |
|
694 | 701 | ``skip_hidden`` while in the debugger, command and accepts "yes", "no", "true" |
|
695 | 702 | and "false" case insensitive parameters. |
|
696 | 703 | |
|
697 | 704 | |
|
698 | 705 | Misc Noticeable changes: |
|
699 | 706 | ------------------------ |
|
700 | 707 | |
|
701 | 708 | - Exceptions are now (re)raised when running notebooks via the :magic:`%run`, helping to catch issues in workflows and |
|
702 | 709 | pipelines. :ghpull:`12301` |
|
703 | 710 | - Fix inputhook for qt 5.15.0 :ghpull:`12355` |
|
704 | 711 | - Fix wx inputhook :ghpull:`12375` |
|
705 | 712 | - Add handling for malformed pathext env var (Windows) :ghpull:`12367` |
|
706 | 713 | - use $SHELL in system_piped :ghpull:`12360` for uniform behavior with |
|
707 | 714 | ipykernel. |
|
708 | 715 | |
|
709 | 716 | Reproducible Build |
|
710 | 717 | ------------------ |
|
711 | 718 | |
|
712 | 719 | IPython 7.15 reproducible build did not work, so we try again this month |
|
713 | 720 | :ghpull:`12358`. |
|
714 | 721 | |
|
715 | 722 | |
|
716 | 723 | API Changes |
|
717 | 724 | ----------- |
|
718 | 725 | |
|
719 | 726 | Change of API and exposed objects automatically detected using `frappuccino |
|
720 | 727 | <https://pypi.org/project/frappuccino/>`_ (still in beta): |
|
721 | 728 | |
|
722 | 729 | |
|
723 | 730 | The following items are new and mostly related to understanding ``__tracebackhide__``:: |
|
724 | 731 | |
|
725 | 732 | + IPython.core.debugger.Pdb.do_down(self, arg) |
|
726 | 733 | + IPython.core.debugger.Pdb.do_skip_hidden(self, arg) |
|
727 | 734 | + IPython.core.debugger.Pdb.do_up(self, arg) |
|
728 | 735 | + IPython.core.debugger.Pdb.hidden_frames(self, stack) |
|
729 | 736 | + IPython.core.debugger.Pdb.stop_here(self, frame) |
|
730 | 737 | |
|
731 | 738 | |
|
732 | 739 | The following items have been removed:: |
|
733 | 740 | |
|
734 | 741 | - IPython.core.debugger.Pdb.new_do_down |
|
735 | 742 | - IPython.core.debugger.Pdb.new_do_up |
|
736 | 743 | |
|
737 | 744 | Those were implementation details. |
|
738 | 745 | |
|
739 | 746 | |
|
740 | 747 | .. _version 715: |
|
741 | 748 | |
|
742 | 749 | IPython 7.15 |
|
743 | 750 | ============ |
|
744 | 751 | |
|
745 | 752 | IPython 7.15 brings a number of bug fixes and user facing improvements. |
|
746 | 753 | |
|
747 | 754 | Misc Noticeable changes: |
|
748 | 755 | ------------------------ |
|
749 | 756 | |
|
750 | 757 | - Long completion name have better elision in terminal :ghpull:`12284` |
|
751 | 758 | - I've started to test on Python 3.9 :ghpull:`12307` and fix some errors. |
|
752 | 759 | - Hi DPI scaling of figures when using qt eventloop :ghpull:`12314` |
|
753 | 760 | - Document the ability to have systemwide configuration for IPython. |
|
754 | 761 | :ghpull:`12328` |
|
755 | 762 | - Fix issues with input autoformatting :ghpull:`12336` |
|
756 | 763 | - ``IPython.core.debugger.Pdb`` is now interruptible (:ghpull:`12168`, in 7.14 |
|
757 | 764 | but forgotten in release notes) |
|
758 | 765 | - Video HTML attributes (:ghpull:`12212`, in 7.14 but forgotten in release |
|
759 | 766 | notes) |
|
760 | 767 | |
|
761 | 768 | Reproducible Build |
|
762 | 769 | ------------------ |
|
763 | 770 | |
|
764 | 771 | Starting with IPython 7.15, I am attempting to provide reproducible builds, |
|
765 | 772 | that is to say you should be able from the source tree to generate an sdist |
|
766 | 773 | and wheel that are identical byte for byte with the publish version on PyPI. |
|
767 | 774 | |
|
768 | 775 | I've only tested on a couple of machines so far and the process is relatively |
|
769 | 776 | straightforward, so this mean that IPython not only have a deterministic build |
|
770 | 777 | process, but also I have either removed, or put under control all effects of |
|
771 | 778 | the build environments on the final artifact. I encourage you to attempt the |
|
772 | 779 | build process on your machine as documented in :ref:`core_developer_guide` |
|
773 | 780 | and let me know if you do not obtain an identical artifact. |
|
774 | 781 | |
|
775 | 782 | While reproducible builds is critical to check that the supply chain of (open |
|
776 | 783 | source) software has not been compromised, it can also help to speedup many |
|
777 | 784 | of the build processes in large environment (conda, apt...) by allowing |
|
778 | 785 | better caching of intermediate build steps. |
|
779 | 786 | |
|
780 | 787 | Learn more on `<https://reproducible-builds.org/>`_. `Reflections on trusting |
|
781 | 788 | trust <https://dl.acm.org/doi/10.1145/358198.358210>`_ is also one of the |
|
782 | 789 | cornerstone and recommended reads on this subject. |
|
783 | 790 | |
|
784 | 791 | .. note:: |
|
785 | 792 | |
|
786 | 793 | The build commit from which the sdist is generated is also `signed |
|
787 | 794 | <https://en.wikipedia.org/wiki/Digital_signature>`_, so you should be able to |
|
788 | 795 | check it has not been compromised, and the git repository is a `merkle-tree |
|
789 | 796 | <https://en.wikipedia.org/wiki/Merkle_tree>`_, you can check the consistency |
|
790 | 797 | with `git-fsck <https://git-scm.com/docs/git-fsck>`_ which you likely `want |
|
791 | 798 | to enable by default |
|
792 | 799 | <https://gist.github.com/mbbx6spp/14b86437e794bffb4120>`_. |
|
793 | 800 | |
|
794 | 801 | NEP29: Last version to support Python 3.6 |
|
795 | 802 | ----------------------------------------- |
|
796 | 803 | |
|
797 | 804 | IPython 7.15 will be the Last IPython version to officially support Python |
|
798 | 805 | 3.6, as stated by `NumPy Enhancement Proposal 29 |
|
799 | 806 | <https://numpy.org/neps/nep-0029-deprecation_policy.html>`_. Starting with |
|
800 | 807 | next minor version of IPython I may stop testing on Python 3.6 and may stop |
|
801 | 808 | publishing release artifacts that install on Python 3.6 |
|
802 | 809 | |
|
803 | 810 | Highlighted features |
|
804 | 811 | -------------------- |
|
805 | 812 | |
|
806 | 813 | Highlighted features are not new, but seem to not be widely known, this |
|
807 | 814 | section will help you discover in more narrative form what you can do with |
|
808 | 815 | IPython. |
|
809 | 816 | |
|
810 | 817 | Increase Tab Completion Menu Height |
|
811 | 818 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
812 | 819 | |
|
813 | 820 | In terminal IPython it is possible to increase the hight of the tab-completion |
|
814 | 821 | menu. To do so set the value of |
|
815 | 822 | :configtrait:`TerminalInteractiveShell.space_for_menu`, this will reserve more |
|
816 | 823 | space at the bottom of the screen for various kind of menus in IPython including |
|
817 | 824 | tab completion and searching in history. |
|
818 | 825 | |
|
819 | 826 | Autoformat Code in the terminal |
|
820 | 827 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
821 | 828 | |
|
822 | 829 | If you have a preferred code formatter, you can configure IPython to |
|
823 | 830 | reformat your code. Set the value of |
|
824 | 831 | :configtrait:`TerminalInteractiveShell.autoformatter` to for example ``'black'`` |
|
825 | 832 | and IPython will auto format your code when possible. |
|
826 | 833 | |
|
827 | 834 | |
|
828 | 835 | .. _version 714: |
|
829 | 836 | |
|
830 | 837 | IPython 7.14 |
|
831 | 838 | ============ |
|
832 | 839 | |
|
833 | 840 | IPython 7.14 is a minor release that fix a couple of bugs and prepare |
|
834 | 841 | compatibility with new or future versions of some libraries. |
|
835 | 842 | |
|
836 | 843 | Important changes: |
|
837 | 844 | ------------------ |
|
838 | 845 | |
|
839 | 846 | - Fix compatibility with Sphinx 3+ :ghpull:`12235` |
|
840 | 847 | - Remove deprecated matplotlib parameter usage, compatibility with matplotlib |
|
841 | 848 | 3.3+ :`122250` |
|
842 | 849 | |
|
843 | 850 | Misc Changes |
|
844 | 851 | ------------ |
|
845 | 852 | |
|
846 | 853 | - set ``.py`` extension when editing current buffer in vi/emacs. :ghpull:`12167` |
|
847 | 854 | - support for unicode identifiers in ``?``/``??`` :ghpull:`12208` |
|
848 | 855 | - add extra options to the ``Video`` Rich objects :ghpull:`12212` |
|
849 | 856 | - add pretty-printing to ``SimpleNamespace`` :ghpull:`12230` |
|
850 | 857 | |
|
851 | 858 | IPython.core.debugger.Pdb is now interruptible |
|
852 | 859 | ---------------------------------------------- |
|
853 | 860 | |
|
854 | 861 | A ``KeyboardInterrupt`` will now interrupt IPython's extended debugger, in order to make Jupyter able to interrupt it. (:ghpull:`12168`) |
|
855 | 862 | |
|
856 | 863 | Video HTML attributes |
|
857 | 864 | --------------------- |
|
858 | 865 | |
|
859 | 866 | Add an option to `IPython.display.Video` to change the attributes of the HTML display of the video (:ghpull:`12212`) |
|
860 | 867 | |
|
861 | 868 | |
|
862 | 869 | Pending deprecated imports |
|
863 | 870 | -------------------------- |
|
864 | 871 | |
|
865 | 872 | Many object present in ``IPython.core.display`` are there for internal use only, |
|
866 | 873 | and should already been imported from ``IPython.display`` by users and external |
|
867 | 874 | libraries. Trying to import those from ``IPython.core.display`` is still possible |
|
868 | 875 | but will trigger a |
|
869 | 876 | deprecation warning in later versions of IPython and will become errors in the |
|
870 | 877 | future. |
|
871 | 878 | |
|
872 | 879 | This will simplify compatibility with other Python kernels (like Xeus-Python), |
|
873 | 880 | and simplify code base. |
|
874 | 881 | |
|
875 | 882 | |
|
876 | 883 | |
|
877 | 884 | |
|
878 | 885 | .. _version 713: |
|
879 | 886 | |
|
880 | 887 | IPython 7.13 |
|
881 | 888 | ============ |
|
882 | 889 | |
|
883 | 890 | IPython 7.13 is the final release of the 7.x branch since master is diverging |
|
884 | 891 | toward an 8.0. Exiting new features have already been merged in 8.0 and will |
|
885 | 892 | not be available on the 7.x branch. All the changes below have been backported |
|
886 | 893 | from the master branch. |
|
887 | 894 | |
|
888 | 895 | |
|
889 | 896 | - Fix inability to run PDB when inside an event loop :ghpull:`12141` |
|
890 | 897 | - Fix ability to interrupt some processes on windows :ghpull:`12137` |
|
891 | 898 | - Fix debugger shortcuts :ghpull:`12132` |
|
892 | 899 | - improve tab completion when inside a string by removing irrelevant elements :ghpull:`12128` |
|
893 | 900 | - Fix display of filename tab completion when the path is long :ghpull:`12122` |
|
894 | 901 | - Many removal of Python 2 specific code path :ghpull:`12110` |
|
895 | 902 | - displaying wav files do not require NumPy anymore, and is 5x to 30x faster :ghpull:`12113` |
|
896 | 903 | |
|
897 | 904 | See the list of all closed issues and pull request on `github |
|
898 | 905 | <https://github.com/ipython/ipython/pulls?q=is%3Aclosed+milestone%3A7.13>`_. |
|
899 | 906 | |
|
900 | 907 | .. _version 712: |
|
901 | 908 | |
|
902 | 909 | IPython 7.12 |
|
903 | 910 | ============ |
|
904 | 911 | |
|
905 | 912 | IPython 7.12 is a minor update that mostly brings code cleanup, removal of |
|
906 | 913 | longtime deprecated function and a couple update to documentation cleanup as well. |
|
907 | 914 | |
|
908 | 915 | Notable changes are the following: |
|
909 | 916 | |
|
910 | 917 | - Exit non-zero when ipython is given a file path to run that doesn't exist :ghpull:`12074` |
|
911 | 918 | - Test PR on ARM64 with Travis-CI :ghpull:`12073` |
|
912 | 919 | - Update CI to work with latest Pytest :ghpull:`12086` |
|
913 | 920 | - Add infrastructure to run ipykernel eventloop via trio :ghpull:`12097` |
|
914 | 921 | - Support git blame ignore revs :ghpull:`12091` |
|
915 | 922 | - Start multi-line ``__repr__`` s on their own line :ghpull:`12099` |
|
916 | 923 | |
|
917 | 924 | .. _version 7111: |
|
918 | 925 | |
|
919 | 926 | IPython 7.11.1 |
|
920 | 927 | ============== |
|
921 | 928 | |
|
922 | 929 | A couple of deprecated functions (no-op) have been reintroduces in py3compat as |
|
923 | 930 | Cython was still relying on them, and will be removed in a couple of versions. |
|
924 | 931 | |
|
925 | 932 | .. _version 711: |
|
926 | 933 | |
|
927 | 934 | IPython 7.11 |
|
928 | 935 | ============ |
|
929 | 936 | |
|
930 | 937 | IPython 7.11 received a couple of compatibility fixes and code cleanup. |
|
931 | 938 | |
|
932 | 939 | A number of function in the ``py3compat`` have been removed; a number of types |
|
933 | 940 | in the IPython code base are now non-ambiguous and now always ``unicode`` |
|
934 | 941 | instead of ``Union[Unicode,bytes]``; many of the relevant code path have thus |
|
935 | 942 | been simplified/cleaned and types annotation added. |
|
936 | 943 | |
|
937 | 944 | IPython support several verbosity level from exceptions. ``xmode plain`` now |
|
938 | 945 | support chained exceptions. :ghpull:`11999` |
|
939 | 946 | |
|
940 | 947 | We are starting to remove ``shell=True`` in some usages of subprocess. While not directly |
|
941 | 948 | a security issue (as IPython is made to run arbitrary code anyway) it is not good |
|
942 | 949 | practice and we'd like to show the example. :ghissue:`12023`. This discussion |
|
943 | 950 | was started by ``@mschwager`` thanks to a new auditing tool they are working on |
|
944 | 951 | with duo-labs (`dlint <https://github.com/duo-labs/dlint>`_). |
|
945 | 952 | |
|
946 | 953 | Work around some bugs in Python 3.9 tokenizer :ghpull:`12057` |
|
947 | 954 | |
|
948 | 955 | IPython will now print its version after a crash. :ghpull:`11986` |
|
949 | 956 | |
|
950 | 957 | This is likely the last release from the 7.x series that will see new feature. |
|
951 | 958 | The master branch will soon accept large code changes and thrilling new |
|
952 | 959 | features; the 7.x branch will only start to accept critical bug fixes, and |
|
953 | 960 | update dependencies. |
|
954 | 961 | |
|
955 | 962 | .. _version 7102: |
|
956 | 963 | |
|
957 | 964 | IPython 7.10.2 |
|
958 | 965 | ============== |
|
959 | 966 | |
|
960 | 967 | IPython 7.10.2 fix a couple of extra incompatibility between IPython, ipdb, |
|
961 | 968 | asyncio and Prompt Toolkit 3. |
|
962 | 969 | |
|
963 | 970 | .. _version 7101: |
|
964 | 971 | |
|
965 | 972 | IPython 7.10.1 |
|
966 | 973 | ============== |
|
967 | 974 | |
|
968 | 975 | IPython 7.10.1 fix a couple of incompatibilities with Prompt toolkit 3 (please |
|
969 | 976 | update Prompt toolkit to 3.0.2 at least), and fixes some interaction with |
|
970 | 977 | headless IPython. |
|
971 | 978 | |
|
972 | 979 | .. _version 7100: |
|
973 | 980 | |
|
974 | 981 | IPython 7.10.0 |
|
975 | 982 | ============== |
|
976 | 983 | |
|
977 | 984 | IPython 7.10 is the first double digit minor release in the last decade, and |
|
978 | 985 | first since the release of IPython 1.0, previous double digit minor release was |
|
979 | 986 | in August 2009. |
|
980 | 987 | |
|
981 | 988 | We've been trying to give you regular release on the last Friday of every month |
|
982 | 989 | for a guaranty of rapid access to bug fixes and new features. |
|
983 | 990 | |
|
984 | 991 | Unlike the previous first few releases that have seen only a couple of code |
|
985 | 992 | changes, 7.10 bring a number of changes, new features and bugfixes. |
|
986 | 993 | |
|
987 | 994 | Stop Support for Python 3.5 β Adopt NEP 29 |
|
988 | 995 | ------------------------------------------ |
|
989 | 996 | |
|
990 | 997 | IPython has decided to follow the informational `NEP 29 |
|
991 | 998 | <https://numpy.org/neps/nep-0029-deprecation_policy.html>`_ which layout a clear |
|
992 | 999 | policy as to which version of (C)Python and NumPy are supported. |
|
993 | 1000 | |
|
994 | 1001 | We thus dropped support for Python 3.5, and cleaned up a number of code path |
|
995 | 1002 | that were Python-version dependant. If you are on 3.5 or earlier pip should |
|
996 | 1003 | automatically give you the latest compatible version of IPython so you do not |
|
997 | 1004 | need to pin to a given version. |
|
998 | 1005 | |
|
999 | 1006 | Support for Prompt Toolkit 3.0 |
|
1000 | 1007 | ------------------------------ |
|
1001 | 1008 | |
|
1002 | 1009 | Prompt Toolkit 3.0 was release a week before IPython 7.10 and introduces a few |
|
1003 | 1010 | breaking changes. We believe IPython 7.10 should be compatible with both Prompt |
|
1004 | 1011 | Toolkit 2.x and 3.x, though it has not been extensively tested with 3.x so |
|
1005 | 1012 | please report any issues. |
|
1006 | 1013 | |
|
1007 | 1014 | |
|
1008 | 1015 | Prompt Rendering Performance improvements |
|
1009 | 1016 | ----------------------------------------- |
|
1010 | 1017 | |
|
1011 | 1018 | Pull Request :ghpull:`11933` introduced an optimisation in the prompt rendering |
|
1012 | 1019 | logic that should decrease the resource usage of IPython when using the |
|
1013 | 1020 | _default_ configuration but could potentially introduce a regression of |
|
1014 | 1021 | functionalities if you are using a custom prompt. |
|
1015 | 1022 | |
|
1016 | 1023 | We know assume if you haven't changed the default keybindings that the prompt |
|
1017 | 1024 | **will not change** during the duration of your input β which is for example |
|
1018 | 1025 | not true when using vi insert mode that switches between `[ins]` and `[nor]` |
|
1019 | 1026 | for the current mode. |
|
1020 | 1027 | |
|
1021 | 1028 | If you are experiencing any issue let us know. |
|
1022 | 1029 | |
|
1023 | 1030 | Code autoformatting |
|
1024 | 1031 | ------------------- |
|
1025 | 1032 | |
|
1026 | 1033 | The IPython terminal can now auto format your code just before entering a new |
|
1027 | 1034 | line or executing a command. To do so use the |
|
1028 | 1035 | ``--TerminalInteractiveShell.autoformatter`` option and set it to ``'black'``; |
|
1029 | 1036 | if black is installed IPython will use black to format your code when possible. |
|
1030 | 1037 | |
|
1031 | 1038 | IPython cannot always properly format your code; in particular it will |
|
1032 | 1039 | auto formatting with *black* will only work if: |
|
1033 | 1040 | |
|
1034 | 1041 | - Your code does not contains magics or special python syntax. |
|
1035 | 1042 | |
|
1036 | 1043 | - There is no code after your cursor. |
|
1037 | 1044 | |
|
1038 | 1045 | The Black API is also still in motion; so this may not work with all versions of |
|
1039 | 1046 | black. |
|
1040 | 1047 | |
|
1041 | 1048 | It should be possible to register custom formatter, though the API is till in |
|
1042 | 1049 | flux. |
|
1043 | 1050 | |
|
1044 | 1051 | Arbitrary Mimetypes Handing in Terminal (Aka inline images in terminal) |
|
1045 | 1052 | ----------------------------------------------------------------------- |
|
1046 | 1053 | |
|
1047 | 1054 | When using IPython terminal it is now possible to register function to handle |
|
1048 | 1055 | arbitrary mimetypes. While rendering non-text based representation was possible in |
|
1049 | 1056 | many jupyter frontend; it was not possible in terminal IPython, as usually |
|
1050 | 1057 | terminal are limited to displaying text. As many terminal these days provide |
|
1051 | 1058 | escape sequences to display non-text; bringing this loved feature to IPython CLI |
|
1052 | 1059 | made a lot of sens. This functionality will not only allow inline images; but |
|
1053 | 1060 | allow opening of external program; for example ``mplayer`` to "display" sound |
|
1054 | 1061 | files. |
|
1055 | 1062 | |
|
1056 | 1063 | So far only the hooks necessary for this are in place, but no default mime |
|
1057 | 1064 | renderers added; so inline images will only be available via extensions. We will |
|
1058 | 1065 | progressively enable these features by default in the next few releases, and |
|
1059 | 1066 | contribution is welcomed. |
|
1060 | 1067 | |
|
1061 | 1068 | We welcome any feedback on the API. See :ref:`shell_mimerenderer` for more |
|
1062 | 1069 | informations. |
|
1063 | 1070 | |
|
1064 | 1071 | This is originally based on work form in :ghpull:`10610` from @stephanh42 |
|
1065 | 1072 | started over two years ago, and still a lot need to be done. |
|
1066 | 1073 | |
|
1067 | 1074 | MISC |
|
1068 | 1075 | ---- |
|
1069 | 1076 | |
|
1070 | 1077 | - Completions can define their own ordering :ghpull:`11855` |
|
1071 | 1078 | - Enable Plotting in the same cell than the one that import matplotlib |
|
1072 | 1079 | :ghpull:`11916` |
|
1073 | 1080 | - Allow to store and restore multiple variables at once :ghpull:`11930` |
|
1074 | 1081 | |
|
1075 | 1082 | You can see `all pull-requests <https://github.com/ipython/ipython/pulls?q=is%3Apr+milestone%3A7.10+is%3Aclosed>`_ for this release. |
|
1076 | 1083 | |
|
1077 | 1084 | API Changes |
|
1078 | 1085 | ----------- |
|
1079 | 1086 | |
|
1080 | 1087 | Change of API and exposed objects automatically detected using `frappuccino <https://pypi.org/project/frappuccino/>`_ (still in beta): |
|
1081 | 1088 | |
|
1082 | 1089 | The following items are new in IPython 7.10:: |
|
1083 | 1090 | |
|
1084 | 1091 | + IPython.terminal.shortcuts.reformat_text_before_cursor(buffer, document, shell) |
|
1085 | 1092 | + IPython.terminal.interactiveshell.PTK3 |
|
1086 | 1093 | + IPython.terminal.interactiveshell.black_reformat_handler(text_before_cursor) |
|
1087 | 1094 | + IPython.terminal.prompts.RichPromptDisplayHook.write_format_data(self, format_dict, md_dict='None') |
|
1088 | 1095 | |
|
1089 | 1096 | The following items have been removed in 7.10:: |
|
1090 | 1097 | |
|
1091 | 1098 | - IPython.lib.pretty.DICT_IS_ORDERED |
|
1092 | 1099 | |
|
1093 | 1100 | The following signatures differ between versions:: |
|
1094 | 1101 | |
|
1095 | 1102 | - IPython.extensions.storemagic.restore_aliases(ip) |
|
1096 | 1103 | + IPython.extensions.storemagic.restore_aliases(ip, alias='None') |
|
1097 | 1104 | |
|
1098 | 1105 | Special Thanks |
|
1099 | 1106 | -------------- |
|
1100 | 1107 | |
|
1101 | 1108 | - @stephanh42 who started the work on inline images in terminal 2 years ago |
|
1102 | 1109 | - @augustogoulart who spent a lot of time triaging issues and responding to |
|
1103 | 1110 | users. |
|
1104 | 1111 | - @con-f-use who is my (@Carreau) first sponsor on GitHub, as a reminder if you |
|
1105 | 1112 | like IPython, Jupyter and many other library of the SciPy stack you can |
|
1106 | 1113 | donate to numfocus.org non profit |
|
1107 | 1114 | |
|
1108 | 1115 | .. _version 790: |
|
1109 | 1116 | |
|
1110 | 1117 | IPython 7.9.0 |
|
1111 | 1118 | ============= |
|
1112 | 1119 | |
|
1113 | 1120 | IPython 7.9 is a small release with a couple of improvement and bug fixes. |
|
1114 | 1121 | |
|
1115 | 1122 | - Xterm terminal title should be restored on exit :ghpull:`11910` |
|
1116 | 1123 | - special variables ``_``,``__``, ``___`` are not set anymore when cache size |
|
1117 | 1124 | is 0 or less. :ghpull:`11877` |
|
1118 | 1125 | - Autoreload should have regained some speed by using a new heuristic logic to |
|
1119 | 1126 | find all objects needing reload. This should avoid large objects traversal |
|
1120 | 1127 | like pandas dataframes. :ghpull:`11876` |
|
1121 | 1128 | - Get ready for Python 4. :ghpull:`11874` |
|
1122 | 1129 | - `%env` Magic now has heuristic to hide potentially sensitive values :ghpull:`11896` |
|
1123 | 1130 | |
|
1124 | 1131 | This is a small release despite a number of Pull Request Pending that need to |
|
1125 | 1132 | be reviewed/worked on. Many of the core developers have been busy outside of |
|
1126 | 1133 | IPython/Jupyter and we thanks all contributor for their patience; we'll work on |
|
1127 | 1134 | these as soon as we have time. |
|
1128 | 1135 | |
|
1129 | 1136 | |
|
1130 | 1137 | .. _version780: |
|
1131 | 1138 | |
|
1132 | 1139 | IPython 7.8.0 |
|
1133 | 1140 | ============= |
|
1134 | 1141 | |
|
1135 | 1142 | IPython 7.8.0 contain a few bugfix and 2 new APIs: |
|
1136 | 1143 | |
|
1137 | 1144 | - Enable changing the font color for LaTeX rendering :ghpull:`11840` |
|
1138 | 1145 | - and Re-Expose some PDB API (see below) |
|
1139 | 1146 | |
|
1140 | 1147 | Expose Pdb API |
|
1141 | 1148 | -------------- |
|
1142 | 1149 | |
|
1143 | 1150 | Expose the built-in ``pdb.Pdb`` API. ``Pdb`` constructor arguments are generically |
|
1144 | 1151 | exposed, regardless of python version. |
|
1145 | 1152 | Newly exposed arguments: |
|
1146 | 1153 | |
|
1147 | 1154 | - ``skip`` - Python 3.1+ |
|
1148 | 1155 | - ``nosiginnt`` - Python 3.2+ |
|
1149 | 1156 | - ``readrc`` - Python 3.6+ |
|
1150 | 1157 | |
|
1151 | 1158 | Try it out:: |
|
1152 | 1159 | |
|
1153 | 1160 | from IPython.terminal.debugger import TerminalPdb |
|
1154 | 1161 | pdb = TerminalPdb(skip=["skipthismodule"]) |
|
1155 | 1162 | |
|
1156 | 1163 | |
|
1157 | 1164 | See :ghpull:`11840` |
|
1158 | 1165 | |
|
1159 | 1166 | .. _version770: |
|
1160 | 1167 | |
|
1161 | 1168 | IPython 7.7.0 |
|
1162 | 1169 | ============= |
|
1163 | 1170 | |
|
1164 | 1171 | IPython 7.7.0 contain multiple bug fixes and documentation updates; Here are a |
|
1165 | 1172 | few of the outstanding issue fixed: |
|
1166 | 1173 | |
|
1167 | 1174 | - Fix a bug introduced in 7.6 where the ``%matplotlib`` magic would fail on |
|
1168 | 1175 | previously acceptable arguments :ghpull:`11814`. |
|
1169 | 1176 | - Fix the manage location on freebsd :ghpull:`11808`. |
|
1170 | 1177 | - Fix error message about aliases after ``%reset`` call in ipykernel |
|
1171 | 1178 | :ghpull:`11806` |
|
1172 | 1179 | - Fix Duplication completions in emacs :ghpull:`11803` |
|
1173 | 1180 | |
|
1174 | 1181 | We are planning to adopt `NEP29 <https://github.com/numpy/numpy/pull/14086>`_ |
|
1175 | 1182 | (still currently in draft) which may make this minor version of IPython the |
|
1176 | 1183 | last one to support Python 3.5 and will make the code base more aggressive |
|
1177 | 1184 | toward removing compatibility with older versions of Python. |
|
1178 | 1185 | |
|
1179 | 1186 | GitHub now support to give only "Triage" permissions to users; if you'd like to |
|
1180 | 1187 | help close stale issues and labels issues please reach to us with your GitHub |
|
1181 | 1188 | Username and we'll add you to the triage team. It is a great way to start |
|
1182 | 1189 | contributing and a path toward getting commit rights. |
|
1183 | 1190 | |
|
1184 | 1191 | .. _version761: |
|
1185 | 1192 | |
|
1186 | 1193 | IPython 7.6.1 |
|
1187 | 1194 | ============= |
|
1188 | 1195 | |
|
1189 | 1196 | IPython 7.6.1 contain a critical bugfix in the ``%timeit`` magic, which would |
|
1190 | 1197 | crash on some inputs as a side effect of :ghpull:`11716`. See :ghpull:`11812` |
|
1191 | 1198 | |
|
1192 | 1199 | |
|
1193 | 1200 | .. _whatsnew760: |
|
1194 | 1201 | |
|
1195 | 1202 | IPython 7.6.0 |
|
1196 | 1203 | ============= |
|
1197 | 1204 | |
|
1198 | 1205 | IPython 7.6.0 contains a couple of bug fixes and number of small features |
|
1199 | 1206 | additions as well as some compatibility with the current development version of |
|
1200 | 1207 | Python 3.8. |
|
1201 | 1208 | |
|
1202 | 1209 | - Add a ``-l`` option to :magic:`psearch` to list the available search |
|
1203 | 1210 | types. :ghpull:`11672` |
|
1204 | 1211 | - Support ``PathLike`` for ``DisplayObject`` and ``Image``. :ghpull:`11764` |
|
1205 | 1212 | - Configurability of timeout in the test suite for slow platforms. |
|
1206 | 1213 | :ghpull:`11756` |
|
1207 | 1214 | - Accept any casing for matplotlib backend. :ghpull:`121748` |
|
1208 | 1215 | - Properly skip test that requires numpy to be installed :ghpull:`11723` |
|
1209 | 1216 | - More support for Python 3.8 and positional only arguments (pep570) |
|
1210 | 1217 | :ghpull:`11720` |
|
1211 | 1218 | - Unicode names for the completion are loaded lazily on first use which |
|
1212 | 1219 | should decrease startup time. :ghpull:`11693` |
|
1213 | 1220 | - Autoreload now update the types of reloaded objects; this for example allow |
|
1214 | 1221 | pickling of reloaded objects. :ghpull:`11644` |
|
1215 | 1222 | - Fix a bug where ``%%time`` magic would suppress cell output. :ghpull:`11716` |
|
1216 | 1223 | |
|
1217 | 1224 | |
|
1218 | 1225 | Prepare migration to pytest (instead of nose) for testing |
|
1219 | 1226 | --------------------------------------------------------- |
|
1220 | 1227 | |
|
1221 | 1228 | Most of the work between 7.5 and 7.6 was to prepare the migration from our |
|
1222 | 1229 | testing framework to pytest. Most of the test suite should now work by simply |
|
1223 | 1230 | issuing ``pytest`` from the root of the repository. |
|
1224 | 1231 | |
|
1225 | 1232 | The migration to pytest is just at its beginning. Many of our test still rely |
|
1226 | 1233 | on IPython-specific plugins for nose using pytest (doctest using IPython syntax |
|
1227 | 1234 | is one example of this where test appear as "passing", while no code has been |
|
1228 | 1235 | ran). Many test also need to be updated like ``yield-test`` to be properly |
|
1229 | 1236 | parametrized tests. |
|
1230 | 1237 | |
|
1231 | 1238 | Migration to pytest allowed me to discover a number of issues in our test |
|
1232 | 1239 | suite; which was hiding a number of subtle issues βΒ or not actually running |
|
1233 | 1240 | some of the tests in our test suite β I have thus corrected many of those; like |
|
1234 | 1241 | improperly closed resources; or used of deprecated features. I also made use of |
|
1235 | 1242 | the ``pytest --durations=...`` to find some of our slowest test and speed them |
|
1236 | 1243 | up (our test suite can now be up to 10% faster). Pytest as also a variety of |
|
1237 | 1244 | plugins and flags which will make the code quality of IPython and the testing |
|
1238 | 1245 | experience better. |
|
1239 | 1246 | |
|
1240 | 1247 | Misc |
|
1241 | 1248 | ---- |
|
1242 | 1249 | |
|
1243 | 1250 | We skipped the release of 7.6 at the end of May, but will attempt to get back |
|
1244 | 1251 | on schedule. We are starting to think about making introducing backward |
|
1245 | 1252 | incompatible change and start the 8.0 series. |
|
1246 | 1253 | |
|
1247 | 1254 | Special Thanks to Gabriel (@gpotter2 on GitHub), who among other took care many |
|
1248 | 1255 | of the remaining task for 7.4 and 7.5, like updating the website. |
|
1249 | 1256 | |
|
1250 | 1257 | .. _whatsnew750: |
|
1251 | 1258 | |
|
1252 | 1259 | IPython 7.5.0 |
|
1253 | 1260 | ============= |
|
1254 | 1261 | |
|
1255 | 1262 | IPython 7.5.0 consist mostly of bug-fixes, and documentation updates, with one |
|
1256 | 1263 | minor new feature. The `Audio` display element can now be assigned an element |
|
1257 | 1264 | id when displayed in browser. See :ghpull:`11670` |
|
1258 | 1265 | |
|
1259 | 1266 | The major outstanding bug fix correct a change of behavior that was introduce |
|
1260 | 1267 | in 7.4.0 where some cell magics would not be able to access or modify global |
|
1261 | 1268 | scope when using the ``@needs_local_scope`` decorator. This was typically |
|
1262 | 1269 | encountered with the ``%%time`` and ``%%timeit`` magics. See :ghissue:`11659` |
|
1263 | 1270 | and :ghpull:`11698`. |
|
1264 | 1271 | |
|
1265 | 1272 | .. _whatsnew740: |
|
1266 | 1273 | |
|
1267 | 1274 | IPython 7.4.0 |
|
1268 | 1275 | ============= |
|
1269 | 1276 | |
|
1270 | 1277 | Unicode name completions |
|
1271 | 1278 | ------------------------ |
|
1272 | 1279 | |
|
1273 | 1280 | Previously, we provided completion for a unicode name with its relative symbol. |
|
1274 | 1281 | With this, now IPython provides complete suggestions to unicode name symbols. |
|
1275 | 1282 | |
|
1276 | 1283 | As on the PR, if user types ``\LAT<tab>``, IPython provides a list of |
|
1277 | 1284 | possible completions. In this case, it would be something like:: |
|
1278 | 1285 | |
|
1279 | 1286 | 'LATIN CAPITAL LETTER A', |
|
1280 | 1287 | 'LATIN CAPITAL LETTER B', |
|
1281 | 1288 | 'LATIN CAPITAL LETTER C', |
|
1282 | 1289 | 'LATIN CAPITAL LETTER D', |
|
1283 | 1290 | .... |
|
1284 | 1291 | |
|
1285 | 1292 | This help to type unicode character that do not have short latex aliases, and |
|
1286 | 1293 | have long unicode names. for example ``Ν°``, ``\GREEK CAPITAL LETTER HETA``. |
|
1287 | 1294 | |
|
1288 | 1295 | This feature was contributed by Luciana Marques :ghpull:`11583`. |
|
1289 | 1296 | |
|
1290 | 1297 | Make audio normalization optional |
|
1291 | 1298 | --------------------------------- |
|
1292 | 1299 | |
|
1293 | 1300 | Added 'normalize' argument to `IPython.display.Audio`. This argument applies |
|
1294 | 1301 | when audio data is given as an array of samples. The default of `normalize=True` |
|
1295 | 1302 | preserves prior behavior of normalizing the audio to the maximum possible range. |
|
1296 | 1303 | Setting to `False` disables normalization. |
|
1297 | 1304 | |
|
1298 | 1305 | |
|
1299 | 1306 | Miscellaneous |
|
1300 | 1307 | ------------- |
|
1301 | 1308 | |
|
1302 | 1309 | - Fix improper acceptation of ``return`` outside of functions. :ghpull:`11641`. |
|
1303 | 1310 | - Fixed PyQt 5.11 backwards incompatibility causing sip import failure. |
|
1304 | 1311 | :ghpull:`11613`. |
|
1305 | 1312 | - Fix Bug where ``type?`` would crash IPython. :ghpull:`1608`. |
|
1306 | 1313 | - Allow to apply ``@needs_local_scope`` to cell magics for convenience. |
|
1307 | 1314 | :ghpull:`11542`. |
|
1308 | 1315 | |
|
1309 | 1316 | .. _whatsnew730: |
|
1310 | 1317 | |
|
1311 | 1318 | IPython 7.3.0 |
|
1312 | 1319 | ============= |
|
1313 | 1320 | |
|
1314 | 1321 | .. _whatsnew720: |
|
1315 | 1322 | |
|
1316 | 1323 | IPython 7.3.0 bring several bug fixes and small improvements that you will |
|
1317 | 1324 | described bellow. |
|
1318 | 1325 | |
|
1319 | 1326 | The biggest change to this release is the implementation of the ``%conda`` and |
|
1320 | 1327 | ``%pip`` magics, that will attempt to install packages in the **current |
|
1321 | 1328 | environment**. You may still need to restart your interpreter or kernel for the |
|
1322 | 1329 | change to be taken into account, but it should simplify installation of packages |
|
1323 | 1330 | into remote environment. Installing using pip/conda from the command line is |
|
1324 | 1331 | still the prefer method. |
|
1325 | 1332 | |
|
1326 | 1333 | The ``%pip`` magic was already present, but was only printing a warning; now it |
|
1327 | 1334 | will actually forward commands to pip. |
|
1328 | 1335 | |
|
1329 | 1336 | Misc bug fixes and improvements: |
|
1330 | 1337 | |
|
1331 | 1338 | - Compatibility with Python 3.8. |
|
1332 | 1339 | - Do not expand shell variable in execution magics, and added the |
|
1333 | 1340 | ``no_var_expand`` decorator for magic requiring a similar functionality |
|
1334 | 1341 | :ghpull:`11516` |
|
1335 | 1342 | - Add ``%pip`` and ``%conda`` magic :ghpull:`11524` |
|
1336 | 1343 | - Re-initialize posix aliases after a ``%reset`` :ghpull:`11528` |
|
1337 | 1344 | - Allow the IPython command line to run ``*.ipynb`` files :ghpull:`11529` |
|
1338 | 1345 | |
|
1339 | 1346 | IPython 7.2.0 |
|
1340 | 1347 | ============= |
|
1341 | 1348 | |
|
1342 | 1349 | IPython 7.2.0 brings minor bugfixes, improvements, and new configuration options: |
|
1343 | 1350 | |
|
1344 | 1351 | - Fix a bug preventing PySide2 GUI integration from working :ghpull:`11464` |
|
1345 | 1352 | - Run CI on Mac OS ! :ghpull:`11471` |
|
1346 | 1353 | - Fix IPython "Demo" mode. :ghpull:`11498` |
|
1347 | 1354 | - Fix ``%run`` magic with path in name :ghpull:`11499` |
|
1348 | 1355 | - Fix: add CWD to sys.path *after* stdlib :ghpull:`11502` |
|
1349 | 1356 | - Better rendering of signatures, especially long ones. :ghpull:`11505` |
|
1350 | 1357 | - Re-enable jedi by default if it's installed :ghpull:`11506` |
|
1351 | 1358 | - Add New ``minimal`` exception reporting mode (useful for educational purpose). See :ghpull:`11509` |
|
1352 | 1359 | |
|
1353 | 1360 | |
|
1354 | 1361 | Added ability to show subclasses when using pinfo and other utilities |
|
1355 | 1362 | --------------------------------------------------------------------- |
|
1356 | 1363 | |
|
1357 | 1364 | When using ``?``/``??`` on a class, IPython will now list the first 10 subclasses. |
|
1358 | 1365 | |
|
1359 | 1366 | Special Thanks to Chris Mentzel of the Moore Foundation for this feature. Chris |
|
1360 | 1367 | is one of the people who played a critical role in IPython/Jupyter getting |
|
1361 | 1368 | funding. |
|
1362 | 1369 | |
|
1363 | 1370 | We are grateful for all the help Chris has given us over the years, |
|
1364 | 1371 | and we're now proud to have code contributed by Chris in IPython. |
|
1365 | 1372 | |
|
1366 | 1373 | OSMagics.cd_force_quiet configuration option |
|
1367 | 1374 | -------------------------------------------- |
|
1368 | 1375 | |
|
1369 | 1376 | You can set this option to force the %cd magic to behave as if ``-q`` was passed: |
|
1370 | 1377 | :: |
|
1371 | 1378 | |
|
1372 | 1379 | In [1]: cd / |
|
1373 | 1380 | / |
|
1374 | 1381 | |
|
1375 | 1382 | In [2]: %config OSMagics.cd_force_quiet = True |
|
1376 | 1383 | |
|
1377 | 1384 | In [3]: cd /tmp |
|
1378 | 1385 | |
|
1379 | 1386 | In [4]: |
|
1380 | 1387 | |
|
1381 | 1388 | See :ghpull:`11491` |
|
1382 | 1389 | |
|
1383 | 1390 | In vi editing mode, whether the prompt includes the current vi mode can now be configured |
|
1384 | 1391 | ----------------------------------------------------------------------------------------- |
|
1385 | 1392 | |
|
1386 | 1393 | Set the ``TerminalInteractiveShell.prompt_includes_vi_mode`` to a boolean value |
|
1387 | 1394 | (default: True) to control this feature. See :ghpull:`11492` |
|
1388 | 1395 | |
|
1389 | 1396 | .. _whatsnew710: |
|
1390 | 1397 | |
|
1391 | 1398 | IPython 7.1.0 |
|
1392 | 1399 | ============= |
|
1393 | 1400 | |
|
1394 | 1401 | IPython 7.1.0 is the first minor release after 7.0.0 and mostly brings fixes to |
|
1395 | 1402 | new features, internal refactoring, and fixes for regressions that happened during the 6.x->7.x |
|
1396 | 1403 | transition. It also brings **Compatibility with Python 3.7.1**, as we're |
|
1397 | 1404 | unwillingly relying on a bug in CPython. |
|
1398 | 1405 | |
|
1399 | 1406 | New Core Dev: |
|
1400 | 1407 | |
|
1401 | 1408 | - We welcome Jonathan Slenders to the commiters. Jonathan has done a fantastic |
|
1402 | 1409 | work on prompt_toolkit, and we'd like to recognise his impact by giving him |
|
1403 | 1410 | commit rights. :ghissue:`11397` |
|
1404 | 1411 | |
|
1405 | 1412 | Notable Changes |
|
1406 | 1413 | |
|
1407 | 1414 | - Major update of "latex to unicode" tab completion map (see below) |
|
1408 | 1415 | |
|
1409 | 1416 | Notable New Features: |
|
1410 | 1417 | |
|
1411 | 1418 | - Restore functionality and documentation of the **sphinx directive**, which |
|
1412 | 1419 | is now stricter (fail on error by daefault), has new configuration options, |
|
1413 | 1420 | has a brand new documentation page :ref:`ipython_directive` (which needs |
|
1414 | 1421 | some cleanup). It is also now *tested* so we hope to have less regressions. |
|
1415 | 1422 | :ghpull:`11402` |
|
1416 | 1423 | |
|
1417 | 1424 | - ``IPython.display.Video`` now supports ``width`` and ``height`` arguments, |
|
1418 | 1425 | allowing a custom width and height to be set instead of using the video's |
|
1419 | 1426 | width and height. :ghpull:`11353` |
|
1420 | 1427 | |
|
1421 | 1428 | - Warn when using ``HTML('<iframe>')`` instead of ``IFrame`` :ghpull:`11350` |
|
1422 | 1429 | |
|
1423 | 1430 | - Allow Dynamic switching of editing mode between vi/emacs and show |
|
1424 | 1431 | normal/input mode in prompt when using vi. :ghpull:`11390`. Use ``%config |
|
1425 | 1432 | TerminalInteractiveShell.editing_mode = 'vi'`` or ``%config |
|
1426 | 1433 | TerminalInteractiveShell.editing_mode = 'emacs'`` to dynamically switch |
|
1427 | 1434 | between modes. |
|
1428 | 1435 | |
|
1429 | 1436 | |
|
1430 | 1437 | Notable Fixes: |
|
1431 | 1438 | |
|
1432 | 1439 | - Fix entering of **multi-line blocks in terminal** IPython, and various |
|
1433 | 1440 | crashes in the new input transformation machinery :ghpull:`11354`, |
|
1434 | 1441 | :ghpull:`11356`, :ghpull:`11358`. These also fix a **Compatibility bug |
|
1435 | 1442 | with Python 3.7.1**. |
|
1436 | 1443 | |
|
1437 | 1444 | - Fix moving through generator stack in ipdb :ghpull:`11266` |
|
1438 | 1445 | |
|
1439 | 1446 | - %Magic command arguments now support quoting. :ghpull:`11330` |
|
1440 | 1447 | |
|
1441 | 1448 | - Re-add ``rprint`` and ``rprinte`` aliases. :ghpull:`11331` |
|
1442 | 1449 | |
|
1443 | 1450 | - Remove implicit dependency on ``ipython_genutils`` :ghpull:`11317` |
|
1444 | 1451 | |
|
1445 | 1452 | - Make ``nonlocal`` raise ``SyntaxError`` instead of silently failing in async |
|
1446 | 1453 | mode. :ghpull:`11382` |
|
1447 | 1454 | |
|
1448 | 1455 | - Fix mishandling of magics and ``= !`` assignment just after a dedent in |
|
1449 | 1456 | nested code blocks :ghpull:`11418` |
|
1450 | 1457 | |
|
1451 | 1458 | - Fix instructions for custom shortcuts :ghpull:`11426` |
|
1452 | 1459 | |
|
1453 | 1460 | |
|
1454 | 1461 | Notable Internals improvements: |
|
1455 | 1462 | |
|
1456 | 1463 | - Use of ``os.scandir`` (Python 3 only) to speed up some file system operations. |
|
1457 | 1464 | :ghpull:`11365` |
|
1458 | 1465 | |
|
1459 | 1466 | - use ``perf_counter`` instead of ``clock`` for more precise |
|
1460 | 1467 | timing results with ``%time`` :ghpull:`11376` |
|
1461 | 1468 | |
|
1462 | 1469 | Many thanks to all the contributors and in particular to ``bartskowron`` and |
|
1463 | 1470 | ``tonyfast`` who handled some pretty complicated bugs in the input machinery. We |
|
1464 | 1471 | had a number of first time contributors and maybe hacktoberfest participants that |
|
1465 | 1472 | made significant contributions and helped us free some time to focus on more |
|
1466 | 1473 | complicated bugs. |
|
1467 | 1474 | |
|
1468 | 1475 | You |
|
1469 | 1476 | can see all the closed issues and Merged PR, new features and fixes `here |
|
1470 | 1477 | <https://github.com/ipython/ipython/issues?utf8=%E2%9C%93&q=+is%3Aclosed+milestone%3A7.1+>`_. |
|
1471 | 1478 | |
|
1472 | 1479 | Unicode Completion update |
|
1473 | 1480 | ------------------------- |
|
1474 | 1481 | |
|
1475 | 1482 | In IPython 7.1 the Unicode completion map has been updated and synchronized with |
|
1476 | 1483 | the Julia language. |
|
1477 | 1484 | |
|
1478 | 1485 | Added and removed character characters: |
|
1479 | 1486 | |
|
1480 | 1487 | ``\jmath`` (``Θ·``), ``\\underleftrightarrow`` (U+034D, combining) have been |
|
1481 | 1488 | added, while ``\\textasciicaron`` have been removed |
|
1482 | 1489 | |
|
1483 | 1490 | Some sequences have seen their prefix removed: |
|
1484 | 1491 | |
|
1485 | 1492 | - 6 characters ``\text...<tab>`` should now be inputed with ``\...<tab>`` directly, |
|
1486 | 1493 | - 45 characters ``\Elz...<tab>`` should now be inputed with ``\...<tab>`` directly, |
|
1487 | 1494 | - 65 characters ``\B...<tab>`` should now be inputed with ``\...<tab>`` directly, |
|
1488 | 1495 | - 450 characters ``\m...<tab>`` should now be inputed with ``\...<tab>`` directly, |
|
1489 | 1496 | |
|
1490 | 1497 | Some sequences have seen their prefix shortened: |
|
1491 | 1498 | |
|
1492 | 1499 | - 5 characters ``\mitBbb...<tab>`` should now be inputed with ``\bbi...<tab>`` directly, |
|
1493 | 1500 | - 52 characters ``\mit...<tab>`` should now be inputed with ``\i...<tab>`` directly, |
|
1494 | 1501 | - 216 characters ``\mbfit...<tab>`` should now be inputed with ``\bi...<tab>`` directly, |
|
1495 | 1502 | - 222 characters ``\mbf...<tab>`` should now be inputed with ``\b...<tab>`` directly, |
|
1496 | 1503 | |
|
1497 | 1504 | A couple of characters had their sequence simplified: |
|
1498 | 1505 | |
|
1499 | 1506 | - ``Γ°``, type ``\dh<tab>``, instead of ``\eth<tab>`` |
|
1500 | 1507 | - ``Δ§``, type ``\hbar<tab>``, instead of ``\Elzxh<tab>`` |
|
1501 | 1508 | - ``ΙΈ``, type ``\ltphi<tab>``, instead of ``\textphi<tab>`` |
|
1502 | 1509 | - ``Ο΄``, type ``\varTheta<tab>``, instead of ``\textTheta<tab>`` |
|
1503 | 1510 | - ``β``, type ``\eulermascheroni<tab>``, instead of ``\Eulerconst<tab>`` |
|
1504 | 1511 | - ``β``, type ``\planck<tab>``, instead of ``\Planckconst<tab>`` |
|
1505 | 1512 | |
|
1506 | 1513 | - U+0336 (COMBINING LONG STROKE OVERLAY), type ``\strike<tab>``, instead of ``\Elzbar<tab>``. |
|
1507 | 1514 | |
|
1508 | 1515 | A couple of sequences have been updated: |
|
1509 | 1516 | |
|
1510 | 1517 | - ``\varepsilon`` now gives ``Ι`` (GREEK SMALL LETTER EPSILON) instead of ``Ξ΅`` (GREEK LUNATE EPSILON SYMBOL), |
|
1511 | 1518 | - ``\underbar`` now gives U+0331 (COMBINING MACRON BELOW) instead of U+0332 (COMBINING LOW LINE). |
|
1512 | 1519 | |
|
1513 | 1520 | |
|
1514 | 1521 | .. _whatsnew700: |
|
1515 | 1522 | |
|
1516 | 1523 | IPython 7.0.0 |
|
1517 | 1524 | ============= |
|
1518 | 1525 | |
|
1519 | 1526 | Released Thursday September 27th, 2018 |
|
1520 | 1527 | |
|
1521 | 1528 | IPython 7 includes major feature improvements. |
|
1522 | 1529 | This is also the second major version of IPython to support only |
|
1523 | 1530 | Python 3 βΒ starting at Python 3.4. Python 2 is still community-supported |
|
1524 | 1531 | on the bugfix only 5.x branch, but we remind you that Python 2 "end of life" |
|
1525 | 1532 | is on Jan 1st 2020. |
|
1526 | 1533 | |
|
1527 | 1534 | We were able to backport bug fixes to the 5.x branch thanks to our backport bot which |
|
1528 | 1535 | backported more than `70 Pull-Requests |
|
1529 | 1536 | <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 manual work. This is an area of the project where you can easily contribute by looking for `PRs that still need manual backport <https://github.com/ipython/ipython/issues?q=label%3A%22Still+Needs+Manual+Backport%22+is%3Aclosed+sort%3Aupdated-desc>`_ |
|
1530 | 1537 | |
|
1531 | 1538 | The IPython 6.x branch will likely not see any further release unless critical |
|
1532 | 1539 | bugs are found. |
|
1533 | 1540 | |
|
1534 | 1541 | Make sure you have pip > 9.0 before upgrading. You should be able to update by running: |
|
1535 | 1542 | |
|
1536 | 1543 | .. code:: |
|
1537 | 1544 | |
|
1538 | 1545 | pip install ipython --upgrade |
|
1539 | 1546 | |
|
1540 | 1547 | .. only:: ipydev |
|
1541 | 1548 | |
|
1542 | 1549 | If you are trying to install or update an ``alpha``, ``beta``, or ``rc`` |
|
1543 | 1550 | version, use pip ``--pre`` flag. |
|
1544 | 1551 | |
|
1545 | 1552 | .. code:: |
|
1546 | 1553 | |
|
1547 | 1554 | pip install ipython --upgrade --pre |
|
1548 | 1555 | |
|
1549 | 1556 | |
|
1550 | 1557 | Or, if you have conda installed: |
|
1551 | 1558 | |
|
1552 | 1559 | .. code:: |
|
1553 | 1560 | |
|
1554 | 1561 | conda install ipython |
|
1555 | 1562 | |
|
1556 | 1563 | |
|
1557 | 1564 | |
|
1558 | 1565 | Prompt Toolkit 2.0 |
|
1559 | 1566 | ------------------ |
|
1560 | 1567 | |
|
1561 | 1568 | IPython 7.0+ now uses ``prompt_toolkit 2.0``. If you still need to use an earlier |
|
1562 | 1569 | ``prompt_toolkit`` version, you may need to pin IPython to ``<7.0``. |
|
1563 | 1570 | |
|
1564 | 1571 | Autowait: Asynchronous REPL |
|
1565 | 1572 | --------------------------- |
|
1566 | 1573 | |
|
1567 | 1574 | Staring with IPython 7.0 on Python 3.6+, IPython can automatically ``await`` |
|
1568 | 1575 | top level code. You should not need to access an event loop or runner |
|
1569 | 1576 | yourself. To learn more, read the :ref:`autoawait` section of our docs, see |
|
1570 | 1577 | :ghpull:`11265`, or try the following code:: |
|
1571 | 1578 | |
|
1572 | 1579 | Python 3.6.0 |
|
1573 | 1580 | Type 'copyright', 'credits' or 'license' for more information |
|
1574 | 1581 | IPython 7.0.0 -- An enhanced Interactive Python. Type '?' for help. |
|
1575 | 1582 | |
|
1576 | 1583 | In [1]: import aiohttp |
|
1577 | 1584 | ...: result = aiohttp.get('https://api.github.com') |
|
1578 | 1585 | |
|
1579 | 1586 | In [2]: response = await result |
|
1580 | 1587 | <pause for a few 100s ms> |
|
1581 | 1588 | |
|
1582 | 1589 | In [3]: await response.json() |
|
1583 | 1590 | Out[3]: |
|
1584 | 1591 | {'authorizations_url': 'https://api.github.com/authorizations', |
|
1585 | 1592 | 'code_search_url': 'https://api.github.com/search/code?q={query}{&page,per_page,sort,order}', |
|
1586 | 1593 | ... |
|
1587 | 1594 | } |
|
1588 | 1595 | |
|
1589 | 1596 | .. note:: |
|
1590 | 1597 | |
|
1591 | 1598 | Async integration is experimental code, behavior may change or be removed |
|
1592 | 1599 | between Python and IPython versions without warnings. |
|
1593 | 1600 | |
|
1594 | 1601 | Integration is by default with `asyncio`, but other libraries can be configured -- |
|
1595 | 1602 | like ``curio`` or ``trio`` -- to improve concurrency in the REPL:: |
|
1596 | 1603 | |
|
1597 | 1604 | In [1]: %autoawait trio |
|
1598 | 1605 | |
|
1599 | 1606 | In [2]: import trio |
|
1600 | 1607 | |
|
1601 | 1608 | In [3]: async def child(i): |
|
1602 | 1609 | ...: print(" child %s goes to sleep"%i) |
|
1603 | 1610 | ...: await trio.sleep(2) |
|
1604 | 1611 | ...: print(" child %s wakes up"%i) |
|
1605 | 1612 | |
|
1606 | 1613 | In [4]: print('parent start') |
|
1607 | 1614 | ...: async with trio.open_nursery() as n: |
|
1608 | 1615 | ...: for i in range(3): |
|
1609 | 1616 | ...: n.spawn(child, i) |
|
1610 | 1617 | ...: print('parent end') |
|
1611 | 1618 | parent start |
|
1612 | 1619 | child 2 goes to sleep |
|
1613 | 1620 | child 0 goes to sleep |
|
1614 | 1621 | child 1 goes to sleep |
|
1615 | 1622 | <about 2 seconds pause> |
|
1616 | 1623 | child 2 wakes up |
|
1617 | 1624 | child 1 wakes up |
|
1618 | 1625 | child 0 wakes up |
|
1619 | 1626 | parent end |
|
1620 | 1627 | |
|
1621 | 1628 | See :ref:`autoawait` for more information. |
|
1622 | 1629 | |
|
1623 | 1630 | |
|
1624 | 1631 | Asynchronous code in a Notebook interface or any other frontend using the |
|
1625 | 1632 | Jupyter Protocol will require further updates to the IPykernel package. |
|
1626 | 1633 | |
|
1627 | 1634 | Non-Asynchronous code |
|
1628 | 1635 | ~~~~~~~~~~~~~~~~~~~~~ |
|
1629 | 1636 | |
|
1630 | 1637 | As the internal API of IPython is now asynchronous, IPython needs to run under |
|
1631 | 1638 | an event loop. In order to allow many workflows, (like using the :magic:`%run` |
|
1632 | 1639 | magic, or copy-pasting code that explicitly starts/stop event loop), when |
|
1633 | 1640 | top-level code is detected as not being asynchronous, IPython code is advanced |
|
1634 | 1641 | via a pseudo-synchronous runner, and may not advance pending tasks. |
|
1635 | 1642 | |
|
1636 | 1643 | Change to Nested Embed |
|
1637 | 1644 | ~~~~~~~~~~~~~~~~~~~~~~ |
|
1638 | 1645 | |
|
1639 | 1646 | The introduction of the ability to run async code had some effect on the |
|
1640 | 1647 | ``IPython.embed()`` API. By default, embed will not allow you to run asynchronous |
|
1641 | 1648 | code unless an event loop is specified. |
|
1642 | 1649 | |
|
1643 | 1650 | Effects on Magics |
|
1644 | 1651 | ~~~~~~~~~~~~~~~~~ |
|
1645 | 1652 | |
|
1646 | 1653 | Some magics will not work with async until they're updated. |
|
1647 | 1654 | Contributions welcome. |
|
1648 | 1655 | |
|
1649 | 1656 | Expected Future changes |
|
1650 | 1657 | ~~~~~~~~~~~~~~~~~~~~~~~ |
|
1651 | 1658 | |
|
1652 | 1659 | We expect more internal but public IPython functions to become ``async``, and |
|
1653 | 1660 | will likely end up having a persistent event loop while IPython is running. |
|
1654 | 1661 | |
|
1655 | 1662 | Thanks |
|
1656 | 1663 | ~~~~~~ |
|
1657 | 1664 | |
|
1658 | 1665 | This release took more than a year in the making. |
|
1659 | 1666 | The code was rebased a number of |
|
1660 | 1667 | times; leading to commit authorship that may have been lost in the final |
|
1661 | 1668 | Pull-Request. Huge thanks to many people for contribution, discussion, code, |
|
1662 | 1669 | documentation, use-cases: dalejung, danielballan, ellisonbg, fperez, gnestor, |
|
1663 | 1670 | minrk, njsmith, pganssle, tacaswell, takluyver , vidartf ... And many others. |
|
1664 | 1671 | |
|
1665 | 1672 | |
|
1666 | 1673 | Autoreload Improvement |
|
1667 | 1674 | ---------------------- |
|
1668 | 1675 | |
|
1669 | 1676 | The magic :magic:`%autoreload 2 <autoreload>` now captures new methods added to |
|
1670 | 1677 | classes. Earlier, only methods existing as of the initial import were being |
|
1671 | 1678 | tracked and updated. |
|
1672 | 1679 | |
|
1673 | 1680 | This new feature helps dual environment development - Jupyter+IDE - where the |
|
1674 | 1681 | code gradually moves from notebook cells to package files as it gets |
|
1675 | 1682 | structured. |
|
1676 | 1683 | |
|
1677 | 1684 | **Example**: An instance of the class ``MyClass`` will be able to access the |
|
1678 | 1685 | method ``cube()`` after it is uncommented and the file ``file1.py`` is saved on |
|
1679 | 1686 | disk. |
|
1680 | 1687 | |
|
1681 | 1688 | |
|
1682 | 1689 | .. code:: |
|
1683 | 1690 | |
|
1684 | 1691 | # notebook |
|
1685 | 1692 | |
|
1686 | 1693 | from mymodule import MyClass |
|
1687 | 1694 | first = MyClass(5) |
|
1688 | 1695 | |
|
1689 | 1696 | .. code:: |
|
1690 | 1697 | |
|
1691 | 1698 | # mymodule/file1.py |
|
1692 | 1699 | |
|
1693 | 1700 | class MyClass: |
|
1694 | 1701 | |
|
1695 | 1702 | def __init__(self, a=10): |
|
1696 | 1703 | self.a = a |
|
1697 | 1704 | |
|
1698 | 1705 | def square(self): |
|
1699 | 1706 | print('compute square') |
|
1700 | 1707 | return self.a*self.a |
|
1701 | 1708 | |
|
1702 | 1709 | # def cube(self): |
|
1703 | 1710 | # print('compute cube') |
|
1704 | 1711 | # return self.a*self.a*self.a |
|
1705 | 1712 | |
|
1706 | 1713 | |
|
1707 | 1714 | |
|
1708 | 1715 | |
|
1709 | 1716 | Misc |
|
1710 | 1717 | ---- |
|
1711 | 1718 | |
|
1712 | 1719 | The autoindent feature that was deprecated in 5.x was re-enabled and |
|
1713 | 1720 | un-deprecated in :ghpull:`11257` |
|
1714 | 1721 | |
|
1715 | 1722 | Make :magic:`%run -n -i ... <run>` work correctly. Earlier, if :magic:`%run` was |
|
1716 | 1723 | passed both arguments, ``-n`` would be silently ignored. See :ghpull:`10308` |
|
1717 | 1724 | |
|
1718 | 1725 | |
|
1719 | 1726 | The :cellmagic:`%%script` (as well as :cellmagic:`%%bash`, |
|
1720 | 1727 | :cellmagic:`%%ruby`... ) cell magics now raise by default if the return code of |
|
1721 | 1728 | the given code is non-zero (thus halting execution of further cells in a |
|
1722 | 1729 | notebook). The behavior can be disable by passing the ``--no-raise-error`` flag. |
|
1723 | 1730 | |
|
1724 | 1731 | |
|
1725 | 1732 | Deprecations |
|
1726 | 1733 | ------------ |
|
1727 | 1734 | |
|
1728 | 1735 | A couple of unused functions and methods have been deprecated and will be removed |
|
1729 | 1736 | in future versions: |
|
1730 | 1737 | |
|
1731 | 1738 | - ``IPython.utils.io.raw_print_err`` |
|
1732 | 1739 | - ``IPython.utils.io.raw_print`` |
|
1733 | 1740 | |
|
1734 | 1741 | |
|
1735 | 1742 | Backwards incompatible changes |
|
1736 | 1743 | ------------------------------ |
|
1737 | 1744 | |
|
1738 | 1745 | * The API for transforming input before it is parsed as Python code has been |
|
1739 | 1746 | completely redesigned: any custom input transformations will need to be |
|
1740 | 1747 | 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