Show More
@@ -1,155 +1,156 b'' | |||||
|
1 | # PYTHON_ARGCOMPLETE_OK | |||
1 | """ |
|
2 | """ | |
2 | IPython: tools for interactive and parallel computing in Python. |
|
3 | IPython: tools for interactive and parallel computing in Python. | |
3 |
|
4 | |||
4 | https://ipython.org |
|
5 | https://ipython.org | |
5 | """ |
|
6 | """ | |
6 | #----------------------------------------------------------------------------- |
|
7 | #----------------------------------------------------------------------------- | |
7 | # Copyright (c) 2008-2011, IPython Development Team. |
|
8 | # Copyright (c) 2008-2011, IPython Development Team. | |
8 | # Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.edu> |
|
9 | # Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.edu> | |
9 | # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de> |
|
10 | # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de> | |
10 | # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu> |
|
11 | # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu> | |
11 | # |
|
12 | # | |
12 | # Distributed under the terms of the Modified BSD License. |
|
13 | # Distributed under the terms of the Modified BSD License. | |
13 | # |
|
14 | # | |
14 | # The full license is in the file COPYING.txt, distributed with this software. |
|
15 | # The full license is in the file COPYING.txt, distributed with this software. | |
15 | #----------------------------------------------------------------------------- |
|
16 | #----------------------------------------------------------------------------- | |
16 |
|
17 | |||
17 | #----------------------------------------------------------------------------- |
|
18 | #----------------------------------------------------------------------------- | |
18 | # Imports |
|
19 | # Imports | |
19 | #----------------------------------------------------------------------------- |
|
20 | #----------------------------------------------------------------------------- | |
20 |
|
21 | |||
21 | import sys |
|
22 | import sys | |
22 |
|
23 | |||
23 | #----------------------------------------------------------------------------- |
|
24 | #----------------------------------------------------------------------------- | |
24 | # Setup everything |
|
25 | # Setup everything | |
25 | #----------------------------------------------------------------------------- |
|
26 | #----------------------------------------------------------------------------- | |
26 |
|
27 | |||
27 | # Don't forget to also update setup.py when this changes! |
|
28 | # Don't forget to also update setup.py when this changes! | |
28 | if sys.version_info < (3, 8): |
|
29 | if sys.version_info < (3, 8): | |
29 | raise ImportError( |
|
30 | raise ImportError( | |
30 | """ |
|
31 | """ | |
31 | IPython 8+ supports Python 3.8 and above, following NEP 29. |
|
32 | IPython 8+ supports Python 3.8 and above, following NEP 29. | |
32 | When using Python 2.7, please install IPython 5.x LTS Long Term Support version. |
|
33 | When using Python 2.7, please install IPython 5.x LTS Long Term Support version. | |
33 | Python 3.3 and 3.4 were supported up to IPython 6.x. |
|
34 | Python 3.3 and 3.4 were supported up to IPython 6.x. | |
34 | Python 3.5 was supported with IPython 7.0 to 7.9. |
|
35 | Python 3.5 was supported with IPython 7.0 to 7.9. | |
35 | Python 3.6 was supported with IPython up to 7.16. |
|
36 | Python 3.6 was supported with IPython up to 7.16. | |
36 | Python 3.7 was still supported with the 7.x branch. |
|
37 | Python 3.7 was still supported with the 7.x branch. | |
37 |
|
38 | |||
38 | See IPython `README.rst` file for more information: |
|
39 | See IPython `README.rst` file for more information: | |
39 |
|
40 | |||
40 | https://github.com/ipython/ipython/blob/main/README.rst |
|
41 | https://github.com/ipython/ipython/blob/main/README.rst | |
41 |
|
42 | |||
42 | """ |
|
43 | """ | |
43 | ) |
|
44 | ) | |
44 |
|
45 | |||
45 | #----------------------------------------------------------------------------- |
|
46 | #----------------------------------------------------------------------------- | |
46 | # Setup the top level names |
|
47 | # Setup the top level names | |
47 | #----------------------------------------------------------------------------- |
|
48 | #----------------------------------------------------------------------------- | |
48 |
|
49 | |||
49 | from .core.getipython import get_ipython |
|
50 | from .core.getipython import get_ipython | |
50 | from .core import release |
|
51 | from .core import release | |
51 | from .core.application import Application |
|
52 | from .core.application import Application | |
52 | from .terminal.embed import embed |
|
53 | from .terminal.embed import embed | |
53 |
|
54 | |||
54 | from .core.interactiveshell import InteractiveShell |
|
55 | from .core.interactiveshell import InteractiveShell | |
55 | from .utils.sysinfo import sys_info |
|
56 | from .utils.sysinfo import sys_info | |
56 | from .utils.frame import extract_module_locals |
|
57 | from .utils.frame import extract_module_locals | |
57 |
|
58 | |||
58 | # Release data |
|
59 | # Release data | |
59 | __author__ = '%s <%s>' % (release.author, release.author_email) |
|
60 | __author__ = '%s <%s>' % (release.author, release.author_email) | |
60 | __license__ = release.license |
|
61 | __license__ = release.license | |
61 | __version__ = release.version |
|
62 | __version__ = release.version | |
62 | version_info = release.version_info |
|
63 | version_info = release.version_info | |
63 | # list of CVEs that should have been patched in this release. |
|
64 | # list of CVEs that should have been patched in this release. | |
64 | # this is informational and should not be relied upon. |
|
65 | # this is informational and should not be relied upon. | |
65 | __patched_cves__ = {"CVE-2022-21699"} |
|
66 | __patched_cves__ = {"CVE-2022-21699"} | |
66 |
|
67 | |||
67 |
|
68 | |||
68 | def embed_kernel(module=None, local_ns=None, **kwargs): |
|
69 | def embed_kernel(module=None, local_ns=None, **kwargs): | |
69 | """Embed and start an IPython kernel in a given scope. |
|
70 | """Embed and start an IPython kernel in a given scope. | |
70 |
|
71 | |||
71 | If you don't want the kernel to initialize the namespace |
|
72 | If you don't want the kernel to initialize the namespace | |
72 | from the scope of the surrounding function, |
|
73 | from the scope of the surrounding function, | |
73 | and/or you want to load full IPython configuration, |
|
74 | and/or you want to load full IPython configuration, | |
74 | you probably want `IPython.start_kernel()` instead. |
|
75 | you probably want `IPython.start_kernel()` instead. | |
75 |
|
76 | |||
76 | Parameters |
|
77 | Parameters | |
77 | ---------- |
|
78 | ---------- | |
78 | module : types.ModuleType, optional |
|
79 | module : types.ModuleType, optional | |
79 | The module to load into IPython globals (default: caller) |
|
80 | The module to load into IPython globals (default: caller) | |
80 | local_ns : dict, optional |
|
81 | local_ns : dict, optional | |
81 | The namespace to load into IPython user namespace (default: caller) |
|
82 | The namespace to load into IPython user namespace (default: caller) | |
82 | **kwargs : various, optional |
|
83 | **kwargs : various, optional | |
83 | Further keyword args are relayed to the IPKernelApp constructor, |
|
84 | Further keyword args are relayed to the IPKernelApp constructor, | |
84 | allowing configuration of the Kernel. Will only have an effect |
|
85 | allowing configuration of the Kernel. Will only have an effect | |
85 | on the first embed_kernel call for a given process. |
|
86 | on the first embed_kernel call for a given process. | |
86 | """ |
|
87 | """ | |
87 |
|
88 | |||
88 | (caller_module, caller_locals) = extract_module_locals(1) |
|
89 | (caller_module, caller_locals) = extract_module_locals(1) | |
89 | if module is None: |
|
90 | if module is None: | |
90 | module = caller_module |
|
91 | module = caller_module | |
91 | if local_ns is None: |
|
92 | if local_ns is None: | |
92 | local_ns = caller_locals |
|
93 | local_ns = caller_locals | |
93 |
|
94 | |||
94 | # Only import .zmq when we really need it |
|
95 | # Only import .zmq when we really need it | |
95 | from ipykernel.embed import embed_kernel as real_embed_kernel |
|
96 | from ipykernel.embed import embed_kernel as real_embed_kernel | |
96 | real_embed_kernel(module=module, local_ns=local_ns, **kwargs) |
|
97 | real_embed_kernel(module=module, local_ns=local_ns, **kwargs) | |
97 |
|
98 | |||
98 | def start_ipython(argv=None, **kwargs): |
|
99 | def start_ipython(argv=None, **kwargs): | |
99 | """Launch a normal IPython instance (as opposed to embedded) |
|
100 | """Launch a normal IPython instance (as opposed to embedded) | |
100 |
|
101 | |||
101 | `IPython.embed()` puts a shell in a particular calling scope, |
|
102 | `IPython.embed()` puts a shell in a particular calling scope, | |
102 | such as a function or method for debugging purposes, |
|
103 | such as a function or method for debugging purposes, | |
103 | which is often not desirable. |
|
104 | which is often not desirable. | |
104 |
|
105 | |||
105 | `start_ipython()` does full, regular IPython initialization, |
|
106 | `start_ipython()` does full, regular IPython initialization, | |
106 | including loading startup files, configuration, etc. |
|
107 | including loading startup files, configuration, etc. | |
107 | much of which is skipped by `embed()`. |
|
108 | much of which is skipped by `embed()`. | |
108 |
|
109 | |||
109 | This is a public API method, and will survive implementation changes. |
|
110 | This is a public API method, and will survive implementation changes. | |
110 |
|
111 | |||
111 | Parameters |
|
112 | Parameters | |
112 | ---------- |
|
113 | ---------- | |
113 | argv : list or None, optional |
|
114 | argv : list or None, optional | |
114 | If unspecified or None, IPython will parse command-line options from sys.argv. |
|
115 | If unspecified or None, IPython will parse command-line options from sys.argv. | |
115 | To prevent any command-line parsing, pass an empty list: `argv=[]`. |
|
116 | To prevent any command-line parsing, pass an empty list: `argv=[]`. | |
116 | user_ns : dict, optional |
|
117 | user_ns : dict, optional | |
117 | specify this dictionary to initialize the IPython user namespace with particular values. |
|
118 | specify this dictionary to initialize the IPython user namespace with particular values. | |
118 | **kwargs : various, optional |
|
119 | **kwargs : various, optional | |
119 | Any other kwargs will be passed to the Application constructor, |
|
120 | Any other kwargs will be passed to the Application constructor, | |
120 | such as `config`. |
|
121 | such as `config`. | |
121 | """ |
|
122 | """ | |
122 | from IPython.terminal.ipapp import launch_new_instance |
|
123 | from IPython.terminal.ipapp import launch_new_instance | |
123 | return launch_new_instance(argv=argv, **kwargs) |
|
124 | return launch_new_instance(argv=argv, **kwargs) | |
124 |
|
125 | |||
125 | def start_kernel(argv=None, **kwargs): |
|
126 | def start_kernel(argv=None, **kwargs): | |
126 | """Launch a normal IPython kernel instance (as opposed to embedded) |
|
127 | """Launch a normal IPython kernel instance (as opposed to embedded) | |
127 |
|
128 | |||
128 | `IPython.embed_kernel()` puts a shell in a particular calling scope, |
|
129 | `IPython.embed_kernel()` puts a shell in a particular calling scope, | |
129 | such as a function or method for debugging purposes, |
|
130 | such as a function or method for debugging purposes, | |
130 | which is often not desirable. |
|
131 | which is often not desirable. | |
131 |
|
132 | |||
132 | `start_kernel()` does full, regular IPython initialization, |
|
133 | `start_kernel()` does full, regular IPython initialization, | |
133 | including loading startup files, configuration, etc. |
|
134 | including loading startup files, configuration, etc. | |
134 | much of which is skipped by `embed()`. |
|
135 | much of which is skipped by `embed()`. | |
135 |
|
136 | |||
136 | Parameters |
|
137 | Parameters | |
137 | ---------- |
|
138 | ---------- | |
138 | argv : list or None, optional |
|
139 | argv : list or None, optional | |
139 | If unspecified or None, IPython will parse command-line options from sys.argv. |
|
140 | If unspecified or None, IPython will parse command-line options from sys.argv. | |
140 | To prevent any command-line parsing, pass an empty list: `argv=[]`. |
|
141 | To prevent any command-line parsing, pass an empty list: `argv=[]`. | |
141 | user_ns : dict, optional |
|
142 | user_ns : dict, optional | |
142 | specify this dictionary to initialize the IPython user namespace with particular values. |
|
143 | specify this dictionary to initialize the IPython user namespace with particular values. | |
143 | **kwargs : various, optional |
|
144 | **kwargs : various, optional | |
144 | Any other kwargs will be passed to the Application constructor, |
|
145 | Any other kwargs will be passed to the Application constructor, | |
145 | such as `config`. |
|
146 | such as `config`. | |
146 | """ |
|
147 | """ | |
147 | import warnings |
|
148 | import warnings | |
148 |
|
149 | |||
149 | warnings.warn( |
|
150 | warnings.warn( | |
150 | "start_kernel is deprecated since IPython 8.0, use from `ipykernel.kernelapp.launch_new_instance`", |
|
151 | "start_kernel is deprecated since IPython 8.0, use from `ipykernel.kernelapp.launch_new_instance`", | |
151 | DeprecationWarning, |
|
152 | DeprecationWarning, | |
152 | stacklevel=2, |
|
153 | stacklevel=2, | |
153 | ) |
|
154 | ) | |
154 | from ipykernel.kernelapp import launch_new_instance |
|
155 | from ipykernel.kernelapp import launch_new_instance | |
155 | return launch_new_instance(argv=argv, **kwargs) |
|
156 | return launch_new_instance(argv=argv, **kwargs) |
@@ -1,14 +1,15 b'' | |||||
|
1 | # PYTHON_ARGCOMPLETE_OK | |||
1 | # encoding: utf-8 |
|
2 | # encoding: utf-8 | |
2 | """Terminal-based IPython entry point. |
|
3 | """Terminal-based IPython entry point. | |
3 | """ |
|
4 | """ | |
4 | #----------------------------------------------------------------------------- |
|
5 | #----------------------------------------------------------------------------- | |
5 | # Copyright (c) 2012, IPython Development Team. |
|
6 | # Copyright (c) 2012, IPython Development Team. | |
6 | # |
|
7 | # | |
7 | # Distributed under the terms of the Modified BSD License. |
|
8 | # Distributed under the terms of the Modified BSD License. | |
8 | # |
|
9 | # | |
9 | # The full license is in the file COPYING.txt, distributed with this software. |
|
10 | # The full license is in the file COPYING.txt, distributed with this software. | |
10 | #----------------------------------------------------------------------------- |
|
11 | #----------------------------------------------------------------------------- | |
11 |
|
12 | |||
12 | from IPython import start_ipython |
|
13 | from IPython import start_ipython | |
13 |
|
14 | |||
14 | start_ipython() |
|
15 | start_ipython() |
General Comments 0
You need to be logged in to leave comments.
Login now