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