Show More
@@ -0,0 +1,12 b'' | |||||
|
1 | """The IPython HTML Notebook""" | |||
|
2 | ||||
|
3 | # check for tornado 2.1.0 | |||
|
4 | msg = "The IPython Notebook requires tornado >= 2.1.0" | |||
|
5 | try: | |||
|
6 | import tornado | |||
|
7 | except ImportError: | |||
|
8 | raise ImportError(msg) | |||
|
9 | else: | |||
|
10 | if tornado.version_info < (2,1,0): | |||
|
11 | raise ImportError(msg+", but you have %s"%tornado.version) | |||
|
12 | del msg |
@@ -1,441 +1,449 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """IPython Test Suite Runner. |
|
2 | """IPython Test Suite Runner. | |
3 |
|
3 | |||
4 | This module provides a main entry point to a user script to test IPython |
|
4 | This module provides a main entry point to a user script to test IPython | |
5 | itself from the command line. There are two ways of running this script: |
|
5 | itself from the command line. There are two ways of running this script: | |
6 |
|
6 | |||
7 | 1. With the syntax `iptest all`. This runs our entire test suite by |
|
7 | 1. With the syntax `iptest all`. This runs our entire test suite by | |
8 | calling this script (with different arguments) recursively. This |
|
8 | calling this script (with different arguments) recursively. This | |
9 | causes modules and package to be tested in different processes, using nose |
|
9 | causes modules and package to be tested in different processes, using nose | |
10 | or trial where appropriate. |
|
10 | or trial where appropriate. | |
11 | 2. With the regular nose syntax, like `iptest -vvs IPython`. In this form |
|
11 | 2. With the regular nose syntax, like `iptest -vvs IPython`. In this form | |
12 | the script simply calls nose, but with special command line flags and |
|
12 | the script simply calls nose, but with special command line flags and | |
13 | plugins loaded. |
|
13 | plugins loaded. | |
14 |
|
14 | |||
15 | """ |
|
15 | """ | |
16 |
|
16 | |||
17 | #----------------------------------------------------------------------------- |
|
17 | #----------------------------------------------------------------------------- | |
18 | # Copyright (C) 2009 The IPython Development Team |
|
18 | # Copyright (C) 2009 The IPython Development Team | |
19 | # |
|
19 | # | |
20 | # Distributed under the terms of the BSD License. The full license is in |
|
20 | # Distributed under the terms of the BSD License. The full license is in | |
21 | # the file COPYING, distributed as part of this software. |
|
21 | # the file COPYING, distributed as part of this software. | |
22 | #----------------------------------------------------------------------------- |
|
22 | #----------------------------------------------------------------------------- | |
23 |
|
23 | |||
24 | #----------------------------------------------------------------------------- |
|
24 | #----------------------------------------------------------------------------- | |
25 | # Imports |
|
25 | # Imports | |
26 | #----------------------------------------------------------------------------- |
|
26 | #----------------------------------------------------------------------------- | |
27 |
|
27 | |||
28 | # Stdlib |
|
28 | # Stdlib | |
29 | import os |
|
29 | import os | |
30 | import os.path as path |
|
30 | import os.path as path | |
31 | import signal |
|
31 | import signal | |
32 | import sys |
|
32 | import sys | |
33 | import subprocess |
|
33 | import subprocess | |
34 | import tempfile |
|
34 | import tempfile | |
35 | import time |
|
35 | import time | |
36 | import warnings |
|
36 | import warnings | |
37 |
|
37 | |||
38 | # Note: monkeypatch! |
|
38 | # Note: monkeypatch! | |
39 | # We need to monkeypatch a small problem in nose itself first, before importing |
|
39 | # We need to monkeypatch a small problem in nose itself first, before importing | |
40 | # it for actual use. This should get into nose upstream, but its release cycle |
|
40 | # it for actual use. This should get into nose upstream, but its release cycle | |
41 | # is slow and we need it for our parametric tests to work correctly. |
|
41 | # is slow and we need it for our parametric tests to work correctly. | |
42 | from IPython.testing import nosepatch |
|
42 | from IPython.testing import nosepatch | |
43 | # Now, proceed to import nose itself |
|
43 | # Now, proceed to import nose itself | |
44 | import nose.plugins.builtin |
|
44 | import nose.plugins.builtin | |
45 | from nose.core import TestProgram |
|
45 | from nose.core import TestProgram | |
46 |
|
46 | |||
47 | # Our own imports |
|
47 | # Our own imports | |
48 | from IPython.utils.path import get_ipython_module_path |
|
48 | from IPython.utils.path import get_ipython_module_path | |
49 | from IPython.utils.process import find_cmd, pycmd2argv |
|
49 | from IPython.utils.process import find_cmd, pycmd2argv | |
50 | from IPython.utils.sysinfo import sys_info |
|
50 | from IPython.utils.sysinfo import sys_info | |
51 |
|
51 | |||
52 | from IPython.testing import globalipapp |
|
52 | from IPython.testing import globalipapp | |
53 | from IPython.testing.plugin.ipdoctest import IPythonDoctest |
|
53 | from IPython.testing.plugin.ipdoctest import IPythonDoctest | |
54 | from IPython.external.decorators import KnownFailure |
|
54 | from IPython.external.decorators import KnownFailure | |
55 |
|
55 | |||
56 | pjoin = path.join |
|
56 | pjoin = path.join | |
57 |
|
57 | |||
58 |
|
58 | |||
59 | #----------------------------------------------------------------------------- |
|
59 | #----------------------------------------------------------------------------- | |
60 | # Globals |
|
60 | # Globals | |
61 | #----------------------------------------------------------------------------- |
|
61 | #----------------------------------------------------------------------------- | |
62 |
|
62 | |||
63 |
|
63 | |||
64 | #----------------------------------------------------------------------------- |
|
64 | #----------------------------------------------------------------------------- | |
65 | # Warnings control |
|
65 | # Warnings control | |
66 | #----------------------------------------------------------------------------- |
|
66 | #----------------------------------------------------------------------------- | |
67 |
|
67 | |||
68 | # Twisted generates annoying warnings with Python 2.6, as will do other code |
|
68 | # Twisted generates annoying warnings with Python 2.6, as will do other code | |
69 | # that imports 'sets' as of today |
|
69 | # that imports 'sets' as of today | |
70 | warnings.filterwarnings('ignore', 'the sets module is deprecated', |
|
70 | warnings.filterwarnings('ignore', 'the sets module is deprecated', | |
71 | DeprecationWarning ) |
|
71 | DeprecationWarning ) | |
72 |
|
72 | |||
73 | # This one also comes from Twisted |
|
73 | # This one also comes from Twisted | |
74 | warnings.filterwarnings('ignore', 'the sha module is deprecated', |
|
74 | warnings.filterwarnings('ignore', 'the sha module is deprecated', | |
75 | DeprecationWarning) |
|
75 | DeprecationWarning) | |
76 |
|
76 | |||
77 | # Wx on Fedora11 spits these out |
|
77 | # Wx on Fedora11 spits these out | |
78 | warnings.filterwarnings('ignore', 'wxPython/wxWidgets release number mismatch', |
|
78 | warnings.filterwarnings('ignore', 'wxPython/wxWidgets release number mismatch', | |
79 | UserWarning) |
|
79 | UserWarning) | |
80 |
|
80 | |||
81 | #----------------------------------------------------------------------------- |
|
81 | #----------------------------------------------------------------------------- | |
82 | # Logic for skipping doctests |
|
82 | # Logic for skipping doctests | |
83 | #----------------------------------------------------------------------------- |
|
83 | #----------------------------------------------------------------------------- | |
84 |
|
84 | |||
85 | def test_for(mod, min_version=None): |
|
85 | def test_for(mod, min_version=None): | |
86 | """Test to see if mod is importable.""" |
|
86 | """Test to see if mod is importable.""" | |
87 | try: |
|
87 | try: | |
88 | __import__(mod) |
|
88 | __import__(mod) | |
89 | except (ImportError, RuntimeError): |
|
89 | except (ImportError, RuntimeError): | |
90 | # GTK reports Runtime error if it can't be initialized even if it's |
|
90 | # GTK reports Runtime error if it can't be initialized even if it's | |
91 | # importable. |
|
91 | # importable. | |
92 | return False |
|
92 | return False | |
93 | else: |
|
93 | else: | |
94 | if min_version: |
|
94 | if min_version: | |
95 | return sys.modules[mod].__version__ >= min_version |
|
95 | return sys.modules[mod].__version__ >= min_version | |
96 | else: |
|
96 | else: | |
97 | return True |
|
97 | return True | |
98 |
|
98 | |||
99 | # Global dict where we can store information on what we have and what we don't |
|
99 | # Global dict where we can store information on what we have and what we don't | |
100 | # have available at test run time |
|
100 | # have available at test run time | |
101 | have = {} |
|
101 | have = {} | |
102 |
|
102 | |||
103 | have['curses'] = test_for('_curses') |
|
103 | have['curses'] = test_for('_curses') | |
104 | have['matplotlib'] = test_for('matplotlib') |
|
104 | have['matplotlib'] = test_for('matplotlib') | |
105 | have['pexpect'] = test_for('pexpect') |
|
105 | have['pexpect'] = test_for('pexpect') | |
106 | have['pymongo'] = test_for('pymongo') |
|
106 | have['pymongo'] = test_for('pymongo') | |
107 | have['wx'] = test_for('wx') |
|
107 | have['wx'] = test_for('wx') | |
108 | have['wx.aui'] = test_for('wx.aui') |
|
108 | have['wx.aui'] = test_for('wx.aui') | |
109 | if os.name == 'nt': |
|
109 | if os.name == 'nt': | |
110 | have['zmq'] = test_for('zmq', '2.1.7') |
|
110 | have['zmq'] = test_for('zmq', '2.1.7') | |
111 | else: |
|
111 | else: | |
112 | have['zmq'] = test_for('zmq', '2.1.4') |
|
112 | have['zmq'] = test_for('zmq', '2.1.4') | |
113 | have['qt'] = test_for('IPython.external.qt') |
|
113 | have['qt'] = test_for('IPython.external.qt') | |
114 | have['tornado'] = test_for('tornado') |
|
114 | ||
|
115 | try: | |||
|
116 | import tornado | |||
|
117 | if tornado.version_info < (2,1,0): | |||
|
118 | raise ImportError | |||
|
119 | except ImportError: | |||
|
120 | have['tornado'] = False | |||
|
121 | else: | |||
|
122 | have['tornado'] = True | |||
115 |
|
123 | |||
116 | #----------------------------------------------------------------------------- |
|
124 | #----------------------------------------------------------------------------- | |
117 | # Functions and classes |
|
125 | # Functions and classes | |
118 | #----------------------------------------------------------------------------- |
|
126 | #----------------------------------------------------------------------------- | |
119 |
|
127 | |||
120 | def report(): |
|
128 | def report(): | |
121 | """Return a string with a summary report of test-related variables.""" |
|
129 | """Return a string with a summary report of test-related variables.""" | |
122 |
|
130 | |||
123 | out = [ sys_info(), '\n'] |
|
131 | out = [ sys_info(), '\n'] | |
124 |
|
132 | |||
125 | avail = [] |
|
133 | avail = [] | |
126 | not_avail = [] |
|
134 | not_avail = [] | |
127 |
|
135 | |||
128 | for k, is_avail in have.items(): |
|
136 | for k, is_avail in have.items(): | |
129 | if is_avail: |
|
137 | if is_avail: | |
130 | avail.append(k) |
|
138 | avail.append(k) | |
131 | else: |
|
139 | else: | |
132 | not_avail.append(k) |
|
140 | not_avail.append(k) | |
133 |
|
141 | |||
134 | if avail: |
|
142 | if avail: | |
135 | out.append('\nTools and libraries available at test time:\n') |
|
143 | out.append('\nTools and libraries available at test time:\n') | |
136 | avail.sort() |
|
144 | avail.sort() | |
137 | out.append(' ' + ' '.join(avail)+'\n') |
|
145 | out.append(' ' + ' '.join(avail)+'\n') | |
138 |
|
146 | |||
139 | if not_avail: |
|
147 | if not_avail: | |
140 | out.append('\nTools and libraries NOT available at test time:\n') |
|
148 | out.append('\nTools and libraries NOT available at test time:\n') | |
141 | not_avail.sort() |
|
149 | not_avail.sort() | |
142 | out.append(' ' + ' '.join(not_avail)+'\n') |
|
150 | out.append(' ' + ' '.join(not_avail)+'\n') | |
143 |
|
151 | |||
144 | return ''.join(out) |
|
152 | return ''.join(out) | |
145 |
|
153 | |||
146 |
|
154 | |||
147 | def make_exclude(): |
|
155 | def make_exclude(): | |
148 | """Make patterns of modules and packages to exclude from testing. |
|
156 | """Make patterns of modules and packages to exclude from testing. | |
149 |
|
157 | |||
150 | For the IPythonDoctest plugin, we need to exclude certain patterns that |
|
158 | For the IPythonDoctest plugin, we need to exclude certain patterns that | |
151 | cause testing problems. We should strive to minimize the number of |
|
159 | cause testing problems. We should strive to minimize the number of | |
152 | skipped modules, since this means untested code. |
|
160 | skipped modules, since this means untested code. | |
153 |
|
161 | |||
154 | These modules and packages will NOT get scanned by nose at all for tests. |
|
162 | These modules and packages will NOT get scanned by nose at all for tests. | |
155 | """ |
|
163 | """ | |
156 | # Simple utility to make IPython paths more readably, we need a lot of |
|
164 | # Simple utility to make IPython paths more readably, we need a lot of | |
157 | # these below |
|
165 | # these below | |
158 | ipjoin = lambda *paths: pjoin('IPython', *paths) |
|
166 | ipjoin = lambda *paths: pjoin('IPython', *paths) | |
159 |
|
167 | |||
160 | exclusions = [ipjoin('external'), |
|
168 | exclusions = [ipjoin('external'), | |
161 | pjoin('IPython_doctest_plugin'), |
|
169 | pjoin('IPython_doctest_plugin'), | |
162 | ipjoin('quarantine'), |
|
170 | ipjoin('quarantine'), | |
163 | ipjoin('deathrow'), |
|
171 | ipjoin('deathrow'), | |
164 | ipjoin('testing', 'attic'), |
|
172 | ipjoin('testing', 'attic'), | |
165 | # This guy is probably attic material |
|
173 | # This guy is probably attic material | |
166 | ipjoin('testing', 'mkdoctests'), |
|
174 | ipjoin('testing', 'mkdoctests'), | |
167 | # Testing inputhook will need a lot of thought, to figure out |
|
175 | # Testing inputhook will need a lot of thought, to figure out | |
168 | # how to have tests that don't lock up with the gui event |
|
176 | # how to have tests that don't lock up with the gui event | |
169 | # loops in the picture |
|
177 | # loops in the picture | |
170 | ipjoin('lib', 'inputhook'), |
|
178 | ipjoin('lib', 'inputhook'), | |
171 | # Config files aren't really importable stand-alone |
|
179 | # Config files aren't really importable stand-alone | |
172 | ipjoin('config', 'default'), |
|
180 | ipjoin('config', 'default'), | |
173 | ipjoin('config', 'profile'), |
|
181 | ipjoin('config', 'profile'), | |
174 | ] |
|
182 | ] | |
175 |
|
183 | |||
176 | if not have['wx']: |
|
184 | if not have['wx']: | |
177 | exclusions.append(ipjoin('lib', 'inputhookwx')) |
|
185 | exclusions.append(ipjoin('lib', 'inputhookwx')) | |
178 |
|
186 | |||
179 | # We do this unconditionally, so that the test suite doesn't import |
|
187 | # We do this unconditionally, so that the test suite doesn't import | |
180 | # gtk, changing the default encoding and masking some unicode bugs. |
|
188 | # gtk, changing the default encoding and masking some unicode bugs. | |
181 | exclusions.append(ipjoin('lib', 'inputhookgtk')) |
|
189 | exclusions.append(ipjoin('lib', 'inputhookgtk')) | |
182 |
|
190 | |||
183 | # These have to be skipped on win32 because the use echo, rm, cd, etc. |
|
191 | # These have to be skipped on win32 because the use echo, rm, cd, etc. | |
184 | # See ticket https://github.com/ipython/ipython/issues/87 |
|
192 | # See ticket https://github.com/ipython/ipython/issues/87 | |
185 | if sys.platform == 'win32': |
|
193 | if sys.platform == 'win32': | |
186 | exclusions.append(ipjoin('testing', 'plugin', 'test_exampleip')) |
|
194 | exclusions.append(ipjoin('testing', 'plugin', 'test_exampleip')) | |
187 | exclusions.append(ipjoin('testing', 'plugin', 'dtexample')) |
|
195 | exclusions.append(ipjoin('testing', 'plugin', 'dtexample')) | |
188 |
|
196 | |||
189 | if not have['pexpect']: |
|
197 | if not have['pexpect']: | |
190 | exclusions.extend([ipjoin('scripts', 'irunner'), |
|
198 | exclusions.extend([ipjoin('scripts', 'irunner'), | |
191 | ipjoin('lib', 'irunner'), |
|
199 | ipjoin('lib', 'irunner'), | |
192 | ipjoin('lib', 'tests', 'test_irunner')]) |
|
200 | ipjoin('lib', 'tests', 'test_irunner')]) | |
193 |
|
201 | |||
194 | if not have['zmq']: |
|
202 | if not have['zmq']: | |
195 | exclusions.append(ipjoin('zmq')) |
|
203 | exclusions.append(ipjoin('zmq')) | |
196 | exclusions.append(ipjoin('frontend', 'qt')) |
|
204 | exclusions.append(ipjoin('frontend', 'qt')) | |
197 | exclusions.append(ipjoin('parallel')) |
|
205 | exclusions.append(ipjoin('parallel')) | |
198 | elif not have['qt']: |
|
206 | elif not have['qt']: | |
199 | exclusions.append(ipjoin('frontend', 'qt')) |
|
207 | exclusions.append(ipjoin('frontend', 'qt')) | |
200 |
|
208 | |||
201 | if not have['pymongo']: |
|
209 | if not have['pymongo']: | |
202 | exclusions.append(ipjoin('parallel', 'controller', 'mongodb')) |
|
210 | exclusions.append(ipjoin('parallel', 'controller', 'mongodb')) | |
203 | exclusions.append(ipjoin('parallel', 'tests', 'test_mongodb')) |
|
211 | exclusions.append(ipjoin('parallel', 'tests', 'test_mongodb')) | |
204 |
|
212 | |||
205 | if not have['matplotlib']: |
|
213 | if not have['matplotlib']: | |
206 | exclusions.extend([ipjoin('lib', 'pylabtools'), |
|
214 | exclusions.extend([ipjoin('lib', 'pylabtools'), | |
207 | ipjoin('lib', 'tests', 'test_pylabtools')]) |
|
215 | ipjoin('lib', 'tests', 'test_pylabtools')]) | |
208 |
|
216 | |||
209 | if not have['tornado']: |
|
217 | if not have['tornado']: | |
210 | exclusions.append(ipjoin('frontend', 'html')) |
|
218 | exclusions.append(ipjoin('frontend', 'html')) | |
211 |
|
219 | |||
212 | # This is needed for the reg-exp to match on win32 in the ipdoctest plugin. |
|
220 | # This is needed for the reg-exp to match on win32 in the ipdoctest plugin. | |
213 | if sys.platform == 'win32': |
|
221 | if sys.platform == 'win32': | |
214 | exclusions = [s.replace('\\','\\\\') for s in exclusions] |
|
222 | exclusions = [s.replace('\\','\\\\') for s in exclusions] | |
215 |
|
223 | |||
216 | return exclusions |
|
224 | return exclusions | |
217 |
|
225 | |||
218 |
|
226 | |||
219 | class IPTester(object): |
|
227 | class IPTester(object): | |
220 | """Call that calls iptest or trial in a subprocess. |
|
228 | """Call that calls iptest or trial in a subprocess. | |
221 | """ |
|
229 | """ | |
222 | #: string, name of test runner that will be called |
|
230 | #: string, name of test runner that will be called | |
223 | runner = None |
|
231 | runner = None | |
224 | #: list, parameters for test runner |
|
232 | #: list, parameters for test runner | |
225 | params = None |
|
233 | params = None | |
226 | #: list, arguments of system call to be made to call test runner |
|
234 | #: list, arguments of system call to be made to call test runner | |
227 | call_args = None |
|
235 | call_args = None | |
228 | #: list, process ids of subprocesses we start (for cleanup) |
|
236 | #: list, process ids of subprocesses we start (for cleanup) | |
229 | pids = None |
|
237 | pids = None | |
230 |
|
238 | |||
231 | def __init__(self, runner='iptest', params=None): |
|
239 | def __init__(self, runner='iptest', params=None): | |
232 | """Create new test runner.""" |
|
240 | """Create new test runner.""" | |
233 | p = os.path |
|
241 | p = os.path | |
234 | if runner == 'iptest': |
|
242 | if runner == 'iptest': | |
235 | iptest_app = get_ipython_module_path('IPython.testing.iptest') |
|
243 | iptest_app = get_ipython_module_path('IPython.testing.iptest') | |
236 | self.runner = pycmd2argv(iptest_app) + sys.argv[1:] |
|
244 | self.runner = pycmd2argv(iptest_app) + sys.argv[1:] | |
237 | else: |
|
245 | else: | |
238 | raise Exception('Not a valid test runner: %s' % repr(runner)) |
|
246 | raise Exception('Not a valid test runner: %s' % repr(runner)) | |
239 | if params is None: |
|
247 | if params is None: | |
240 | params = [] |
|
248 | params = [] | |
241 | if isinstance(params, str): |
|
249 | if isinstance(params, str): | |
242 | params = [params] |
|
250 | params = [params] | |
243 | self.params = params |
|
251 | self.params = params | |
244 |
|
252 | |||
245 | # Assemble call |
|
253 | # Assemble call | |
246 | self.call_args = self.runner+self.params |
|
254 | self.call_args = self.runner+self.params | |
247 |
|
255 | |||
248 | # Store pids of anything we start to clean up on deletion, if possible |
|
256 | # Store pids of anything we start to clean up on deletion, if possible | |
249 | # (on posix only, since win32 has no os.kill) |
|
257 | # (on posix only, since win32 has no os.kill) | |
250 | self.pids = [] |
|
258 | self.pids = [] | |
251 |
|
259 | |||
252 | if sys.platform == 'win32': |
|
260 | if sys.platform == 'win32': | |
253 | def _run_cmd(self): |
|
261 | def _run_cmd(self): | |
254 | # On Windows, use os.system instead of subprocess.call, because I |
|
262 | # On Windows, use os.system instead of subprocess.call, because I | |
255 | # was having problems with subprocess and I just don't know enough |
|
263 | # was having problems with subprocess and I just don't know enough | |
256 | # about win32 to debug this reliably. Os.system may be the 'old |
|
264 | # about win32 to debug this reliably. Os.system may be the 'old | |
257 | # fashioned' way to do it, but it works just fine. If someone |
|
265 | # fashioned' way to do it, but it works just fine. If someone | |
258 | # later can clean this up that's fine, as long as the tests run |
|
266 | # later can clean this up that's fine, as long as the tests run | |
259 | # reliably in win32. |
|
267 | # reliably in win32. | |
260 | # What types of problems are you having. They may be related to |
|
268 | # What types of problems are you having. They may be related to | |
261 | # running Python in unboffered mode. BG. |
|
269 | # running Python in unboffered mode. BG. | |
262 | return os.system(' '.join(self.call_args)) |
|
270 | return os.system(' '.join(self.call_args)) | |
263 | else: |
|
271 | else: | |
264 | def _run_cmd(self): |
|
272 | def _run_cmd(self): | |
265 | # print >> sys.stderr, '*** CMD:', ' '.join(self.call_args) # dbg |
|
273 | # print >> sys.stderr, '*** CMD:', ' '.join(self.call_args) # dbg | |
266 | subp = subprocess.Popen(self.call_args) |
|
274 | subp = subprocess.Popen(self.call_args) | |
267 | self.pids.append(subp.pid) |
|
275 | self.pids.append(subp.pid) | |
268 | # If this fails, the pid will be left in self.pids and cleaned up |
|
276 | # If this fails, the pid will be left in self.pids and cleaned up | |
269 | # later, but if the wait call succeeds, then we can clear the |
|
277 | # later, but if the wait call succeeds, then we can clear the | |
270 | # stored pid. |
|
278 | # stored pid. | |
271 | retcode = subp.wait() |
|
279 | retcode = subp.wait() | |
272 | self.pids.pop() |
|
280 | self.pids.pop() | |
273 | return retcode |
|
281 | return retcode | |
274 |
|
282 | |||
275 | def run(self): |
|
283 | def run(self): | |
276 | """Run the stored commands""" |
|
284 | """Run the stored commands""" | |
277 | try: |
|
285 | try: | |
278 | return self._run_cmd() |
|
286 | return self._run_cmd() | |
279 | except: |
|
287 | except: | |
280 | import traceback |
|
288 | import traceback | |
281 | traceback.print_exc() |
|
289 | traceback.print_exc() | |
282 | return 1 # signal failure |
|
290 | return 1 # signal failure | |
283 |
|
291 | |||
284 | def __del__(self): |
|
292 | def __del__(self): | |
285 | """Cleanup on exit by killing any leftover processes.""" |
|
293 | """Cleanup on exit by killing any leftover processes.""" | |
286 |
|
294 | |||
287 | if not hasattr(os, 'kill'): |
|
295 | if not hasattr(os, 'kill'): | |
288 | return |
|
296 | return | |
289 |
|
297 | |||
290 | for pid in self.pids: |
|
298 | for pid in self.pids: | |
291 | try: |
|
299 | try: | |
292 | print 'Cleaning stale PID:', pid |
|
300 | print 'Cleaning stale PID:', pid | |
293 | os.kill(pid, signal.SIGKILL) |
|
301 | os.kill(pid, signal.SIGKILL) | |
294 | except OSError: |
|
302 | except OSError: | |
295 | # This is just a best effort, if we fail or the process was |
|
303 | # This is just a best effort, if we fail or the process was | |
296 | # really gone, ignore it. |
|
304 | # really gone, ignore it. | |
297 | pass |
|
305 | pass | |
298 |
|
306 | |||
299 |
|
307 | |||
300 | def make_runners(): |
|
308 | def make_runners(): | |
301 | """Define the top-level packages that need to be tested. |
|
309 | """Define the top-level packages that need to be tested. | |
302 | """ |
|
310 | """ | |
303 |
|
311 | |||
304 | # Packages to be tested via nose, that only depend on the stdlib |
|
312 | # Packages to be tested via nose, that only depend on the stdlib | |
305 | nose_pkg_names = ['config', 'core', 'extensions', 'frontend', 'lib', |
|
313 | nose_pkg_names = ['config', 'core', 'extensions', 'frontend', 'lib', | |
306 | 'scripts', 'testing', 'utils', 'nbformat' ] |
|
314 | 'scripts', 'testing', 'utils', 'nbformat' ] | |
307 |
|
315 | |||
308 | if have['zmq']: |
|
316 | if have['zmq']: | |
309 | nose_pkg_names.append('parallel') |
|
317 | nose_pkg_names.append('parallel') | |
310 |
|
318 | |||
311 | # For debugging this code, only load quick stuff |
|
319 | # For debugging this code, only load quick stuff | |
312 | #nose_pkg_names = ['core', 'extensions'] # dbg |
|
320 | #nose_pkg_names = ['core', 'extensions'] # dbg | |
313 |
|
321 | |||
314 | # Make fully qualified package names prepending 'IPython.' to our name lists |
|
322 | # Make fully qualified package names prepending 'IPython.' to our name lists | |
315 | nose_packages = ['IPython.%s' % m for m in nose_pkg_names ] |
|
323 | nose_packages = ['IPython.%s' % m for m in nose_pkg_names ] | |
316 |
|
324 | |||
317 | # Make runners |
|
325 | # Make runners | |
318 | runners = [ (v, IPTester('iptest', params=v)) for v in nose_packages ] |
|
326 | runners = [ (v, IPTester('iptest', params=v)) for v in nose_packages ] | |
319 |
|
327 | |||
320 | return runners |
|
328 | return runners | |
321 |
|
329 | |||
322 |
|
330 | |||
323 | def run_iptest(): |
|
331 | def run_iptest(): | |
324 | """Run the IPython test suite using nose. |
|
332 | """Run the IPython test suite using nose. | |
325 |
|
333 | |||
326 | This function is called when this script is **not** called with the form |
|
334 | This function is called when this script is **not** called with the form | |
327 | `iptest all`. It simply calls nose with appropriate command line flags |
|
335 | `iptest all`. It simply calls nose with appropriate command line flags | |
328 | and accepts all of the standard nose arguments. |
|
336 | and accepts all of the standard nose arguments. | |
329 | """ |
|
337 | """ | |
330 |
|
338 | |||
331 | warnings.filterwarnings('ignore', |
|
339 | warnings.filterwarnings('ignore', | |
332 | 'This will be removed soon. Use IPython.testing.util instead') |
|
340 | 'This will be removed soon. Use IPython.testing.util instead') | |
333 |
|
341 | |||
334 | argv = sys.argv + [ '--detailed-errors', # extra info in tracebacks |
|
342 | argv = sys.argv + [ '--detailed-errors', # extra info in tracebacks | |
335 |
|
343 | |||
336 | # Loading ipdoctest causes problems with Twisted, but |
|
344 | # Loading ipdoctest causes problems with Twisted, but | |
337 | # our test suite runner now separates things and runs |
|
345 | # our test suite runner now separates things and runs | |
338 | # all Twisted tests with trial. |
|
346 | # all Twisted tests with trial. | |
339 | '--with-ipdoctest', |
|
347 | '--with-ipdoctest', | |
340 | '--ipdoctest-tests','--ipdoctest-extension=txt', |
|
348 | '--ipdoctest-tests','--ipdoctest-extension=txt', | |
341 |
|
349 | |||
342 | # We add --exe because of setuptools' imbecility (it |
|
350 | # We add --exe because of setuptools' imbecility (it | |
343 | # blindly does chmod +x on ALL files). Nose does the |
|
351 | # blindly does chmod +x on ALL files). Nose does the | |
344 | # right thing and it tries to avoid executables, |
|
352 | # right thing and it tries to avoid executables, | |
345 | # setuptools unfortunately forces our hand here. This |
|
353 | # setuptools unfortunately forces our hand here. This | |
346 | # has been discussed on the distutils list and the |
|
354 | # has been discussed on the distutils list and the | |
347 | # setuptools devs refuse to fix this problem! |
|
355 | # setuptools devs refuse to fix this problem! | |
348 | '--exe', |
|
356 | '--exe', | |
349 | ] |
|
357 | ] | |
350 |
|
358 | |||
351 | if nose.__version__ >= '0.11': |
|
359 | if nose.__version__ >= '0.11': | |
352 | # I don't fully understand why we need this one, but depending on what |
|
360 | # I don't fully understand why we need this one, but depending on what | |
353 | # directory the test suite is run from, if we don't give it, 0 tests |
|
361 | # directory the test suite is run from, if we don't give it, 0 tests | |
354 | # get run. Specifically, if the test suite is run from the source dir |
|
362 | # get run. Specifically, if the test suite is run from the source dir | |
355 | # with an argument (like 'iptest.py IPython.core', 0 tests are run, |
|
363 | # with an argument (like 'iptest.py IPython.core', 0 tests are run, | |
356 | # even if the same call done in this directory works fine). It appears |
|
364 | # even if the same call done in this directory works fine). It appears | |
357 | # that if the requested package is in the current dir, nose bails early |
|
365 | # that if the requested package is in the current dir, nose bails early | |
358 | # by default. Since it's otherwise harmless, leave it in by default |
|
366 | # by default. Since it's otherwise harmless, leave it in by default | |
359 | # for nose >= 0.11, though unfortunately nose 0.10 doesn't support it. |
|
367 | # for nose >= 0.11, though unfortunately nose 0.10 doesn't support it. | |
360 | argv.append('--traverse-namespace') |
|
368 | argv.append('--traverse-namespace') | |
361 |
|
369 | |||
362 | # use our plugin for doctesting. It will remove the standard doctest plugin |
|
370 | # use our plugin for doctesting. It will remove the standard doctest plugin | |
363 | # if it finds it enabled |
|
371 | # if it finds it enabled | |
364 | plugins = [IPythonDoctest(make_exclude()), KnownFailure()] |
|
372 | plugins = [IPythonDoctest(make_exclude()), KnownFailure()] | |
365 | # We need a global ipython running in this process |
|
373 | # We need a global ipython running in this process | |
366 | globalipapp.start_ipython() |
|
374 | globalipapp.start_ipython() | |
367 | # Now nose can run |
|
375 | # Now nose can run | |
368 | TestProgram(argv=argv, addplugins=plugins) |
|
376 | TestProgram(argv=argv, addplugins=plugins) | |
369 |
|
377 | |||
370 |
|
378 | |||
371 | def run_iptestall(): |
|
379 | def run_iptestall(): | |
372 | """Run the entire IPython test suite by calling nose and trial. |
|
380 | """Run the entire IPython test suite by calling nose and trial. | |
373 |
|
381 | |||
374 | This function constructs :class:`IPTester` instances for all IPython |
|
382 | This function constructs :class:`IPTester` instances for all IPython | |
375 | modules and package and then runs each of them. This causes the modules |
|
383 | modules and package and then runs each of them. This causes the modules | |
376 | and packages of IPython to be tested each in their own subprocess using |
|
384 | and packages of IPython to be tested each in their own subprocess using | |
377 | nose or twisted.trial appropriately. |
|
385 | nose or twisted.trial appropriately. | |
378 | """ |
|
386 | """ | |
379 |
|
387 | |||
380 | runners = make_runners() |
|
388 | runners = make_runners() | |
381 |
|
389 | |||
382 | # Run the test runners in a temporary dir so we can nuke it when finished |
|
390 | # Run the test runners in a temporary dir so we can nuke it when finished | |
383 | # to clean up any junk files left over by accident. This also makes it |
|
391 | # to clean up any junk files left over by accident. This also makes it | |
384 | # robust against being run in non-writeable directories by mistake, as the |
|
392 | # robust against being run in non-writeable directories by mistake, as the | |
385 | # temp dir will always be user-writeable. |
|
393 | # temp dir will always be user-writeable. | |
386 | curdir = os.getcwdu() |
|
394 | curdir = os.getcwdu() | |
387 | testdir = tempfile.gettempdir() |
|
395 | testdir = tempfile.gettempdir() | |
388 | os.chdir(testdir) |
|
396 | os.chdir(testdir) | |
389 |
|
397 | |||
390 | # Run all test runners, tracking execution time |
|
398 | # Run all test runners, tracking execution time | |
391 | failed = [] |
|
399 | failed = [] | |
392 | t_start = time.time() |
|
400 | t_start = time.time() | |
393 | try: |
|
401 | try: | |
394 | for (name, runner) in runners: |
|
402 | for (name, runner) in runners: | |
395 | print '*'*70 |
|
403 | print '*'*70 | |
396 | print 'IPython test group:',name |
|
404 | print 'IPython test group:',name | |
397 | res = runner.run() |
|
405 | res = runner.run() | |
398 | if res: |
|
406 | if res: | |
399 | failed.append( (name, runner) ) |
|
407 | failed.append( (name, runner) ) | |
400 | finally: |
|
408 | finally: | |
401 | os.chdir(curdir) |
|
409 | os.chdir(curdir) | |
402 | t_end = time.time() |
|
410 | t_end = time.time() | |
403 | t_tests = t_end - t_start |
|
411 | t_tests = t_end - t_start | |
404 | nrunners = len(runners) |
|
412 | nrunners = len(runners) | |
405 | nfail = len(failed) |
|
413 | nfail = len(failed) | |
406 | # summarize results |
|
414 | # summarize results | |
407 |
|
415 | |||
408 | print '*'*70 |
|
416 | print '*'*70 | |
409 | print 'Test suite completed for system with the following information:' |
|
417 | print 'Test suite completed for system with the following information:' | |
410 | print report() |
|
418 | print report() | |
411 | print 'Ran %s test groups in %.3fs' % (nrunners, t_tests) |
|
419 | print 'Ran %s test groups in %.3fs' % (nrunners, t_tests) | |
412 |
|
420 | |||
413 | print 'Status:' |
|
421 | print 'Status:' | |
414 | if not failed: |
|
422 | if not failed: | |
415 | print 'OK' |
|
423 | print 'OK' | |
416 | else: |
|
424 | else: | |
417 | # If anything went wrong, point out what command to rerun manually to |
|
425 | # If anything went wrong, point out what command to rerun manually to | |
418 | # see the actual errors and individual summary |
|
426 | # see the actual errors and individual summary | |
419 | print 'ERROR - %s out of %s test groups failed.' % (nfail, nrunners) |
|
427 | print 'ERROR - %s out of %s test groups failed.' % (nfail, nrunners) | |
420 | for name, failed_runner in failed: |
|
428 | for name, failed_runner in failed: | |
421 | print '-'*40 |
|
429 | print '-'*40 | |
422 | print 'Runner failed:',name |
|
430 | print 'Runner failed:',name | |
423 | print 'You may wish to rerun this one individually, with:' |
|
431 | print 'You may wish to rerun this one individually, with:' | |
424 | print ' '.join(failed_runner.call_args) |
|
432 | print ' '.join(failed_runner.call_args) | |
425 |
|
433 | |||
426 | # Ensure that our exit code indicates failure |
|
434 | # Ensure that our exit code indicates failure | |
427 | sys.exit(1) |
|
435 | sys.exit(1) | |
428 |
|
436 | |||
429 |
|
437 | |||
430 | def main(): |
|
438 | def main(): | |
431 | for arg in sys.argv[1:]: |
|
439 | for arg in sys.argv[1:]: | |
432 | if arg.startswith('IPython'): |
|
440 | if arg.startswith('IPython'): | |
433 | # This is in-process |
|
441 | # This is in-process | |
434 | run_iptest() |
|
442 | run_iptest() | |
435 | else: |
|
443 | else: | |
436 | # This starts subprocesses |
|
444 | # This starts subprocesses | |
437 | run_iptestall() |
|
445 | run_iptestall() | |
438 |
|
446 | |||
439 |
|
447 | |||
440 | if __name__ == '__main__': |
|
448 | if __name__ == '__main__': | |
441 | main() |
|
449 | main() |
@@ -1,403 +1,401 b'' | |||||
1 | Overview |
|
1 | Overview | |
2 | ======== |
|
2 | ======== | |
3 |
|
3 | |||
4 | This document describes the steps required to install IPython. IPython is |
|
4 | This document describes the steps required to install IPython. IPython is | |
5 | organized into a number of subpackages, each of which has its own dependencies. |
|
5 | organized into a number of subpackages, each of which has its own dependencies. | |
6 | All of the subpackages come with IPython, so you don't need to download and |
|
6 | All of the subpackages come with IPython, so you don't need to download and | |
7 | install them separately. However, to use a given subpackage, you will need to |
|
7 | install them separately. However, to use a given subpackage, you will need to | |
8 | install all of its dependencies. |
|
8 | install all of its dependencies. | |
9 |
|
9 | |||
10 |
|
10 | |||
11 | Please let us know if you have problems installing IPython or any of its |
|
11 | Please let us know if you have problems installing IPython or any of its | |
12 | dependencies. Officially, IPython requires Python version 2.6 or 2.7. There |
|
12 | dependencies. Officially, IPython requires Python version 2.6 or 2.7. There | |
13 | is an experimental port of IPython for Python3 `on GitHub |
|
13 | is an experimental port of IPython for Python3 `on GitHub | |
14 | <https://github.com/ipython/ipython-py3k>`_ |
|
14 | <https://github.com/ipython/ipython-py3k>`_ | |
15 |
|
15 | |||
16 | .. warning:: |
|
16 | .. warning:: | |
17 |
|
17 | |||
18 | Officially, IPython supports Python versions 2.6 and 2.7. |
|
18 | Officially, IPython supports Python versions 2.6 and 2.7. | |
19 |
|
19 | |||
20 | IPython 0.11 has a hard syntax dependency on 2.6, and will no longer work |
|
20 | IPython 0.11 has a hard syntax dependency on 2.6, and will no longer work | |
21 | on Python <= 2.5. |
|
21 | on Python <= 2.5. | |
22 |
|
22 | |||
23 | Some of the installation approaches use the :mod:`setuptools` package and its |
|
23 | Some of the installation approaches use the :mod:`setuptools` package and its | |
24 | :command:`easy_install` command line program. In many scenarios, this provides |
|
24 | :command:`easy_install` command line program. In many scenarios, this provides | |
25 | the most simple method of installing IPython and its dependencies. It is not |
|
25 | the most simple method of installing IPython and its dependencies. It is not | |
26 | required though. More information about :mod:`setuptools` can be found on its |
|
26 | required though. More information about :mod:`setuptools` can be found on its | |
27 | website. |
|
27 | website. | |
28 |
|
28 | |||
29 | .. note:: |
|
29 | .. note:: | |
30 |
|
30 | |||
31 | On Windows, IPython *does* depend on :mod:`setuptools`, and it is recommended |
|
31 | On Windows, IPython *does* depend on :mod:`setuptools`, and it is recommended | |
32 | that you install the :mod:`distribute` package, which improves |
|
32 | that you install the :mod:`distribute` package, which improves | |
33 | :mod:`setuptools` and fixes various bugs. |
|
33 | :mod:`setuptools` and fixes various bugs. | |
34 |
|
34 | |||
35 | We hope to remove this dependency in 0.12. |
|
35 | We hope to remove this dependency in 0.12. | |
36 |
|
36 | |||
37 | More general information about installing Python packages can be found in |
|
37 | More general information about installing Python packages can be found in | |
38 | Python's documentation at http://www.python.org/doc/. |
|
38 | Python's documentation at http://www.python.org/doc/. | |
39 |
|
39 | |||
40 | Quickstart |
|
40 | Quickstart | |
41 | ========== |
|
41 | ========== | |
42 |
|
42 | |||
43 | If you have :mod:`setuptools` installed and you are on OS X or Linux (not |
|
43 | If you have :mod:`setuptools` installed and you are on OS X or Linux (not | |
44 | Windows), the following will download and install IPython *and* the main |
|
44 | Windows), the following will download and install IPython *and* the main | |
45 | optional dependencies: |
|
45 | optional dependencies: | |
46 |
|
46 | |||
47 | .. code-block:: bash |
|
47 | .. code-block:: bash | |
48 |
|
48 | |||
49 | $ easy_install ipython[zmq,test] |
|
49 | $ easy_install ipython[zmq,test] | |
50 |
|
50 | |||
51 | This will get pyzmq, which is needed for |
|
51 | This will get pyzmq, which is needed for | |
52 | IPython's parallel computing features as well as the nose package, which will |
|
52 | IPython's parallel computing features as well as the nose package, which will | |
53 | enable you to run IPython's test suite. |
|
53 | enable you to run IPython's test suite. | |
54 |
|
54 | |||
55 | To run IPython's test suite, use the :command:`iptest` command: |
|
55 | To run IPython's test suite, use the :command:`iptest` command: | |
56 |
|
56 | |||
57 | .. code-block:: bash |
|
57 | .. code-block:: bash | |
58 |
|
58 | |||
59 | $ iptest |
|
59 | $ iptest | |
60 |
|
60 | |||
61 | Read on for more specific details and instructions for Windows. |
|
61 | Read on for more specific details and instructions for Windows. | |
62 |
|
62 | |||
63 | Installing IPython itself |
|
63 | Installing IPython itself | |
64 | ========================= |
|
64 | ========================= | |
65 |
|
65 | |||
66 | Given a properly built Python, the basic interactive IPython shell will work |
|
66 | Given a properly built Python, the basic interactive IPython shell will work | |
67 | with no external dependencies. However, some Python distributions |
|
67 | with no external dependencies. However, some Python distributions | |
68 | (particularly on Windows and OS X), don't come with a working :mod:`readline` |
|
68 | (particularly on Windows and OS X), don't come with a working :mod:`readline` | |
69 | module. The IPython shell will work without :mod:`readline`, but will lack |
|
69 | module. The IPython shell will work without :mod:`readline`, but will lack | |
70 | many features that users depend on, such as tab completion and command line |
|
70 | many features that users depend on, such as tab completion and command line | |
71 | editing. If you install IPython with :mod:`setuptools`, (e.g. with `easy_install`), |
|
71 | editing. If you install IPython with :mod:`setuptools`, (e.g. with `easy_install`), | |
72 | then the appropriate :mod:`readline` for your platform will be installed. |
|
72 | then the appropriate :mod:`readline` for your platform will be installed. | |
73 | See below for details of how to make sure you have a working :mod:`readline`. |
|
73 | See below for details of how to make sure you have a working :mod:`readline`. | |
74 |
|
74 | |||
75 | Installation using easy_install |
|
75 | Installation using easy_install | |
76 | ------------------------------- |
|
76 | ------------------------------- | |
77 |
|
77 | |||
78 | If you have :mod:`setuptools` installed, the easiest way of getting IPython is |
|
78 | If you have :mod:`setuptools` installed, the easiest way of getting IPython is | |
79 | to simple use :command:`easy_install`: |
|
79 | to simple use :command:`easy_install`: | |
80 |
|
80 | |||
81 | .. code-block:: bash |
|
81 | .. code-block:: bash | |
82 |
|
82 | |||
83 | $ easy_install ipython |
|
83 | $ easy_install ipython | |
84 |
|
84 | |||
85 | That's it. |
|
85 | That's it. | |
86 |
|
86 | |||
87 | Installation from source |
|
87 | Installation from source | |
88 | ------------------------ |
|
88 | ------------------------ | |
89 |
|
89 | |||
90 | If you don't want to use :command:`easy_install`, or don't have it installed, |
|
90 | If you don't want to use :command:`easy_install`, or don't have it installed, | |
91 | just grab the latest stable build of IPython from `here |
|
91 | just grab the latest stable build of IPython from `here | |
92 | <https://github.com/ipython/ipython/downloads>`_. Then do the following: |
|
92 | <https://github.com/ipython/ipython/downloads>`_. Then do the following: | |
93 |
|
93 | |||
94 | .. code-block:: bash |
|
94 | .. code-block:: bash | |
95 |
|
95 | |||
96 | $ tar -xzf ipython.tar.gz |
|
96 | $ tar -xzf ipython.tar.gz | |
97 | $ cd ipython |
|
97 | $ cd ipython | |
98 | $ python setup.py install |
|
98 | $ python setup.py install | |
99 |
|
99 | |||
100 | If you are installing to a location (like ``/usr/local``) that requires higher |
|
100 | If you are installing to a location (like ``/usr/local``) that requires higher | |
101 | permissions, you may need to run the last command with :command:`sudo`. |
|
101 | permissions, you may need to run the last command with :command:`sudo`. | |
102 |
|
102 | |||
103 | Windows |
|
103 | Windows | |
104 | ------- |
|
104 | ------- | |
105 |
|
105 | |||
106 | .. note:: |
|
106 | .. note:: | |
107 |
|
107 | |||
108 | On Windows, IPython requires :mod:`setuptools` or :mod:`distribute`. |
|
108 | On Windows, IPython requires :mod:`setuptools` or :mod:`distribute`. | |
109 |
|
109 | |||
110 | We hope to remove this dependency in 0.12. |
|
110 | We hope to remove this dependency in 0.12. | |
111 |
|
111 | |||
112 | There are a few caveats for Windows users. The main issue is that a basic |
|
112 | There are a few caveats for Windows users. The main issue is that a basic | |
113 | ``python setup.py install`` approach won't create ``.bat`` file or Start Menu |
|
113 | ``python setup.py install`` approach won't create ``.bat`` file or Start Menu | |
114 | shortcuts, which most users want. To get an installation with these, you can |
|
114 | shortcuts, which most users want. To get an installation with these, you can | |
115 | use any of the following alternatives: |
|
115 | use any of the following alternatives: | |
116 |
|
116 | |||
117 | 1. Install using :command:`easy_install`. |
|
117 | 1. Install using :command:`easy_install`. | |
118 |
|
118 | |||
119 | 2. Install using our binary ``.exe`` Windows installer, which can be found |
|
119 | 2. Install using our binary ``.exe`` Windows installer, which can be found | |
120 | `here <http://ipython.scipy.org/dist/>`_ |
|
120 | `here <http://ipython.scipy.org/dist/>`_ | |
121 |
|
121 | |||
122 | 3. Install from source, but using :mod:`setuptools` (``python setupegg.py |
|
122 | 3. Install from source, but using :mod:`setuptools` (``python setupegg.py | |
123 | install``). |
|
123 | install``). | |
124 |
|
124 | |||
125 | IPython by default runs in a terminal window, but the normal terminal |
|
125 | IPython by default runs in a terminal window, but the normal terminal | |
126 | application supplied by Microsoft Windows is very primitive. You may want to |
|
126 | application supplied by Microsoft Windows is very primitive. You may want to | |
127 | download the excellent and free Console_ application instead, which is a far |
|
127 | download the excellent and free Console_ application instead, which is a far | |
128 | superior tool. You can even configure Console to give you by default an |
|
128 | superior tool. You can even configure Console to give you by default an | |
129 | IPython tab, which is very convenient to create new IPython sessions directly |
|
129 | IPython tab, which is very convenient to create new IPython sessions directly | |
130 | from the working terminal. |
|
130 | from the working terminal. | |
131 |
|
131 | |||
132 | .. _Console: http://sourceforge.net/projects/console |
|
132 | .. _Console: http://sourceforge.net/projects/console | |
133 |
|
133 | |||
134 | Note for Windows 64 bit users: you may have difficulties with the stock |
|
134 | Note for Windows 64 bit users: you may have difficulties with the stock | |
135 | installer on 64 bit systems; in this case (since we currently do not have 64 |
|
135 | installer on 64 bit systems; in this case (since we currently do not have 64 | |
136 | bit builds of the Windows installer) your best bet is to install from source |
|
136 | bit builds of the Windows installer) your best bet is to install from source | |
137 | with the setuptools method indicated in #3 above. See `this bug report`_ for |
|
137 | with the setuptools method indicated in #3 above. See `this bug report`_ for | |
138 | further details. |
|
138 | further details. | |
139 |
|
139 | |||
140 | .. _this bug report: https://bugs.launchpad.net/ipython/+bug/382214 |
|
140 | .. _this bug report: https://bugs.launchpad.net/ipython/+bug/382214 | |
141 |
|
141 | |||
142 |
|
142 | |||
143 | Installing the development version |
|
143 | Installing the development version | |
144 | ---------------------------------- |
|
144 | ---------------------------------- | |
145 |
|
145 | |||
146 | It is also possible to install the development version of IPython from our |
|
146 | It is also possible to install the development version of IPython from our | |
147 | `Git <http://git-scm.com/>`_ source code repository. To do this you will |
|
147 | `Git <http://git-scm.com/>`_ source code repository. To do this you will | |
148 | need to have Git installed on your system. Then just do: |
|
148 | need to have Git installed on your system. Then just do: | |
149 |
|
149 | |||
150 | .. code-block:: bash |
|
150 | .. code-block:: bash | |
151 |
|
151 | |||
152 | $ git clone https://github.com/ipython/ipython.git |
|
152 | $ git clone https://github.com/ipython/ipython.git | |
153 | $ cd ipython |
|
153 | $ cd ipython | |
154 | $ python setup.py install |
|
154 | $ python setup.py install | |
155 |
|
155 | |||
156 | Again, this last step on Windows won't create ``.bat`` files or Start Menu |
|
156 | Again, this last step on Windows won't create ``.bat`` files or Start Menu | |
157 | shortcuts, so you will have to use one of the other approaches listed above. |
|
157 | shortcuts, so you will have to use one of the other approaches listed above. | |
158 |
|
158 | |||
159 | Some users want to be able to follow the development branch as it changes. If |
|
159 | Some users want to be able to follow the development branch as it changes. If | |
160 | you have :mod:`setuptools` installed, this is easy. Simply replace the last |
|
160 | you have :mod:`setuptools` installed, this is easy. Simply replace the last | |
161 | step by: |
|
161 | step by: | |
162 |
|
162 | |||
163 | .. code-block:: bash |
|
163 | .. code-block:: bash | |
164 |
|
164 | |||
165 | $ python setupegg.py develop |
|
165 | $ python setupegg.py develop | |
166 |
|
166 | |||
167 | This creates links in the right places and installs the command line script to |
|
167 | This creates links in the right places and installs the command line script to | |
168 | the appropriate places. Then, if you want to update your IPython at any time, |
|
168 | the appropriate places. Then, if you want to update your IPython at any time, | |
169 | just do: |
|
169 | just do: | |
170 |
|
170 | |||
171 | .. code-block:: bash |
|
171 | .. code-block:: bash | |
172 |
|
172 | |||
173 | $ git pull |
|
173 | $ git pull | |
174 |
|
174 | |||
175 | Basic optional dependencies |
|
175 | Basic optional dependencies | |
176 | =========================== |
|
176 | =========================== | |
177 |
|
177 | |||
178 | There are a number of basic optional dependencies that most users will want to |
|
178 | There are a number of basic optional dependencies that most users will want to | |
179 | get. These are: |
|
179 | get. These are: | |
180 |
|
180 | |||
181 | * readline (for command line editing, tab completion, etc.) |
|
181 | * readline (for command line editing, tab completion, etc.) | |
182 | * nose (to run the IPython test suite) |
|
182 | * nose (to run the IPython test suite) | |
183 | * pexpect (to use things like irunner) |
|
183 | * pexpect (to use things like irunner) | |
184 |
|
184 | |||
185 | If you are comfortable installing these things yourself, have at it, otherwise |
|
185 | If you are comfortable installing these things yourself, have at it, otherwise | |
186 | read on for more details. |
|
186 | read on for more details. | |
187 |
|
187 | |||
188 | readline |
|
188 | readline | |
189 | -------- |
|
189 | -------- | |
190 |
|
190 | |||
191 | In principle, all Python distributions should come with a working |
|
191 | In principle, all Python distributions should come with a working | |
192 | :mod:`readline` module. But, reality is not quite that simple. There are two |
|
192 | :mod:`readline` module. But, reality is not quite that simple. There are two | |
193 | common situations where you won't have a working :mod:`readline` module: |
|
193 | common situations where you won't have a working :mod:`readline` module: | |
194 |
|
194 | |||
195 | * If you are using the built-in Python on Mac OS X. |
|
195 | * If you are using the built-in Python on Mac OS X. | |
196 |
|
196 | |||
197 | * If you are running Windows, which doesn't have a :mod:`readline` module. |
|
197 | * If you are running Windows, which doesn't have a :mod:`readline` module. | |
198 |
|
198 | |||
199 | When IPython is installed with :mod:`setuptools`, (e.g. with `easy_install`), |
|
199 | When IPython is installed with :mod:`setuptools`, (e.g. with `easy_install`), | |
200 | readline is added as a dependency on OS X, and PyReadline on Windows, and will |
|
200 | readline is added as a dependency on OS X, and PyReadline on Windows, and will | |
201 | be installed on your system. However, if you do not use setuptools, you may |
|
201 | be installed on your system. However, if you do not use setuptools, you may | |
202 | have to install one of these packages yourself. |
|
202 | have to install one of these packages yourself. | |
203 |
|
203 | |||
204 | On OS X, the built-in Python doesn't not have :mod:`readline` because of |
|
204 | On OS X, the built-in Python doesn't not have :mod:`readline` because of | |
205 | license issues. Starting with OS X 10.5 (Leopard), Apple's built-in Python has |
|
205 | license issues. Starting with OS X 10.5 (Leopard), Apple's built-in Python has | |
206 | a BSD-licensed not-quite-compatible readline replacement. As of IPython 0.9, |
|
206 | a BSD-licensed not-quite-compatible readline replacement. As of IPython 0.9, | |
207 | many of the issues related to the differences between readline and libedit seem |
|
207 | many of the issues related to the differences between readline and libedit seem | |
208 | to have been resolved. While you may find libedit sufficient, we have |
|
208 | to have been resolved. While you may find libedit sufficient, we have | |
209 | occasional reports of bugs with it and several developers who use OS X as their |
|
209 | occasional reports of bugs with it and several developers who use OS X as their | |
210 | main environment consider libedit unacceptable for productive, regular use with |
|
210 | main environment consider libedit unacceptable for productive, regular use with | |
211 | IPython. |
|
211 | IPython. | |
212 |
|
212 | |||
213 | Therefore, we *strongly* recommend that on OS X you get the full |
|
213 | Therefore, we *strongly* recommend that on OS X you get the full | |
214 | :mod:`readline` module. We will *not* consider completion/history problems to |
|
214 | :mod:`readline` module. We will *not* consider completion/history problems to | |
215 | be bugs for IPython if you are using libedit. |
|
215 | be bugs for IPython if you are using libedit. | |
216 |
|
216 | |||
217 | To get a working :mod:`readline` module, just do (with :mod:`setuptools` |
|
217 | To get a working :mod:`readline` module, just do (with :mod:`setuptools` | |
218 | installed): |
|
218 | installed): | |
219 |
|
219 | |||
220 | .. code-block:: bash |
|
220 | .. code-block:: bash | |
221 |
|
221 | |||
222 | $ easy_install readline |
|
222 | $ easy_install readline | |
223 |
|
223 | |||
224 | .. note:: |
|
224 | .. note:: | |
225 |
|
225 | |||
226 | Other Python distributions on OS X (such as fink, MacPorts and the official |
|
226 | Other Python distributions on OS X (such as fink, MacPorts and the official | |
227 | python.org binaries) already have readline installed so you likely don't |
|
227 | python.org binaries) already have readline installed so you likely don't | |
228 | have to do this step. |
|
228 | have to do this step. | |
229 |
|
229 | |||
230 | If needed, the readline egg can be build and installed from source (see the |
|
230 | If needed, the readline egg can be build and installed from source (see the | |
231 | wiki page at http://ipython.scipy.org/moin/InstallationOSXLeopard). |
|
231 | wiki page at http://ipython.scipy.org/moin/InstallationOSXLeopard). | |
232 |
|
232 | |||
233 | On Windows, you will need the PyReadline module. PyReadline is a separate, |
|
233 | On Windows, you will need the PyReadline module. PyReadline is a separate, | |
234 | Windows only implementation of readline that uses native Windows calls through |
|
234 | Windows only implementation of readline that uses native Windows calls through | |
235 | :mod:`ctypes`. The easiest way of installing PyReadline is you use the binary |
|
235 | :mod:`ctypes`. The easiest way of installing PyReadline is you use the binary | |
236 | installer available `here <https://launchpad.net/pyreadline/+download>`_. |
|
236 | installer available `here <https://launchpad.net/pyreadline/+download>`_. | |
237 |
|
237 | |||
238 | nose |
|
238 | nose | |
239 | ---- |
|
239 | ---- | |
240 |
|
240 | |||
241 | To run the IPython test suite you will need the :mod:`nose` package. Nose |
|
241 | To run the IPython test suite you will need the :mod:`nose` package. Nose | |
242 | provides a great way of sniffing out and running all of the IPython tests. The |
|
242 | provides a great way of sniffing out and running all of the IPython tests. The | |
243 | simplest way of getting nose, is to use :command:`easy_install`: |
|
243 | simplest way of getting nose, is to use :command:`easy_install`: | |
244 |
|
244 | |||
245 | .. code-block:: bash |
|
245 | .. code-block:: bash | |
246 |
|
246 | |||
247 | $ easy_install nose |
|
247 | $ easy_install nose | |
248 |
|
248 | |||
249 | Another way of getting this is to do: |
|
249 | Another way of getting this is to do: | |
250 |
|
250 | |||
251 | .. code-block:: bash |
|
251 | .. code-block:: bash | |
252 |
|
252 | |||
253 | $ easy_install ipython[test] |
|
253 | $ easy_install ipython[test] | |
254 |
|
254 | |||
255 | For more installation options, see the `nose website |
|
255 | For more installation options, see the `nose website | |
256 | <http://somethingaboutorange.com/mrl/projects/nose/>`_. |
|
256 | <http://somethingaboutorange.com/mrl/projects/nose/>`_. | |
257 |
|
257 | |||
258 | Once you have nose installed, you can run IPython's test suite using the |
|
258 | Once you have nose installed, you can run IPython's test suite using the | |
259 | iptest command: |
|
259 | iptest command: | |
260 |
|
260 | |||
261 | .. code-block:: bash |
|
261 | .. code-block:: bash | |
262 |
|
262 | |||
263 | $ iptest |
|
263 | $ iptest | |
264 |
|
264 | |||
265 | pexpect |
|
265 | pexpect | |
266 | ------- |
|
266 | ------- | |
267 |
|
267 | |||
268 | The pexpect_ package is used in IPython's :command:`irunner` script, as well as |
|
268 | The pexpect_ package is used in IPython's :command:`irunner` script, as well as | |
269 | for managing subprocesses. IPython now includes a version of pexpect in |
|
269 | for managing subprocesses. IPython now includes a version of pexpect in | |
270 | :mod:`IPython.external`, but if you have installed pexpect, IPython will use |
|
270 | :mod:`IPython.external`, but if you have installed pexpect, IPython will use | |
271 | that instead. On Unix platforms (including OS X), just do: |
|
271 | that instead. On Unix platforms (including OS X), just do: | |
272 |
|
272 | |||
273 | .. code-block:: bash |
|
273 | .. code-block:: bash | |
274 |
|
274 | |||
275 | $ easy_install pexpect |
|
275 | $ easy_install pexpect | |
276 |
|
276 | |||
277 | Windows users are out of luck as pexpect does not run there. |
|
277 | Windows users are out of luck as pexpect does not run there. | |
278 |
|
278 | |||
279 | Dependencies for IPython.parallel (parallel computing) |
|
279 | Dependencies for IPython.parallel (parallel computing) | |
280 | ====================================================== |
|
280 | ====================================================== | |
281 |
|
281 | |||
282 | :mod:`IPython.kernel` has been replaced by :mod:`IPython.parallel`, |
|
282 | :mod:`IPython.kernel` has been replaced by :mod:`IPython.parallel`, | |
283 | which uses ZeroMQ for all communication. |
|
283 | which uses ZeroMQ for all communication. | |
284 |
|
284 | |||
285 | IPython.parallel provides a nice architecture for parallel computing. The |
|
285 | IPython.parallel provides a nice architecture for parallel computing. The | |
286 | main focus of this architecture is on interactive parallel computing. These |
|
286 | main focus of this architecture is on interactive parallel computing. These | |
287 | features require just one package: PyZMQ. See the next section for PyZMQ |
|
287 | features require just one package: PyZMQ. See the next section for PyZMQ | |
288 | details. |
|
288 | details. | |
289 |
|
289 | |||
290 | On a Unix style platform (including OS X), if you want to use |
|
290 | On a Unix style platform (including OS X), if you want to use | |
291 | :mod:`setuptools`, you can just do: |
|
291 | :mod:`setuptools`, you can just do: | |
292 |
|
292 | |||
293 | .. code-block:: bash |
|
293 | .. code-block:: bash | |
294 |
|
294 | |||
295 | $ easy_install ipython[zmq] # will include pyzmq |
|
295 | $ easy_install ipython[zmq] # will include pyzmq | |
296 |
|
296 | |||
297 | Security in IPython.parallel is provided by SSH tunnels. By default, Linux |
|
297 | Security in IPython.parallel is provided by SSH tunnels. By default, Linux | |
298 | and OSX clients will use the shell ssh command, but on Windows, we also |
|
298 | and OSX clients will use the shell ssh command, but on Windows, we also | |
299 | support tunneling with paramiko_. |
|
299 | support tunneling with paramiko_. | |
300 |
|
300 | |||
301 | Dependencies for IPython.zmq |
|
301 | Dependencies for IPython.zmq | |
302 | ============================ |
|
302 | ============================ | |
303 |
|
303 | |||
304 | pyzmq |
|
304 | pyzmq | |
305 | ----- |
|
305 | ----- | |
306 |
|
306 | |||
307 | IPython 0.11 introduced some new functionality, including a two-process |
|
307 | IPython 0.11 introduced some new functionality, including a two-process | |
308 | execution model using ZeroMQ_ for communication. The Python bindings to ZeroMQ |
|
308 | execution model using ZeroMQ_ for communication. The Python bindings to ZeroMQ | |
309 | are found in the PyZMQ_ project, which is easy_install-able once you have |
|
309 | are found in the PyZMQ_ project, which is easy_install-able once you have | |
310 | ZeroMQ installed. If you are on Python 2.6 or 2.7 on OSX, or 2.7 on Windows, |
|
310 | ZeroMQ installed. If you are on Python 2.6 or 2.7 on OSX, or 2.7 on Windows, | |
311 | pyzmq has eggs that include ZeroMQ itself. |
|
311 | pyzmq has eggs that include ZeroMQ itself. | |
312 |
|
312 | |||
313 | IPython.zmq depends on pyzmq >= 2.1.4. |
|
313 | IPython.zmq depends on pyzmq >= 2.1.4. | |
314 |
|
314 | |||
315 | Dependencies for the IPython QT console |
|
315 | Dependencies for the IPython QT console | |
316 | ======================================= |
|
316 | ======================================= | |
317 |
|
317 | |||
318 | pyzmq |
|
318 | pyzmq | |
319 | ----- |
|
319 | ----- | |
320 |
|
320 | |||
321 | Like the :mod:`IPython.parallel` package, the QT Console requires ZeroMQ and |
|
321 | Like the :mod:`IPython.parallel` package, the QT Console requires ZeroMQ and | |
322 | PyZMQ. |
|
322 | PyZMQ. | |
323 |
|
323 | |||
324 | Qt |
|
324 | Qt | |
325 | -- |
|
325 | -- | |
326 |
|
326 | |||
327 | Also with 0.11, a new GUI was added using the work in :mod:`IPython.zmq`, which |
|
327 | Also with 0.11, a new GUI was added using the work in :mod:`IPython.zmq`, which | |
328 | can be launched with ``ipython qtconsole``. The GUI is built on Qt, and works |
|
328 | can be launched with ``ipython qtconsole``. The GUI is built on Qt, and works | |
329 | with either PyQt, which can be installed from the `PyQt website |
|
329 | with either PyQt, which can be installed from the `PyQt website | |
330 | <http://www.riverbankcomputing.co.uk/>`_, or `PySide |
|
330 | <http://www.riverbankcomputing.co.uk/>`_, or `PySide | |
331 | <http://www.pyside.org/>`_, from Nokia. |
|
331 | <http://www.pyside.org/>`_, from Nokia. | |
332 |
|
332 | |||
333 | pygments |
|
333 | pygments | |
334 | -------- |
|
334 | -------- | |
335 |
|
335 | |||
336 | The syntax-highlighting in ``ipython qtconsole`` is done with the pygments_ |
|
336 | The syntax-highlighting in ``ipython qtconsole`` is done with the pygments_ | |
337 | project, which is easy_install-able. |
|
337 | project, which is easy_install-able. | |
338 |
|
338 | |||
|
339 | .. _installnotebook: | |||
339 |
|
340 | |||
340 | Dependencies for the IPython HTML notebook |
|
341 | Dependencies for the IPython HTML notebook | |
341 | ========================================== |
|
342 | ========================================== | |
342 |
|
343 | |||
343 | The IPython notebook is a notebook-style web interface to IPython and can be |
|
344 | The IPython notebook is a notebook-style web interface to IPython and can be | |
344 | started withe command ``ipython notebook``. |
|
345 | started withe command ``ipython notebook``. | |
345 |
|
346 | |||
346 | pyzmq |
|
347 | pyzmq | |
347 | ----- |
|
348 | ----- | |
348 |
|
349 | |||
349 | Like the :mod:`IPython.parallel` and :mod:`IPython.frontend.qt.console` packages, |
|
350 | Like the :mod:`IPython.parallel` and :mod:`IPython.frontend.qt.console` packages, | |
350 | the HTML notebook requires ZeroMQ and PyZMQ. |
|
351 | the HTML notebook requires ZeroMQ and PyZMQ. | |
351 |
|
352 | |||
352 | Tornado |
|
353 | Tornado | |
353 | ------- |
|
354 | ------- | |
354 |
|
355 | |||
355 |
The IPython notebook uses the Tornado_ project for its HTTP server. |
|
356 | The IPython notebook uses the Tornado_ project for its HTTP server. Tornado 2.1 | |
356 | writing, we require a development version from github, as version 2.0 is *not |
|
357 | is required, in order to support current versions of browsers, due to an update | |
357 | sufficient*. You can either clone their git repository yourself and install it |
|
358 | to the websocket protocol. | |
358 | manually, or install directly from github with:: |
|
|||
359 |
|
359 | |||
360 | easy_install https://github.com/facebook/tornado/tarball/master |
|
|||
361 |
|
360 | |||
362 |
|
||||
363 | MathJax |
|
361 | MathJax | |
364 | ------- |
|
362 | ------- | |
365 |
|
363 | |||
366 | The IPython notebook uses the MathJax_ Javascript library for rendering LaTeX |
|
364 | The IPython notebook uses the MathJax_ Javascript library for rendering LaTeX | |
367 | in web browsers. Because MathJax is large, we don't include it with |
|
365 | in web browsers. Because MathJax is large, we don't include it with | |
368 | IPython. Normally IPython will load MathJax from a CDN, but if you have a slow |
|
366 | IPython. Normally IPython will load MathJax from a CDN, but if you have a slow | |
369 | network connection, or want to use LaTeX without an internet connection at all, |
|
367 | network connection, or want to use LaTeX without an internet connection at all, | |
370 | we do include a utility to aid in downloading MathJax and installing it into |
|
368 | we do include a utility to aid in downloading MathJax and installing it into | |
371 | the proper location:: |
|
369 | the proper location:: | |
372 |
|
370 | |||
373 | from IPython.external.mathjax import install_mathjax |
|
371 | from IPython.external.mathjax import install_mathjax | |
374 | install_mathjax() |
|
372 | install_mathjax() | |
375 |
|
373 | |||
376 | This function does require write access to the IPython install directory, so if you |
|
374 | This function does require write access to the IPython install directory, so if you | |
377 | have a system-wide Python install, it may need to be done from a ``sudo python`` session. |
|
375 | have a system-wide Python install, it may need to be done from a ``sudo python`` session. | |
378 |
|
376 | |||
379 | Browser Compatibility |
|
377 | Browser Compatibility | |
380 | --------------------- |
|
378 | --------------------- | |
381 |
|
379 | |||
382 | The notebook uses WebSockets and the flexible box model. These features are |
|
380 | The notebook uses WebSockets and the flexible box model. These features are | |
383 | available in the following browsers: |
|
381 | available in the following browsers: | |
384 |
|
382 | |||
385 | * Chrome. |
|
383 | * Chrome. | |
386 | * Safari. |
|
384 | * Safari. | |
387 | * Firefox 4 and 5. These browsers have WebSocket support, but it is disabled by |
|
385 | * Firefox 4 and 5. These browsers have WebSocket support, but it is disabled by | |
388 | default. You can enable it by entering ``about:config`` in the URL bar and then |
|
386 | default. You can enable it by entering ``about:config`` in the URL bar and then | |
389 | setting ``network.websocket.enabled`` and ``network.websocket.override-security-block`` |
|
387 | setting ``network.websocket.enabled`` and ``network.websocket.override-security-block`` | |
390 | to ``true``. |
|
388 | to ``true``. | |
391 | * Firefox 6. Starting with version 6, Firefox has WebSocket support enabled by default. |
|
389 | * Firefox 6. Starting with version 6, Firefox has WebSocket support enabled by default. | |
392 |
|
390 | |||
393 | Internet Explorer 9 does not support WebSockets or the flexible box model, but |
|
391 | Internet Explorer 9 does not support WebSockets or the flexible box model, but | |
394 | these features should appear in Internet Explorer 10. |
|
392 | these features should appear in Internet Explorer 10. | |
395 |
|
393 | |||
396 |
|
394 | |||
397 | .. _ZeroMQ: http://www.zeromq.org |
|
395 | .. _ZeroMQ: http://www.zeromq.org | |
398 | .. _PyZMQ: https://github.com/zeromq/pyzmq |
|
396 | .. _PyZMQ: https://github.com/zeromq/pyzmq | |
399 | .. _paramiko: https://github.com/robey/paramiko |
|
397 | .. _paramiko: https://github.com/robey/paramiko | |
400 | .. _pygments: http://pygments.org |
|
398 | .. _pygments: http://pygments.org | |
401 | .. _pexpect: http://www.noah.org/wiki/Pexpect |
|
399 | .. _pexpect: http://www.noah.org/wiki/Pexpect | |
402 | .. _Tornado: http://www.tornadoweb.org |
|
400 | .. _Tornado: http://www.tornadoweb.org | |
403 | .. _MathJax: http://www.mathjax.org |
|
401 | .. _MathJax: http://www.mathjax.org |
@@ -1,213 +1,217 b'' | |||||
1 | .. _htmlnotebook: |
|
1 | .. _htmlnotebook: | |
2 |
|
2 | |||
3 | ========================= |
|
3 | ========================= | |
4 | An HTML Notebook IPython |
|
4 | An HTML Notebook IPython | |
5 | ========================= |
|
5 | ========================= | |
6 |
|
6 | |||
|
7 | .. seealso:: | |||
|
8 | ||||
|
9 | :ref:`Installation requirements <installnotebook>` for the Notebook. | |||
|
10 | ||||
7 | The IPython Notebook consists of two related components: |
|
11 | The IPython Notebook consists of two related components: | |
8 |
|
12 | |||
9 | * An JSON based Notebook document format for recording and distributing |
|
13 | * An JSON based Notebook document format for recording and distributing | |
10 | Python code and rich text. |
|
14 | Python code and rich text. | |
11 | * A web-based user interface for authoring and running notebook documents. |
|
15 | * A web-based user interface for authoring and running notebook documents. | |
12 |
|
16 | |||
13 | The Notebook can be used by starting the Notebook server with the |
|
17 | The Notebook can be used by starting the Notebook server with the | |
14 | command:: |
|
18 | command:: | |
15 |
|
19 | |||
16 | $ ipython notebook |
|
20 | $ ipython notebook | |
17 |
|
21 | |||
18 | Note that by default, the notebook doesn't load pylab, it's just a normal |
|
22 | Note that by default, the notebook doesn't load pylab, it's just a normal | |
19 | IPython session like any other. If you want pylab support, you must use:: |
|
23 | IPython session like any other. If you want pylab support, you must use:: | |
20 |
|
24 | |||
21 | $ ipython notebook --pylab |
|
25 | $ ipython notebook --pylab | |
22 |
|
26 | |||
23 | which will behave similar to the terminal and Qt console versions, using your |
|
27 | which will behave similar to the terminal and Qt console versions, using your | |
24 | default matplotlib backend and providing floating interactive plot windows. If |
|
28 | default matplotlib backend and providing floating interactive plot windows. If | |
25 | you want inline figures, you must manually select the ``inline`` backend:: |
|
29 | you want inline figures, you must manually select the ``inline`` backend:: | |
26 |
|
30 | |||
27 | $ ipython notebook --pylab=inline |
|
31 | $ ipython notebook --pylab=inline | |
28 |
|
32 | |||
29 | You can start the notebook to communicate via a secure protocol mode using a |
|
33 | You can start the notebook to communicate via a secure protocol mode using a | |
30 | self-signed certificate by typing:: |
|
34 | self-signed certificate by typing:: | |
31 |
|
35 | |||
32 | $ ipython notebook --certfile=mycert.pem |
|
36 | $ ipython notebook --certfile=mycert.pem | |
33 |
|
37 | |||
34 | .. note:: |
|
38 | .. note:: | |
35 |
|
39 | |||
36 | A self-signed certificate can be generated with openssl. For example: |
|
40 | A self-signed certificate can be generated with openssl. For example: | |
37 |
|
41 | |||
38 | openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem |
|
42 | openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem | |
39 |
|
43 | |||
40 | This server uses the same ZeroMQ-based two process kernel architecture as |
|
44 | This server uses the same ZeroMQ-based two process kernel architecture as | |
41 | the QT Console as well Tornado for serving HTTP/S requests. Some of the main |
|
45 | the QT Console as well Tornado for serving HTTP/S requests. Some of the main | |
42 | features of the Notebook include: |
|
46 | features of the Notebook include: | |
43 |
|
47 | |||
44 | * Display rich data (png/html/latex/svg) in the browser as a result of |
|
48 | * Display rich data (png/html/latex/svg) in the browser as a result of | |
45 | computations. |
|
49 | computations. | |
46 | * Compose text cells using HTML and Markdown. |
|
50 | * Compose text cells using HTML and Markdown. | |
47 | * Import and export notebook documents in range of formats (.ipynb, .py). |
|
51 | * Import and export notebook documents in range of formats (.ipynb, .py). | |
48 | * In browser syntax highlighting, tab completion and autoindentation. |
|
52 | * In browser syntax highlighting, tab completion and autoindentation. | |
49 | * Inline matplotlib plots that can be stored in Notebook documents and opened |
|
53 | * Inline matplotlib plots that can be stored in Notebook documents and opened | |
50 | later. |
|
54 | later. | |
51 |
|
55 | |||
52 | See :ref:`our installation documentation <install_index>` for directions on |
|
56 | See :ref:`our installation documentation <install_index>` for directions on | |
53 | how to install the notebook and its dependencies. |
|
57 | how to install the notebook and its dependencies. | |
54 |
|
58 | |||
55 | .. note:: |
|
59 | .. note:: | |
56 |
|
60 | |||
57 | You can start more than one notebook server at the same time, if you want to |
|
61 | You can start more than one notebook server at the same time, if you want to | |
58 | work on notebooks in different directories. By default the first notebook |
|
62 | work on notebooks in different directories. By default the first notebook | |
59 | server starts in port 8888, later notebooks search for random ports near |
|
63 | server starts in port 8888, later notebooks search for random ports near | |
60 | that one. You can also manually specify the port with the ``--port`` |
|
64 | that one. You can also manually specify the port with the ``--port`` | |
61 | option. |
|
65 | option. | |
62 |
|
66 | |||
63 |
|
67 | |||
64 | Basic Usage |
|
68 | Basic Usage | |
65 | =========== |
|
69 | =========== | |
66 |
|
70 | |||
67 | The landing page of the notebook server application, which we call the IPython |
|
71 | The landing page of the notebook server application, which we call the IPython | |
68 | Notebook *dashboard*, shows the notebooks currently available in the directory |
|
72 | Notebook *dashboard*, shows the notebooks currently available in the directory | |
69 | in which the application was started, and allows you to create new notebooks. |
|
73 | in which the application was started, and allows you to create new notebooks. | |
70 |
|
74 | |||
71 | A notebook is a combination of two things: |
|
75 | A notebook is a combination of two things: | |
72 |
|
76 | |||
73 | 1. An interactive session connected to an IPython kernel, controlled by a web |
|
77 | 1. An interactive session connected to an IPython kernel, controlled by a web | |
74 | application that can send input to the console and display many types of output |
|
78 | application that can send input to the console and display many types of output | |
75 | (text, graphics, mathematics and more). This is the same kernel used by the |
|
79 | (text, graphics, mathematics and more). This is the same kernel used by the | |
76 | :ref:`Qt console <qtconsole>`, but in this case the web console sends input in |
|
80 | :ref:`Qt console <qtconsole>`, but in this case the web console sends input in | |
77 | persistent cells that you can edit in-place instead of the vertically scrolling |
|
81 | persistent cells that you can edit in-place instead of the vertically scrolling | |
78 | terminal style used by the Qt console. |
|
82 | terminal style used by the Qt console. | |
79 |
|
83 | |||
80 | 2. A document that can save the inputs and outputs of the session as well as |
|
84 | 2. A document that can save the inputs and outputs of the session as well as | |
81 | additional text that accompanies the code but is not meant for execution. In |
|
85 | additional text that accompanies the code but is not meant for execution. In | |
82 | this way, notebook files serve as a complete computational record of a session |
|
86 | this way, notebook files serve as a complete computational record of a session | |
83 | including explanatory text and mathematics, code and resulting figures. These |
|
87 | including explanatory text and mathematics, code and resulting figures. These | |
84 | documents are internally JSON files and are saved with the ``.ipynb`` |
|
88 | documents are internally JSON files and are saved with the ``.ipynb`` | |
85 | extension. |
|
89 | extension. | |
86 |
|
90 | |||
87 | If you have ever used the Mathematica or Sage notebooks (the latter is also |
|
91 | If you have ever used the Mathematica or Sage notebooks (the latter is also | |
88 | web-based__) you should feel right at home. If you have not, you should be |
|
92 | web-based__) you should feel right at home. If you have not, you should be | |
89 | able to learn how to use it in just a few minutes. |
|
93 | able to learn how to use it in just a few minutes. | |
90 |
|
94 | |||
91 | .. __: http://sagenb.org |
|
95 | .. __: http://sagenb.org | |
92 |
|
96 | |||
93 |
|
97 | |||
94 | Creating and editing notebooks |
|
98 | Creating and editing notebooks | |
95 | ------------------------------ |
|
99 | ------------------------------ | |
96 |
|
100 | |||
97 | You can create new notebooks from the dashboard with the ``New Notebook`` |
|
101 | You can create new notebooks from the dashboard with the ``New Notebook`` | |
98 | button or open existing ones by clicking on their name. Once in a notebook, |
|
102 | button or open existing ones by clicking on their name. Once in a notebook, | |
99 | your browser tab will reflect the name of that notebook (prefixed with "IPy:"). |
|
103 | your browser tab will reflect the name of that notebook (prefixed with "IPy:"). | |
100 | The URL for that notebook is not meant to be human-readable and is *not* |
|
104 | The URL for that notebook is not meant to be human-readable and is *not* | |
101 | persistent across invocations of the notebook server. |
|
105 | persistent across invocations of the notebook server. | |
102 |
|
106 | |||
103 | You can also drag and drop into the area listing files any python file: it |
|
107 | You can also drag and drop into the area listing files any python file: it | |
104 | will be imported into a notebook with the same name (but ``.ipynb`` extension) |
|
108 | will be imported into a notebook with the same name (but ``.ipynb`` extension) | |
105 | located in the directory where the notebook server was started. This notebook |
|
109 | located in the directory where the notebook server was started. This notebook | |
106 | will consist of a single cell with all the code in the file, which you can |
|
110 | will consist of a single cell with all the code in the file, which you can | |
107 | later manually partition into individual cells for gradual execution, add text |
|
111 | later manually partition into individual cells for gradual execution, add text | |
108 | and graphics, etc. |
|
112 | and graphics, etc. | |
109 |
|
113 | |||
110 | Workflow and limitations |
|
114 | Workflow and limitations | |
111 | ------------------------ |
|
115 | ------------------------ | |
112 |
|
116 | |||
113 | The normal workflow in a notebook is quite similar to a normal IPython session, |
|
117 | The normal workflow in a notebook is quite similar to a normal IPython session, | |
114 | with the difference that you can edit a cell in-place multiple times until you |
|
118 | with the difference that you can edit a cell in-place multiple times until you | |
115 | obtain the desired results rather than having to rerun separate scripts with |
|
119 | obtain the desired results rather than having to rerun separate scripts with | |
116 | the ``%run`` magic (though magics also work in the notebook). Typically |
|
120 | the ``%run`` magic (though magics also work in the notebook). Typically | |
117 | you'll work on a problem in pieces, organizing related pieces into cells and |
|
121 | you'll work on a problem in pieces, organizing related pieces into cells and | |
118 | moving forward as previous parts work correctly. This is much more convenient |
|
122 | moving forward as previous parts work correctly. This is much more convenient | |
119 | for interactive exploration than breaking up a computation into scripts that |
|
123 | for interactive exploration than breaking up a computation into scripts that | |
120 | must be executed together, especially if parts of them take a long time to run |
|
124 | must be executed together, especially if parts of them take a long time to run | |
121 | (you can use tricks with namespaces and ``%run -i``, but we think the notebook |
|
125 | (you can use tricks with namespaces and ``%run -i``, but we think the notebook | |
122 | is a more natural solution for that kind of problem). |
|
126 | is a more natural solution for that kind of problem). | |
123 |
|
127 | |||
124 | The only significant limitation the notebook currently has, compared to the qt |
|
128 | The only significant limitation the notebook currently has, compared to the qt | |
125 | console, is that it can not run any code that expects input from the kernel |
|
129 | console, is that it can not run any code that expects input from the kernel | |
126 | (such as scripts that call :func:`raw_input`). Very importantly, this means |
|
130 | (such as scripts that call :func:`raw_input`). Very importantly, this means | |
127 | that the ``%debug`` magic does *not* work in the notebook! We intend to |
|
131 | that the ``%debug`` magic does *not* work in the notebook! We intend to | |
128 | correct this limitation, but in the meantime, there is a way to debug problems |
|
132 | correct this limitation, but in the meantime, there is a way to debug problems | |
129 | in the notebook: you can attach a Qt console to your existing notebook kernel, |
|
133 | in the notebook: you can attach a Qt console to your existing notebook kernel, | |
130 | and run ``%debug`` from the Qt console. Simply look for the lines in the |
|
134 | and run ``%debug`` from the Qt console. Simply look for the lines in the | |
131 | terminal where you started the kernel that read something like:: |
|
135 | terminal where you started the kernel that read something like:: | |
132 |
|
136 | |||
133 | [IPKernelApp] To connect another client to this kernel, use: |
|
137 | [IPKernelApp] To connect another client to this kernel, use: | |
134 | [IPKernelApp] --existing --shell=53328 --iopub=53817 --stdin=34736 --hb=45543 |
|
138 | [IPKernelApp] --existing --shell=53328 --iopub=53817 --stdin=34736 --hb=45543 | |
135 |
|
139 | |||
136 | and then start a qt console pointing to that kernel:: |
|
140 | and then start a qt console pointing to that kernel:: | |
137 |
|
141 | |||
138 | ipython qtconsole --existing --shell=53328 --iopub=53817 --stdin=34736 --hb=45543 |
|
142 | ipython qtconsole --existing --shell=53328 --iopub=53817 --stdin=34736 --hb=45543 | |
139 |
|
143 | |||
140 |
|
144 | |||
141 | Text input |
|
145 | Text input | |
142 | ---------- |
|
146 | ---------- | |
143 |
|
147 | |||
144 | In addition to code cells and the output they procude (such as figures), you |
|
148 | In addition to code cells and the output they procude (such as figures), you | |
145 | can also type text not meant for execution. To type text, change the type of a |
|
149 | can also type text not meant for execution. To type text, change the type of a | |
146 | cell from ``Code`` to ``Markdown`` by using the button or the :kbd:`Ctrl-m m` |
|
150 | cell from ``Code`` to ``Markdown`` by using the button or the :kbd:`Ctrl-m m` | |
147 | keybinding (see below). You can then type any text in Markdown_ syntax, as |
|
151 | keybinding (see below). You can then type any text in Markdown_ syntax, as | |
148 | well as mathematical expressions if you use ``$...$`` for inline math or |
|
152 | well as mathematical expressions if you use ``$...$`` for inline math or | |
149 | ``$$...$$`` for displayed math. |
|
153 | ``$$...$$`` for displayed math. | |
150 |
|
154 | |||
151 | Exporting a notebook |
|
155 | Exporting a notebook | |
152 | -------------------- |
|
156 | -------------------- | |
153 |
|
157 | |||
154 | If you want to provide others with a static HTML or PDF view of your notebook, |
|
158 | If you want to provide others with a static HTML or PDF view of your notebook, | |
155 | use the ``Print`` button. This opens a static view of the document, which you |
|
159 | use the ``Print`` button. This opens a static view of the document, which you | |
156 | can print to PDF using your operating system's facilities, or save to a file |
|
160 | can print to PDF using your operating system's facilities, or save to a file | |
157 | with your web browser's 'Save' option (note that typically, this will create |
|
161 | with your web browser's 'Save' option (note that typically, this will create | |
158 | both an html file *and* a directory called `notebook_name_files` next to it |
|
162 | both an html file *and* a directory called `notebook_name_files` next to it | |
159 | that contains all the necessary style information, so if you intend to share |
|
163 | that contains all the necessary style information, so if you intend to share | |
160 | this, you must send the directory along with the main html file). |
|
164 | this, you must send the directory along with the main html file). | |
161 |
|
165 | |||
162 | The `Download` button lets you save a notebook file to the Download area |
|
166 | The `Download` button lets you save a notebook file to the Download area | |
163 | configured by your web browser (particularly useful if you are running the |
|
167 | configured by your web browser (particularly useful if you are running the | |
164 | notebook server on a remote host and need a file locally). The notebook is |
|
168 | notebook server on a remote host and need a file locally). The notebook is | |
165 | saved by default with the ``.ipynb`` extension and the files contain JSON data |
|
169 | saved by default with the ``.ipynb`` extension and the files contain JSON data | |
166 | that is not meant for human editing or consumption. But you can always export |
|
170 | that is not meant for human editing or consumption. But you can always export | |
167 | the input part of a notebook to a plain python script by choosing Python format |
|
171 | the input part of a notebook to a plain python script by choosing Python format | |
168 | in the `Download` drop list. This removes all output and saves the text cells |
|
172 | in the `Download` drop list. This removes all output and saves the text cells | |
169 | in comment areas. |
|
173 | in comment areas. | |
170 |
|
174 | |||
171 | .. warning:: |
|
175 | .. warning:: | |
172 |
|
176 | |||
173 | While in simple cases you can roundtrip a notebook to Python, edit the |
|
177 | While in simple cases you can roundtrip a notebook to Python, edit the | |
174 | python file and import it back without loss, this is in general *not |
|
178 | python file and import it back without loss, this is in general *not | |
175 | guaranteed to work at all*. As the notebook format evolves in complexity, |
|
179 | guaranteed to work at all*. As the notebook format evolves in complexity, | |
176 | there will be attributes of the notebook that will not survive a roundtrip |
|
180 | there will be attributes of the notebook that will not survive a roundtrip | |
177 | through the Python form. You should think of the Python format as a way to |
|
181 | through the Python form. You should think of the Python format as a way to | |
178 | output a script version of a notebook and the import capabilities as a way |
|
182 | output a script version of a notebook and the import capabilities as a way | |
179 | to load existing code to get a notebook started. But the Python version is |
|
183 | to load existing code to get a notebook started. But the Python version is | |
180 | *not* an alternate notebook format. |
|
184 | *not* an alternate notebook format. | |
181 |
|
185 | |||
182 |
|
186 | |||
183 | Keyboard use |
|
187 | Keyboard use | |
184 | ------------ |
|
188 | ------------ | |
185 |
|
189 | |||
186 | All actions in the notebook can be achieved with the mouse, but we have also |
|
190 | All actions in the notebook can be achieved with the mouse, but we have also | |
187 | added keyboard shortcuts for the most common ones, so that productive use of |
|
191 | added keyboard shortcuts for the most common ones, so that productive use of | |
188 | the notebook can be achieved with minimal mouse intervention. The main |
|
192 | the notebook can be achieved with minimal mouse intervention. The main | |
189 | key bindings you need to remember are: |
|
193 | key bindings you need to remember are: | |
190 |
|
194 | |||
191 | * :kbd:`Shift-Enter`: execute the current cell (similar to the Qt console), |
|
195 | * :kbd:`Shift-Enter`: execute the current cell (similar to the Qt console), | |
192 | show output (if any) and create a new cell below. Note that in the notebook, |
|
196 | show output (if any) and create a new cell below. Note that in the notebook, | |
193 | simply using :kbd:`Enter` *never* forces execution, it simply inserts a new |
|
197 | simply using :kbd:`Enter` *never* forces execution, it simply inserts a new | |
194 | line in the current cell. Therefore, in the notebook you must always use |
|
198 | line in the current cell. Therefore, in the notebook you must always use | |
195 | :kbd:`Shift-Enter` to get execution (or use the mouse and click on the ``Run |
|
199 | :kbd:`Shift-Enter` to get execution (or use the mouse and click on the ``Run | |
196 | Selected`` button). |
|
200 | Selected`` button). | |
197 |
|
201 | |||
198 | * :kbd:`Ctrl-Enter`: execute the current cell in "terminal mode", where any |
|
202 | * :kbd:`Ctrl-Enter`: execute the current cell in "terminal mode", where any | |
199 | output is shown but the cursor cursor stays in the current cell, whose input |
|
203 | output is shown but the cursor cursor stays in the current cell, whose input | |
200 | area is flushed empty. This is convenient to do quick in-place experiments |
|
204 | area is flushed empty. This is convenient to do quick in-place experiments | |
201 | or query things like filesystem content without creating additional cells you |
|
205 | or query things like filesystem content without creating additional cells you | |
202 | may not want saved in your notebook. |
|
206 | may not want saved in your notebook. | |
203 |
|
207 | |||
204 | * :kbd:`Ctrl-m`: this is the prefix for all other keybindings, which consist |
|
208 | * :kbd:`Ctrl-m`: this is the prefix for all other keybindings, which consist | |
205 | of an additional single letter. Type :kbd:`Ctrl-m h` (that is, the sole |
|
209 | of an additional single letter. Type :kbd:`Ctrl-m h` (that is, the sole | |
206 | letter :kbd:`h` after :kbd:`Ctrl-m`) and IPython will show you the remaining |
|
210 | letter :kbd:`h` after :kbd:`Ctrl-m`) and IPython will show you the remaining | |
207 | available keybindings. |
|
211 | available keybindings. | |
208 |
|
212 | |||
209 |
|
213 | |||
210 | Notebook document format |
|
214 | Notebook document format | |
211 | ======================== |
|
215 | ======================== | |
212 |
|
216 | |||
213 |
|
217 |
General Comments 0
You need to be logged in to leave comments.
Login now