Show More
@@ -100,6 +100,8 b' def get_kernel_spec(kernel_name):' | |||||
100 |
|
100 | |||
101 | Raises KeyError if the given kernel name is not found. |
|
101 | Raises KeyError if the given kernel name is not found. | |
102 | """ |
|
102 | """ | |
|
103 | if kernel_name == 'native': | |||
|
104 | kernel_name = NATIVE_KERNEL_NAME | |||
103 | d = list_kernel_specs() |
|
105 | d = list_kernel_specs() | |
104 | resource_dir = d[kernel_name.lower()] |
|
106 | resource_dir = d[kernel_name.lower()] | |
105 | return KernelSpec.from_resource_dir(resource_dir) No newline at end of file |
|
107 | return KernelSpec.from_resource_dir(resource_dir) |
@@ -18,6 +18,7 b' import re' | |||||
18 | import signal |
|
18 | import signal | |
19 | import sys |
|
19 | import sys | |
20 | import time |
|
20 | import time | |
|
21 | import warnings | |||
21 |
|
22 | |||
22 | import zmq |
|
23 | import zmq | |
23 |
|
24 | |||
@@ -31,6 +32,7 b' from IPython.utils.traitlets import (' | |||||
31 | from IPython.kernel import ( |
|
32 | from IPython.kernel import ( | |
32 | make_ipkernel_cmd, |
|
33 | make_ipkernel_cmd, | |
33 | launch_kernel, |
|
34 | launch_kernel, | |
|
35 | kernelspec, | |||
34 | ) |
|
36 | ) | |
35 | from .connect import ConnectionFileMixin |
|
37 | from .connect import ConnectionFileMixin | |
36 | from .zmq.session import Session |
|
38 | from .zmq.session import Session | |
@@ -67,9 +69,22 b' class KernelManager(LoggingConfigurable, ConnectionFileMixin):' | |||||
67 | # The kernel process with which the KernelManager is communicating. |
|
69 | # The kernel process with which the KernelManager is communicating. | |
68 | # generally a Popen instance |
|
70 | # generally a Popen instance | |
69 | kernel = Any() |
|
71 | kernel = Any() | |
|
72 | ||||
|
73 | kernel_name = Unicode('native') | |||
|
74 | ||||
|
75 | kernel_spec = Instance(kernelspec.KernelSpec) | |||
|
76 | ||||
|
77 | def _kernel_spec_default(self): | |||
|
78 | return kernelspec.get_kernel_spec(self.kernel_name) | |||
|
79 | ||||
|
80 | def _kernel_name_changed(self, name, old, new): | |||
|
81 | self.kernel_spec = kernelspec.get_kernel_spec(new) | |||
|
82 | self.ipython_kernel = new in {'native', 'python2', 'python3'} | |||
70 |
|
83 | |||
71 | kernel_cmd = List(Unicode, config=True, |
|
84 | kernel_cmd = List(Unicode, config=True, | |
72 | help="""The Popen Command to launch the kernel. |
|
85 | help="""DEPRECATED: Use kernel_name instead. | |
|
86 | ||||
|
87 | The Popen Command to launch the kernel. | |||
73 | Override this if you have a custom kernel. |
|
88 | Override this if you have a custom kernel. | |
74 | If kernel_cmd is specified in a configuration file, |
|
89 | If kernel_cmd is specified in a configuration file, | |
75 | IPython does not pass any arguments to the kernel, |
|
90 | IPython does not pass any arguments to the kernel, | |
@@ -81,6 +96,8 b' class KernelManager(LoggingConfigurable, ConnectionFileMixin):' | |||||
81 | ) |
|
96 | ) | |
82 |
|
97 | |||
83 | def _kernel_cmd_changed(self, name, old, new): |
|
98 | def _kernel_cmd_changed(self, name, old, new): | |
|
99 | warnings.warn("Setting kernel_cmd is deprecated, use kernel_spec to " | |||
|
100 | "start different kernels.") | |||
84 | self.ipython_kernel = False |
|
101 | self.ipython_kernel = False | |
85 |
|
102 | |||
86 | ipython_kernel = Bool(True) |
|
103 | ipython_kernel = Bool(True) | |
@@ -150,11 +167,15 b' class KernelManager(LoggingConfigurable, ConnectionFileMixin):' | |||||
150 | """replace templated args (e.g. {connection_file})""" |
|
167 | """replace templated args (e.g. {connection_file})""" | |
151 | if self.kernel_cmd: |
|
168 | if self.kernel_cmd: | |
152 | cmd = self.kernel_cmd |
|
169 | cmd = self.kernel_cmd | |
153 | else: |
|
170 | elif self.kernel_name == 'native': | |
|
171 | # The native kernel gets special handling | |||
154 | cmd = make_ipkernel_cmd( |
|
172 | cmd = make_ipkernel_cmd( | |
155 | 'from IPython.kernel.zmq.kernelapp import main; main()', |
|
173 | 'from IPython.kernel.zmq.kernelapp import main; main()', | |
156 | **kw |
|
174 | **kw | |
157 | ) |
|
175 | ) | |
|
176 | else: | |||
|
177 | cmd = self.kernel_spec.argv | |||
|
178 | ||||
158 | ns = dict(connection_file=self.connection_file) |
|
179 | ns = dict(connection_file=self.connection_file) | |
159 | ns.update(self._launch_args) |
|
180 | ns.update(self._launch_args) | |
160 |
|
181 |
General Comments 0
You need to be logged in to leave comments.
Login now