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