Show More
@@ -0,0 +1,2 b'' | |||||
|
1 | - :meth:`~.KernelManager.start_kernel` and :meth:`~.KernelManager.format_kernel_cmd` | |||
|
2 | no longer accept a ``executable`` parameter. Use the kernelspec machinery instead. |
@@ -9,6 +9,7 b' pjoin = os.path.join' | |||||
9 | from IPython.utils.path import get_ipython_dir |
|
9 | from IPython.utils.path import get_ipython_dir | |
10 | from IPython.utils.py3compat import PY3 |
|
10 | from IPython.utils.py3compat import PY3 | |
11 | from IPython.utils.traitlets import HasTraits, List, Unicode, Dict, Any |
|
11 | from IPython.utils.traitlets import HasTraits, List, Unicode, Dict, Any | |
|
12 | from .launcher import make_ipkernel_cmd | |||
12 |
|
13 | |||
13 | if os.name == 'nt': |
|
14 | if os.name == 'nt': | |
14 | programdata = os.environ.get('PROGRAMDATA', None) |
|
15 | programdata = os.environ.get('PROGRAMDATA', None) | |
@@ -107,9 +108,8 b' class KernelSpecManager(HasTraits):' | |||||
107 | The native kernel is the kernel using the same Python runtime as this |
|
108 | The native kernel is the kernel using the same Python runtime as this | |
108 | process. This will put its informatino in the user kernels directory. |
|
109 | process. This will put its informatino in the user kernels directory. | |
109 | """ |
|
110 | """ | |
110 |
return {'argv': |
|
111 | return {'argv':make_ipkernel_cmd( | |
111 | 'from IPython.kernel.zmq.kernelapp import main; main()', |
|
112 | 'from IPython.kernel.zmq.kernelapp import main; main()'), | |
112 | '-f', '{connection_file}'], |
|
|||
113 | 'display_name': 'IPython (Python %d)' % (3 if PY3 else 2), |
|
113 | 'display_name': 'IPython (Python %d)' % (3 if PY3 else 2), | |
114 | 'language': 'python', |
|
114 | 'language': 'python', | |
115 | 'codemirror_mode': {'name': 'ipython', |
|
115 | 'codemirror_mode': {'name': 'ipython', |
@@ -97,14 +97,11 b' def make_ipkernel_cmd(code, executable=None, extra_arguments=[], **kw):' | |||||
97 |
|
97 | |||
98 | A Popen command list |
|
98 | A Popen command list | |
99 | """ |
|
99 | """ | |
100 |
|
||||
101 | # Build the kernel launch command. |
|
|||
102 | if executable is None: |
|
100 | if executable is None: | |
103 | executable = sys.executable |
|
101 | executable = sys.executable | |
104 | arguments = [ executable, '-c', code, '-f', '{connection_file}' ] |
|
102 | arguments = [ executable, '-c', code, '-f', '{connection_file}' ] | |
105 | arguments.extend(extra_arguments) |
|
103 | arguments.extend(extra_arguments) | |
106 |
|
104 | |||
107 | # Spawn a kernel. |
|
|||
108 | if sys.platform == 'win32': |
|
105 | if sys.platform == 'win32': | |
109 |
|
106 | |||
110 | # If the kernel is running on pythonw and stdout/stderr are not been |
|
107 | # If the kernel is running on pythonw and stdout/stderr are not been |
@@ -159,18 +159,13 b' class KernelManager(ConnectionFileMixin):' | |||||
159 | # Kernel management |
|
159 | # Kernel management | |
160 | #-------------------------------------------------------------------------- |
|
160 | #-------------------------------------------------------------------------- | |
161 |
|
161 | |||
162 |
def format_kernel_cmd(self, |
|
162 | def format_kernel_cmd(self, extra_arguments=None): | |
163 | """replace templated args (e.g. {connection_file})""" |
|
163 | """replace templated args (e.g. {connection_file})""" | |
|
164 | extra_arguments = extra_arguments or [] | |||
164 | if self.kernel_cmd: |
|
165 | if self.kernel_cmd: | |
165 | cmd = self.kernel_cmd |
|
166 | cmd = self.kernel_cmd + extra_arguments | |
166 | elif self.kernel_name == kernelspec.NATIVE_KERNEL_NAME: |
|
|||
167 | # The native kernel gets special handling |
|
|||
168 | cmd = make_ipkernel_cmd( |
|
|||
169 | 'from IPython.kernel.zmq.kernelapp import main; main()', |
|
|||
170 | **kw |
|
|||
171 | ) |
|
|||
172 | else: |
|
167 | else: | |
173 | cmd = self.kernel_spec.argv |
|
168 | cmd = self.kernel_spec.argv + extra_arguments | |
174 |
|
169 | |||
175 | ns = dict(connection_file=self.connection_file) |
|
170 | ns = dict(connection_file=self.connection_file) | |
176 | ns.update(self._launch_args) |
|
171 | ns.update(self._launch_args) | |
@@ -227,7 +222,8 b' class KernelManager(ConnectionFileMixin):' | |||||
227 | # save kwargs for use in restart |
|
222 | # save kwargs for use in restart | |
228 | self._launch_args = kw.copy() |
|
223 | self._launch_args = kw.copy() | |
229 | # build the Popen cmd |
|
224 | # build the Popen cmd | |
230 | kernel_cmd = self.format_kernel_cmd(**kw) |
|
225 | extra_arguments = kw.pop('extra_arguments', []) | |
|
226 | kernel_cmd = self.format_kernel_cmd(extra_arguments=extra_arguments) | |||
231 | if self.kernel_cmd: |
|
227 | if self.kernel_cmd: | |
232 | # If kernel_cmd has been set manually, don't refer to a kernel spec |
|
228 | # If kernel_cmd has been set manually, don't refer to a kernel spec | |
233 | env = os.environ |
|
229 | env = os.environ |
General Comments 0
You need to be logged in to leave comments.
Login now