Show More
@@ -1,85 +1,86 b'' | |||
|
1 | 1 | # encoding: utf-8 |
|
2 | 2 | """ |
|
3 | 3 | IPython: tools for interactive and parallel computing in Python. |
|
4 | 4 | |
|
5 | 5 | http://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 | from __future__ import absolute_import |
|
22 | 22 | |
|
23 | 23 | import os |
|
24 | 24 | import sys |
|
25 | 25 | |
|
26 | 26 | #----------------------------------------------------------------------------- |
|
27 | 27 | # Setup everything |
|
28 | 28 | #----------------------------------------------------------------------------- |
|
29 | 29 | |
|
30 | 30 | # Don't forget to also update setup.py when this changes! |
|
31 | 31 | if sys.version[0:3] < '2.6': |
|
32 | 32 | raise ImportError('Python Version 2.6 or above is required for IPython.') |
|
33 | 33 | |
|
34 | 34 | # Make it easy to import extensions - they are always directly on pythonpath. |
|
35 | 35 | # Therefore, non-IPython modules can be added to extensions directory. |
|
36 | 36 | # This should probably be in ipapp.py. |
|
37 | 37 | sys.path.append(os.path.join(os.path.dirname(__file__), "extensions")) |
|
38 | 38 | |
|
39 | 39 | #----------------------------------------------------------------------------- |
|
40 | 40 | # Setup the top level names |
|
41 | 41 | #----------------------------------------------------------------------------- |
|
42 | 42 | |
|
43 | 43 | from .config.loader import Config |
|
44 | from .core.ipapi import get_ipython | |
|
44 | 45 | from .core import release |
|
45 | 46 | from .core.application import Application |
|
46 | 47 | from .frontend.terminal.embed import embed |
|
47 | 48 | |
|
48 | 49 | from .core.error import TryNext |
|
49 | 50 | from .core.interactiveshell import InteractiveShell |
|
50 | 51 | from .testing import test |
|
51 | 52 | from .utils.sysinfo import sys_info |
|
52 | 53 | from .utils.frame import extract_module_locals |
|
53 | 54 | |
|
54 | 55 | # Release data |
|
55 | 56 | __author__ = '%s <%s>' % (release.author, release.author_email) |
|
56 | 57 | __license__ = release.license |
|
57 | 58 | __version__ = release.version |
|
58 | 59 | version_info = release.version_info |
|
59 | 60 | |
|
60 | 61 | def embed_kernel(module=None, local_ns=None, **kwargs): |
|
61 | 62 | """Embed and start an IPython kernel in a given scope. |
|
62 | 63 | |
|
63 | 64 | Parameters |
|
64 | 65 | ---------- |
|
65 | 66 | module : ModuleType, optional |
|
66 | 67 | The module to load into IPython globals (default: caller) |
|
67 | 68 | local_ns : dict, optional |
|
68 | 69 | The namespace to load into IPython user namespace (default: caller) |
|
69 | 70 | |
|
70 | 71 | kwargs : various, optional |
|
71 | 72 | Further keyword args are relayed to the IPKernelApp constructor, |
|
72 | 73 | allowing configuration of the Kernel. Will only have an effect |
|
73 | 74 | on the first embed_kernel call for a given process. |
|
74 | 75 | |
|
75 | 76 | """ |
|
76 | 77 | |
|
77 | 78 | (caller_module, caller_locals) = extract_module_locals(1) |
|
78 | 79 | if module is None: |
|
79 | 80 | module = caller_module |
|
80 | 81 | if local_ns is None: |
|
81 | 82 | local_ns = caller_locals |
|
82 | 83 | |
|
83 | 84 | # Only import .zmq when we really need it |
|
84 | 85 | from IPython.kernel.zmq.embed import embed_kernel as real_embed_kernel |
|
85 | 86 | real_embed_kernel(module=module, local_ns=local_ns, **kwargs) |
@@ -1,29 +1,37 b'' | |||
|
1 | 1 | # encoding: utf-8 |
|
2 | """ | |
|
3 | This module is *completely* deprecated and should no longer be used for | |
|
4 | any purpose. Currently, we have a few parts of the core that have | |
|
5 | not been componentized and thus, still rely on this module. When everything | |
|
6 | has been made into a component, this module will be sent to deathrow. | |
|
2 | """Simple function to call to get the current InteractiveShell instance | |
|
7 | 3 | """ |
|
8 | 4 | |
|
9 | 5 | #----------------------------------------------------------------------------- |
|
10 |
# Copyright (C) 20 |
|
|
6 | # Copyright (C) 2013 The IPython Development Team | |
|
11 | 7 | # |
|
12 | 8 | # Distributed under the terms of the BSD License. The full license is in |
|
13 | 9 | # the file COPYING, distributed as part of this software. |
|
14 | 10 | #----------------------------------------------------------------------------- |
|
15 | 11 | |
|
16 | 12 | #----------------------------------------------------------------------------- |
|
17 | 13 | # Imports |
|
18 | 14 | #----------------------------------------------------------------------------- |
|
19 | 15 | |
|
16 | import warnings | |
|
17 | ||
|
20 | 18 | #----------------------------------------------------------------------------- |
|
21 | 19 | # Classes and functions |
|
22 | 20 | #----------------------------------------------------------------------------- |
|
23 | 21 | |
|
24 | 22 | |
|
25 | def get(): | |
|
26 |
"""Get the global InteractiveShell instance. |
|
|
23 | def get_ipython(): | |
|
24 | """Get the global InteractiveShell instance. | |
|
25 | ||
|
26 | Returns None if no InteractiveShell instance is registered. | |
|
27 | """ | |
|
27 | 28 | from IPython.core.interactiveshell import InteractiveShell |
|
28 |
|
|
|
29 | if InteractiveShell.initialized(): | |
|
30 | return InteractiveShell.instance() | |
|
31 | ||
|
32 | def get(): | |
|
33 | warnings.warn("ipapi.get has been deprecated since IPython 0.11", | |
|
34 | DeprecationWarning | |
|
35 | ) | |
|
36 | return get_ipython() | |
|
29 | 37 |
General Comments 0
You need to be logged in to leave comments.
Login now