##// END OF EJS Templates
Merging in changes from Fernando's branch.
Brian Granger -
r1709:27050739 merge
parent child Browse files
Show More
@@ -0,0 +1,423 b''
1 """
2 Defines a docutils directive for inserting inheritance diagrams.
3
4 Provide the directive with one or more classes or modules (separated
5 by whitespace). For modules, all of the classes in that module will
6 be used.
7
8 Example::
9
10 Given the following classes:
11
12 class A: pass
13 class B(A): pass
14 class C(A): pass
15 class D(B, C): pass
16 class E(B): pass
17
18 .. inheritance-diagram: D E
19
20 Produces a graph like the following:
21
22 A
23 / \
24 B C
25 / \ /
26 E D
27
28 The graph is inserted as a PNG+image map into HTML and a PDF in
29 LaTeX.
30 """
31
32 import inspect
33 import os
34 import re
35 import subprocess
36 try:
37 from hashlib import md5
38 except ImportError:
39 from md5 import md5
40
41 from docutils.nodes import Body, Element
42 from docutils.writers.html4css1 import HTMLTranslator
43 from sphinx.latexwriter import LaTeXTranslator
44 from docutils.parsers.rst import directives
45 from sphinx.roles import xfileref_role
46
47 class DotException(Exception):
48 pass
49
50 class InheritanceGraph(object):
51 """
52 Given a list of classes, determines the set of classes that
53 they inherit from all the way to the root "object", and then
54 is able to generate a graphviz dot graph from them.
55 """
56 def __init__(self, class_names, show_builtins=False):
57 """
58 *class_names* is a list of child classes to show bases from.
59
60 If *show_builtins* is True, then Python builtins will be shown
61 in the graph.
62 """
63 self.class_names = class_names
64 self.classes = self._import_classes(class_names)
65 self.all_classes = self._all_classes(self.classes)
66 if len(self.all_classes) == 0:
67 raise ValueError("No classes found for inheritance diagram")
68 self.show_builtins = show_builtins
69
70 py_sig_re = re.compile(r'''^([\w.]*\.)? # class names
71 (\w+) \s* $ # optionally arguments
72 ''', re.VERBOSE)
73
74 def _import_class_or_module(self, name):
75 """
76 Import a class using its fully-qualified *name*.
77 """
78 try:
79 path, base = self.py_sig_re.match(name).groups()
80 except:
81 raise ValueError(
82 "Invalid class or module '%s' specified for inheritance diagram" % name)
83 fullname = (path or '') + base
84 path = (path and path.rstrip('.'))
85 if not path:
86 path = base
87 if not path:
88 raise ValueError(
89 "Invalid class or module '%s' specified for inheritance diagram" % name)
90 try:
91 module = __import__(path, None, None, [])
92 except ImportError:
93 raise ValueError(
94 "Could not import class or module '%s' specified for inheritance diagram" % name)
95
96 try:
97 todoc = module
98 for comp in fullname.split('.')[1:]:
99 todoc = getattr(todoc, comp)
100 except AttributeError:
101 raise ValueError(
102 "Could not find class or module '%s' specified for inheritance diagram" % name)
103
104 # If a class, just return it
105 if inspect.isclass(todoc):
106 return [todoc]
107 elif inspect.ismodule(todoc):
108 classes = []
109 for cls in todoc.__dict__.values():
110 if inspect.isclass(cls) and cls.__module__ == todoc.__name__:
111 classes.append(cls)
112 return classes
113 raise ValueError(
114 "'%s' does not resolve to a class or module" % name)
115
116 def _import_classes(self, class_names):
117 """
118 Import a list of classes.
119 """
120 classes = []
121 for name in class_names:
122 classes.extend(self._import_class_or_module(name))
123 return classes
124
125 def _all_classes(self, classes):
126 """
127 Return a list of all classes that are ancestors of *classes*.
128 """
129 all_classes = {}
130
131 def recurse(cls):
132 all_classes[cls] = None
133 for c in cls.__bases__:
134 if c not in all_classes:
135 recurse(c)
136
137 for cls in classes:
138 recurse(cls)
139
140 return all_classes.keys()
141
142 def class_name(self, cls, parts=0):
143 """
144 Given a class object, return a fully-qualified name. This
145 works for things I've tested in matplotlib so far, but may not
146 be completely general.
147 """
148 module = cls.__module__
149 if module == '__builtin__':
150 fullname = cls.__name__
151 else:
152 fullname = "%s.%s" % (module, cls.__name__)
153 if parts == 0:
154 return fullname
155 name_parts = fullname.split('.')
156 return '.'.join(name_parts[-parts:])
157
158 def get_all_class_names(self):
159 """
160 Get all of the class names involved in the graph.
161 """
162 return [self.class_name(x) for x in self.all_classes]
163
164 # These are the default options for graphviz
165 default_graph_options = {
166 "rankdir": "LR",
167 "size": '"8.0, 12.0"'
168 }
169 default_node_options = {
170 "shape": "box",
171 "fontsize": 10,
172 "height": 0.25,
173 "fontname": "Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",
174 "style": '"setlinewidth(0.5)"'
175 }
176 default_edge_options = {
177 "arrowsize": 0.5,
178 "style": '"setlinewidth(0.5)"'
179 }
180
181 def _format_node_options(self, options):
182 return ','.join(["%s=%s" % x for x in options.items()])
183 def _format_graph_options(self, options):
184 return ''.join(["%s=%s;\n" % x for x in options.items()])
185
186 def generate_dot(self, fd, name, parts=0, urls={},
187 graph_options={}, node_options={},
188 edge_options={}):
189 """
190 Generate a graphviz dot graph from the classes that
191 were passed in to __init__.
192
193 *fd* is a Python file-like object to write to.
194
195 *name* is the name of the graph
196
197 *urls* is a dictionary mapping class names to http urls
198
199 *graph_options*, *node_options*, *edge_options* are
200 dictionaries containing key/value pairs to pass on as graphviz
201 properties.
202 """
203 g_options = self.default_graph_options.copy()
204 g_options.update(graph_options)
205 n_options = self.default_node_options.copy()
206 n_options.update(node_options)
207 e_options = self.default_edge_options.copy()
208 e_options.update(edge_options)
209
210 fd.write('digraph %s {\n' % name)
211 fd.write(self._format_graph_options(g_options))
212
213 for cls in self.all_classes:
214 if not self.show_builtins and cls in __builtins__.values():
215 continue
216
217 name = self.class_name(cls, parts)
218
219 # Write the node
220 this_node_options = n_options.copy()
221 url = urls.get(self.class_name(cls))
222 if url is not None:
223 this_node_options['URL'] = '"%s"' % url
224 fd.write(' "%s" [%s];\n' %
225 (name, self._format_node_options(this_node_options)))
226
227 # Write the edges
228 for base in cls.__bases__:
229 if not self.show_builtins and base in __builtins__.values():
230 continue
231
232 base_name = self.class_name(base, parts)
233 fd.write(' "%s" -> "%s" [%s];\n' %
234 (base_name, name,
235 self._format_node_options(e_options)))
236 fd.write('}\n')
237
238 def run_dot(self, args, name, parts=0, urls={},
239 graph_options={}, node_options={}, edge_options={}):
240 """
241 Run graphviz 'dot' over this graph, returning whatever 'dot'
242 writes to stdout.
243
244 *args* will be passed along as commandline arguments.
245
246 *name* is the name of the graph
247
248 *urls* is a dictionary mapping class names to http urls
249
250 Raises DotException for any of the many os and
251 installation-related errors that may occur.
252 """
253 try:
254 dot = subprocess.Popen(['dot'] + list(args),
255 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
256 close_fds=True)
257 except OSError:
258 raise DotException("Could not execute 'dot'. Are you sure you have 'graphviz' installed?")
259 except ValueError:
260 raise DotException("'dot' called with invalid arguments")
261 except:
262 raise DotException("Unexpected error calling 'dot'")
263
264 self.generate_dot(dot.stdin, name, parts, urls, graph_options,
265 node_options, edge_options)
266 dot.stdin.close()
267 result = dot.stdout.read()
268 returncode = dot.wait()
269 if returncode != 0:
270 raise DotException("'dot' returned the errorcode %d" % returncode)
271 return result
272
273 class inheritance_diagram(Body, Element):
274 """
275 A docutils node to use as a placeholder for the inheritance
276 diagram.
277 """
278 pass
279
280 def inheritance_diagram_directive_run(class_names, options, state):
281 """
282 Run when the inheritance_diagram directive is first encountered.
283 """
284 node = inheritance_diagram()
285
286 # Create a graph starting with the list of classes
287 graph = InheritanceGraph(class_names)
288
289 # Create xref nodes for each target of the graph's image map and
290 # add them to the doc tree so that Sphinx can resolve the
291 # references to real URLs later. These nodes will eventually be
292 # removed from the doctree after we're done with them.
293 for name in graph.get_all_class_names():
294 refnodes, x = xfileref_role(
295 'class', ':class:`%s`' % name, name, 0, state)
296 node.extend(refnodes)
297 # Store the graph object so we can use it to generate the
298 # dot file later
299 node['graph'] = graph
300 # Store the original content for use as a hash
301 node['parts'] = options.get('parts', 0)
302 node['content'] = " ".join(class_names)
303 return [node]
304
305 def get_graph_hash(node):
306 return md5(node['content'] + str(node['parts'])).hexdigest()[-10:]
307
308 def html_output_graph(self, node):
309 """
310 Output the graph for HTML. This will insert a PNG with clickable
311 image map.
312 """
313 graph = node['graph']
314 parts = node['parts']
315
316 graph_hash = get_graph_hash(node)
317 name = "inheritance%s" % graph_hash
318 png_path = os.path.join('_static', name + ".png")
319
320 path = '_static'
321 source = self.document.attributes['source']
322 count = source.split('/doc/')[-1].count('/')
323 for i in range(count):
324 if os.path.exists(path): break
325 path = '../'+path
326 path = '../'+path #specifically added for matplotlib
327
328 # Create a mapping from fully-qualified class names to URLs.
329 urls = {}
330 for child in node:
331 if child.get('refuri') is not None:
332 urls[child['reftitle']] = child.get('refuri')
333 elif child.get('refid') is not None:
334 urls[child['reftitle']] = '#' + child.get('refid')
335
336 # These arguments to dot will save a PNG file to disk and write
337 # an HTML image map to stdout.
338 image_map = graph.run_dot(['-Tpng', '-o%s' % png_path, '-Tcmapx'],
339 name, parts, urls)
340 return ('<img src="%s/%s.png" usemap="#%s" class="inheritance"/>%s' %
341 (path, name, name, image_map))
342
343 def latex_output_graph(self, node):
344 """
345 Output the graph for LaTeX. This will insert a PDF.
346 """
347 graph = node['graph']
348 parts = node['parts']
349
350 graph_hash = get_graph_hash(node)
351 name = "inheritance%s" % graph_hash
352 pdf_path = os.path.join('_static', name + ".pdf")
353
354 graph.run_dot(['-Tpdf', '-o%s' % pdf_path],
355 name, parts, graph_options={'size': '"6.0,6.0"'})
356 return '\\includegraphics{../../%s}' % pdf_path
357
358 def visit_inheritance_diagram(inner_func):
359 """
360 This is just a wrapper around html/latex_output_graph to make it
361 easier to handle errors and insert warnings.
362 """
363 def visitor(self, node):
364 try:
365 content = inner_func(self, node)
366 except DotException, e:
367 # Insert the exception as a warning in the document
368 warning = self.document.reporter.warning(str(e), line=node.line)
369 warning.parent = node
370 node.children = [warning]
371 else:
372 source = self.document.attributes['source']
373 self.body.append(content)
374 node.children = []
375 return visitor
376
377 def do_nothing(self, node):
378 pass
379
380 options_spec = {
381 'parts': directives.nonnegative_int
382 }
383
384 # Deal with the old and new way of registering directives
385 try:
386 from docutils.parsers.rst import Directive
387 except ImportError:
388 from docutils.parsers.rst.directives import _directives
389 def inheritance_diagram_directive(name, arguments, options, content, lineno,
390 content_offset, block_text, state,
391 state_machine):
392 return inheritance_diagram_directive_run(arguments, options, state)
393 inheritance_diagram_directive.__doc__ = __doc__
394 inheritance_diagram_directive.arguments = (1, 100, 0)
395 inheritance_diagram_directive.options = options_spec
396 inheritance_diagram_directive.content = 0
397 _directives['inheritance-diagram'] = inheritance_diagram_directive
398 else:
399 class inheritance_diagram_directive(Directive):
400 has_content = False
401 required_arguments = 1
402 optional_arguments = 100
403 final_argument_whitespace = False
404 option_spec = options_spec
405
406 def run(self):
407 return inheritance_diagram_directive_run(
408 self.arguments, self.options, self.state)
409 inheritance_diagram_directive.__doc__ = __doc__
410
411 directives.register_directive('inheritance-diagram',
412 inheritance_diagram_directive)
413
414 def setup(app):
415 app.add_node(inheritance_diagram)
416
417 HTMLTranslator.visit_inheritance_diagram = \
418 visit_inheritance_diagram(html_output_graph)
419 HTMLTranslator.depart_inheritance_diagram = do_nothing
420
421 LaTeXTranslator.visit_inheritance_diagram = \
422 visit_inheritance_diagram(latex_output_graph)
423 LaTeXTranslator.depart_inheritance_diagram = do_nothing
@@ -0,0 +1,75 b''
1 from pygments.lexer import Lexer, do_insertions
2 from pygments.lexers.agile import PythonConsoleLexer, PythonLexer, \
3 PythonTracebackLexer
4 from pygments.token import Comment, Generic
5 from sphinx import highlighting
6 import re
7
8 line_re = re.compile('.*?\n')
9
10 class IPythonConsoleLexer(Lexer):
11 """
12 For IPython console output or doctests, such as:
13
14 Tracebacks are not currently supported.
15
16 .. sourcecode:: ipython
17
18 In [1]: a = 'foo'
19
20 In [2]: a
21 Out[2]: 'foo'
22
23 In [3]: print a
24 foo
25
26 In [4]: 1 / 0
27 """
28 name = 'IPython console session'
29 aliases = ['ipython']
30 mimetypes = ['text/x-ipython-console']
31 input_prompt = re.compile("(In \[[0-9]+\]: )|( \.\.\.+:)")
32 output_prompt = re.compile("(Out\[[0-9]+\]: )|( \.\.\.+:)")
33 continue_prompt = re.compile(" \.\.\.+:")
34 tb_start = re.compile("\-+")
35
36 def get_tokens_unprocessed(self, text):
37 pylexer = PythonLexer(**self.options)
38 tblexer = PythonTracebackLexer(**self.options)
39
40 curcode = ''
41 insertions = []
42 for match in line_re.finditer(text):
43 line = match.group()
44 input_prompt = self.input_prompt.match(line)
45 continue_prompt = self.continue_prompt.match(line.rstrip())
46 output_prompt = self.output_prompt.match(line)
47 if line.startswith("#"):
48 insertions.append((len(curcode),
49 [(0, Comment, line)]))
50 elif input_prompt is not None:
51 insertions.append((len(curcode),
52 [(0, Generic.Prompt, input_prompt.group())]))
53 curcode += line[input_prompt.end():]
54 elif continue_prompt is not None:
55 insertions.append((len(curcode),
56 [(0, Generic.Prompt, continue_prompt.group())]))
57 curcode += line[continue_prompt.end():]
58 elif output_prompt is not None:
59 insertions.append((len(curcode),
60 [(0, Generic.Output, output_prompt.group())]))
61 curcode += line[output_prompt.end():]
62 else:
63 if curcode:
64 for item in do_insertions(insertions,
65 pylexer.get_tokens_unprocessed(curcode)):
66 yield item
67 curcode = ''
68 insertions = []
69 yield match.start(), Generic.Output, line
70 if curcode:
71 for item in do_insertions(insertions,
72 pylexer.get_tokens_unprocessed(curcode)):
73 yield item
74
75 highlighting.lexers['ipython'] = IPythonConsoleLexer()
@@ -0,0 +1,87 b''
1 #
2 # A pair of directives for inserting content that will only appear in
3 # either html or latex.
4 #
5
6 from docutils.nodes import Body, Element
7 from docutils.writers.html4css1 import HTMLTranslator
8 from sphinx.latexwriter import LaTeXTranslator
9 from docutils.parsers.rst import directives
10
11 class html_only(Body, Element):
12 pass
13
14 class latex_only(Body, Element):
15 pass
16
17 def run(content, node_class, state, content_offset):
18 text = '\n'.join(content)
19 node = node_class(text)
20 state.nested_parse(content, content_offset, node)
21 return [node]
22
23 try:
24 from docutils.parsers.rst import Directive
25 except ImportError:
26 from docutils.parsers.rst.directives import _directives
27
28 def html_only_directive(name, arguments, options, content, lineno,
29 content_offset, block_text, state, state_machine):
30 return run(content, html_only, state, content_offset)
31
32 def latex_only_directive(name, arguments, options, content, lineno,
33 content_offset, block_text, state, state_machine):
34 return run(content, latex_only, state, content_offset)
35
36 for func in (html_only_directive, latex_only_directive):
37 func.content = 1
38 func.options = {}
39 func.arguments = None
40
41 _directives['htmlonly'] = html_only_directive
42 _directives['latexonly'] = latex_only_directive
43 else:
44 class OnlyDirective(Directive):
45 has_content = True
46 required_arguments = 0
47 optional_arguments = 0
48 final_argument_whitespace = True
49 option_spec = {}
50
51 def run(self):
52 self.assert_has_content()
53 return run(self.content, self.node_class,
54 self.state, self.content_offset)
55
56 class HtmlOnlyDirective(OnlyDirective):
57 node_class = html_only
58
59 class LatexOnlyDirective(OnlyDirective):
60 node_class = latex_only
61
62 directives.register_directive('htmlonly', HtmlOnlyDirective)
63 directives.register_directive('latexonly', LatexOnlyDirective)
64
65 def setup(app):
66 app.add_node(html_only)
67 app.add_node(latex_only)
68
69 # Add visit/depart methods to HTML-Translator:
70 def visit_perform(self, node):
71 pass
72 def depart_perform(self, node):
73 pass
74 def visit_ignore(self, node):
75 node.children = []
76 def depart_ignore(self, node):
77 node.children = []
78
79 HTMLTranslator.visit_html_only = visit_perform
80 HTMLTranslator.depart_html_only = depart_perform
81 HTMLTranslator.visit_latex_only = visit_ignore
82 HTMLTranslator.depart_latex_only = depart_ignore
83
84 LaTeXTranslator.visit_html_only = visit_ignore
85 LaTeXTranslator.depart_html_only = depart_ignore
86 LaTeXTranslator.visit_latex_only = visit_perform
87 LaTeXTranslator.depart_latex_only = depart_perform
@@ -0,0 +1,155 b''
1 """A special directive for including a matplotlib plot.
2
3 Given a path to a .py file, it includes the source code inline, then:
4
5 - On HTML, will include a .png with a link to a high-res .png.
6
7 - On LaTeX, will include a .pdf
8
9 This directive supports all of the options of the `image` directive,
10 except for `target` (since plot will add its own target).
11
12 Additionally, if the :include-source: option is provided, the literal
13 source will be included inline, as well as a link to the source.
14 """
15
16 import sys, os, glob, shutil
17 from docutils.parsers.rst import directives
18
19 try:
20 # docutils 0.4
21 from docutils.parsers.rst.directives.images import align
22 except ImportError:
23 # docutils 0.5
24 from docutils.parsers.rst.directives.images import Image
25 align = Image.align
26
27
28 import matplotlib
29 import IPython.Shell
30 matplotlib.use('Agg')
31 import matplotlib.pyplot as plt
32
33 mplshell = IPython.Shell.MatplotlibShell('mpl')
34
35 options = {'alt': directives.unchanged,
36 'height': directives.length_or_unitless,
37 'width': directives.length_or_percentage_or_unitless,
38 'scale': directives.nonnegative_int,
39 'align': align,
40 'class': directives.class_option,
41 'include-source': directives.flag }
42
43 template = """
44 .. htmlonly::
45
46 [`source code <../%(srcdir)s/%(basename)s.py>`__,
47 `png <../%(srcdir)s/%(basename)s.hires.png>`__,
48 `pdf <../%(srcdir)s/%(basename)s.pdf>`__]
49
50 .. image:: ../%(srcdir)s/%(basename)s.png
51 %(options)s
52
53 .. latexonly::
54 .. image:: ../%(srcdir)s/%(basename)s.pdf
55 %(options)s
56
57 """
58
59 def makefig(fullpath, outdir):
60 """
61 run a pyplot script and save the low and high res PNGs and a PDF in _static
62 """
63
64 fullpath = str(fullpath) # todo, why is unicode breaking this
65 formats = [('png', 100),
66 ('hires.png', 200),
67 ('pdf', 72),
68 ]
69
70 basedir, fname = os.path.split(fullpath)
71 basename, ext = os.path.splitext(fname)
72 all_exists = True
73
74 if basedir != outdir:
75 shutil.copyfile(fullpath, os.path.join(outdir, fname))
76
77 for format, dpi in formats:
78 outname = os.path.join(outdir, '%s.%s' % (basename, format))
79 if not os.path.exists(outname):
80 all_exists = False
81 break
82
83 if all_exists:
84 print ' already have %s'%fullpath
85 return
86
87 print ' building %s'%fullpath
88 plt.close('all') # we need to clear between runs
89 matplotlib.rcdefaults()
90
91 mplshell.magic_run(fullpath)
92 for format, dpi in formats:
93 outname = os.path.join(outdir, '%s.%s' % (basename, format))
94 if os.path.exists(outname): continue
95 plt.savefig(outname, dpi=dpi)
96
97 def run(arguments, options, state_machine, lineno):
98 reference = directives.uri(arguments[0])
99 basedir, fname = os.path.split(reference)
100 basename, ext = os.path.splitext(fname)
101
102 # todo - should we be using the _static dir for the outdir, I am
103 # not sure we want to corrupt that dir with autogenerated files
104 # since it also has permanent files in it which makes it difficult
105 # to clean (save an rm -rf followed by and svn up)
106 srcdir = 'pyplots'
107
108 makefig(os.path.join(srcdir, reference), srcdir)
109
110 # todo: it is not great design to assume the makefile is putting
111 # the figs into the right place, so we may want to do that here instead.
112
113 if options.has_key('include-source'):
114 lines = ['.. literalinclude:: ../pyplots/%(reference)s' % locals()]
115 del options['include-source']
116 else:
117 lines = []
118
119 options = [' :%s: %s' % (key, val) for key, val in
120 options.items()]
121 options = "\n".join(options)
122
123 lines.extend((template % locals()).split('\n'))
124
125 state_machine.insert_input(
126 lines, state_machine.input_lines.source(0))
127 return []
128
129
130 try:
131 from docutils.parsers.rst import Directive
132 except ImportError:
133 from docutils.parsers.rst.directives import _directives
134
135 def plot_directive(name, arguments, options, content, lineno,
136 content_offset, block_text, state, state_machine):
137 return run(arguments, options, state_machine, lineno)
138 plot_directive.__doc__ = __doc__
139 plot_directive.arguments = (1, 0, 1)
140 plot_directive.options = options
141
142 _directives['plot'] = plot_directive
143 else:
144 class plot_directive(Directive):
145 required_arguments = 1
146 optional_arguments = 0
147 final_argument_whitespace = True
148 option_spec = options
149 def run(self):
150 return run(self.arguments, self.options,
151 self.state_machine, self.lineno)
152 plot_directive.__doc__ = __doc__
153
154 directives.register_directive('plot', plot_directive)
155
@@ -1,7 +1,5 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """Release data for the IPython project.
2 """Release data for the IPython project."""
3
4 $Id: Release.py 3002 2008-02-01 07:17:00Z fperez $"""
5
3
6 #*****************************************************************************
4 #*****************************************************************************
7 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
5 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
@@ -23,9 +21,9 b" name = 'ipython'"
23 # bdist_deb does not accept underscores (a Debian convention).
21 # bdist_deb does not accept underscores (a Debian convention).
24
22
25 development = False # change this to False to do a release
23 development = False # change this to False to do a release
26 version_base = '0.9'
24 version_base = '0.9.1'
27 branch = 'ipython'
25 branch = 'ipython'
28 revision = '1124'
26 revision = '1143'
29
27
30 if development:
28 if development:
31 if branch == 'ipython':
29 if branch == 'ipython':
@@ -21,8 +21,77 b' __docformat__ = "restructuredtext en"'
21 # Imports
21 # Imports
22 #-------------------------------------------------------------------------------
22 #-------------------------------------------------------------------------------
23 import string
23 import string
24 import uuid
24
25 import _ast
25 try:
26 import _ast
27 except ImportError:
28 # Python 2.4 hackish workaround.
29 class bunch: pass
30 _ast = bunch()
31 _ast.PyCF_ONLY_AST = 1024
32
33
34
35 try:
36 import uuid
37 except ImportError:
38 # Python 2.4 hackish workaround.
39 class UUID:
40 def __init__(self,bytes):
41 version = 4
42 int = long(('%02x'*16) % tuple(map(ord, bytes)), 16)
43 # Set the variant to RFC 4122.
44 int &= ~(0xc000 << 48L)
45 int |= 0x8000 << 48L
46 # Set the version number.
47 int &= ~(0xf000 << 64L)
48 int |= version << 76L
49 self.__dict__['int'] = int
50
51 def __cmp__(self, other):
52 if isinstance(other, UUID):
53 return cmp(self.int, other.int)
54 return NotImplemented
55
56 def __hash__(self):
57 return hash(self.int)
58
59 def __int__(self):
60 return self.int
61
62 def __repr__(self):
63 return 'UUID(%r)' % str(self)
64
65 def __setattr__(self, name, value):
66 raise TypeError('UUID objects are immutable')
67
68 def __str__(self):
69 hex = '%032x' % self.int
70 return '%s-%s-%s-%s-%s' % (
71 hex[:8], hex[8:12], hex[12:16], hex[16:20], hex[20:])
72
73 def get_bytes(self):
74 bytes = ''
75 for shift in range(0, 128, 8):
76 bytes = chr((self.int >> shift) & 0xff) + bytes
77 return bytes
78
79 bytes = property(get_bytes)
80
81
82 def _u4():
83 "Fake random uuid"
84
85 import random
86 bytes = [chr(random.randrange(256)) for i in range(16)]
87 return UUID(bytes)
88
89 class bunch: pass
90 uuid = bunch()
91 uuid.uuid4 = _u4
92 del _u4
93
94
26
95
27 from IPython.frontend.zopeinterface import (
96 from IPython.frontend.zopeinterface import (
28 Interface,
97 Interface,
@@ -182,16 +182,29 b' class LineFrontEndBase(FrontEndBase):'
182 raw_string = python_string
182 raw_string = python_string
183 # Create a false result, in case there is an exception
183 # Create a false result, in case there is an exception
184 self.last_result = dict(number=self.prompt_number)
184 self.last_result = dict(number=self.prompt_number)
185
186 ## try:
187 ## self.history.input_cache[-1] = raw_string.rstrip()
188 ## result = self.shell.execute(python_string)
189 ## self.last_result = result
190 ## self.render_result(result)
191 ## except:
192 ## self.show_traceback()
193 ## finally:
194 ## self.after_execute()
195
185 try:
196 try:
186 self.history.input_cache[-1] = raw_string.rstrip()
197 try:
187 result = self.shell.execute(python_string)
198 self.history.input_cache[-1] = raw_string.rstrip()
188 self.last_result = result
199 result = self.shell.execute(python_string)
189 self.render_result(result)
200 self.last_result = result
190 except:
201 self.render_result(result)
191 self.show_traceback()
202 except:
203 self.show_traceback()
192 finally:
204 finally:
193 self.after_execute()
205 self.after_execute()
194
206
207
195 #--------------------------------------------------------------------------
208 #--------------------------------------------------------------------------
196 # LineFrontEndBase interface
209 # LineFrontEndBase interface
197 #--------------------------------------------------------------------------
210 #--------------------------------------------------------------------------
@@ -196,17 +196,33 b' This is the wx frontend, by Gael Varoquaux. This is EXPERIMENTAL code."""'
196 # capture it.
196 # capture it.
197 self.capture_output()
197 self.capture_output()
198 self.last_result = dict(number=self.prompt_number)
198 self.last_result = dict(number=self.prompt_number)
199
200 ## try:
201 ## for line in input_string.split('\n'):
202 ## filtered_lines.append(
203 ## self.ipython0.prefilter(line, False).rstrip())
204 ## except:
205 ## # XXX: probably not the right thing to do.
206 ## self.ipython0.showsyntaxerror()
207 ## self.after_execute()
208 ## finally:
209 ## self.release_output()
210
211
199 try:
212 try:
200 for line in input_string.split('\n'):
213 try:
201 filtered_lines.append(
214 for line in input_string.split('\n'):
202 self.ipython0.prefilter(line, False).rstrip())
215 filtered_lines.append(
203 except:
216 self.ipython0.prefilter(line, False).rstrip())
204 # XXX: probably not the right thing to do.
217 except:
205 self.ipython0.showsyntaxerror()
218 # XXX: probably not the right thing to do.
206 self.after_execute()
219 self.ipython0.showsyntaxerror()
220 self.after_execute()
207 finally:
221 finally:
208 self.release_output()
222 self.release_output()
209
223
224
225
210 # Clean up the trailing whitespace, to avoid indentation errors
226 # Clean up the trailing whitespace, to avoid indentation errors
211 filtered_string = '\n'.join(filtered_lines)
227 filtered_string = '\n'.join(filtered_lines)
212 return filtered_string
228 return filtered_string
@@ -19,10 +19,6 b' __docformat__ = "restructuredtext en"'
19 #-------------------------------------------------------------------------------
19 #-------------------------------------------------------------------------------
20 # Imports
20 # Imports
21 #-------------------------------------------------------------------------------
21 #-------------------------------------------------------------------------------
22 import string
23 import uuid
24 import _ast
25
26 try:
22 try:
27 from zope.interface import Interface, Attribute, implements, classProvides
23 from zope.interface import Interface, Attribute, implements, classProvides
28 except ImportError:
24 except ImportError:
@@ -8,8 +8,6 b' which can also be useful as templates for writing new, application-specific'
8 managers.
8 managers.
9 """
9 """
10
10
11 from __future__ import with_statement
12
13 __docformat__ = "restructuredtext en"
11 __docformat__ = "restructuredtext en"
14
12
15 #-------------------------------------------------------------------------------
13 #-------------------------------------------------------------------------------
@@ -1,4 +1,6 b''
1 from __future__ import with_statement
1 #from __future__ import with_statement
2
3 # XXX This file is currently disabled to preserve 2.4 compatibility.
2
4
3 #def test_simple():
5 #def test_simple():
4 if 0:
6 if 0:
@@ -25,17 +27,17 b' if 0:'
25
27
26 mec.pushAll()
28 mec.pushAll()
27
29
28 with parallel as pr:
30 ## with parallel as pr:
29 # A comment
31 ## # A comment
30 remote() # this means the code below only runs remotely
32 ## remote() # this means the code below only runs remotely
31 print 'Hello remote world'
33 ## print 'Hello remote world'
32 x = range(10)
34 ## x = range(10)
33 # Comments are OK
35 ## # Comments are OK
34 # Even misindented.
36 ## # Even misindented.
35 y = x+1
37 ## y = x+1
36
38
37
39
38 with pfor('i',sequence) as pr:
40 ## with pfor('i',sequence) as pr:
39 print x[i]
41 ## print x[i]
40
42
41 print pr.x + pr.y
43 print pr.x + pr.y
@@ -45,7 +45,10 b' def mergesort(list_of_lists, key=None):'
45 for i, itr in enumerate(iter(pl) for pl in list_of_lists):
45 for i, itr in enumerate(iter(pl) for pl in list_of_lists):
46 try:
46 try:
47 item = itr.next()
47 item = itr.next()
48 toadd = (key(item), i, item, itr) if key else (item, i, itr)
48 if key:
49 toadd = (key(item), i, item, itr)
50 else:
51 toadd = (item, i, itr)
49 heap.append(toadd)
52 heap.append(toadd)
50 except StopIteration:
53 except StopIteration:
51 pass
54 pass
1 NO CONTENT: file renamed from docs/source/parallel/parallel_task_old.txt to docs/source/attic/parallel_task_old.txt
NO CONTENT: file renamed from docs/source/parallel/parallel_task_old.txt to docs/source/attic/parallel_task_old.txt
@@ -15,8 +15,8 b" What's new"
15 1.4.2 Bug fixes
15 1.4.2 Bug fixes
16 1.4.3 Backwards incompatible changes
16 1.4.3 Backwards incompatible changes
17 2 Release 0.8.4
17 2 Release 0.8.4
18 3 Release 0.8.2
18 3 Release 0.8.3
19 4 Release 0.8.3
19 4 Release 0.8.2
20 5 Older releases
20 5 Older releases
21 ..
21 ..
22
22
@@ -68,80 +68,84 b' New features'
68 be run using the :command:`iptest` command line program.
68 be run using the :command:`iptest` command line program.
69
69
70 * The notion of a task has been completely reworked. An `ITask` interface has
70 * The notion of a task has been completely reworked. An `ITask` interface has
71 been created. This interface defines the methods that tasks need to implement.
71 been created. This interface defines the methods that tasks need to
72 These methods are now responsible for things like submitting tasks and processing
72 implement. These methods are now responsible for things like submitting
73 results. There are two basic task types: :class:`IPython.kernel.task.StringTask`
73 tasks and processing results. There are two basic task types:
74 (this is the old `Task` object, but renamed) and the new
74 :class:`IPython.kernel.task.StringTask` (this is the old `Task` object, but
75 :class:`IPython.kernel.task.MapTask`, which is based on a function.
75 renamed) and the new :class:`IPython.kernel.task.MapTask`, which is based on
76 a function.
76
77
77 * A new interface, :class:`IPython.kernel.mapper.IMapper` has been defined to
78 * A new interface, :class:`IPython.kernel.mapper.IMapper` has been defined to
78 standardize the idea of a `map` method. This interface has a single
79 standardize the idea of a `map` method. This interface has a single `map`
79 `map` method that has the same syntax as the built-in `map`. We have also defined
80 method that has the same syntax as the built-in `map`. We have also defined
80 a `mapper` factory interface that creates objects that implement
81 a `mapper` factory interface that creates objects that implement
81 :class:`IPython.kernel.mapper.IMapper` for different controllers. Both
82 :class:`IPython.kernel.mapper.IMapper` for different controllers. Both the
82 the multiengine and task controller now have mapping capabilties.
83 multiengine and task controller now have mapping capabilties.
83
84
84 * The parallel function capabilities have been reworks. The major changes are that
85 * The parallel function capabilities have been reworks. The major changes are
85 i) there is now an `@parallel` magic that creates parallel functions, ii)
86 that i) there is now an `@parallel` magic that creates parallel functions,
86 the syntax for mulitple variable follows that of `map`, iii) both the
87 ii) the syntax for mulitple variable follows that of `map`, iii) both the
87 multiengine and task controller now have a parallel function implementation.
88 multiengine and task controller now have a parallel function implementation.
88
89
89 * All of the parallel computing capabilities from `ipython1-dev` have been merged into
90 * All of the parallel computing capabilities from `ipython1-dev` have been
90 IPython proper. This resulted in the following new subpackages:
91 merged into IPython proper. This resulted in the following new subpackages:
91 :mod:`IPython.kernel`, :mod:`IPython.kernel.core`, :mod:`IPython.config`,
92 :mod:`IPython.kernel`, :mod:`IPython.kernel.core`, :mod:`IPython.config`,
92 :mod:`IPython.tools` and :mod:`IPython.testing`.
93 :mod:`IPython.tools` and :mod:`IPython.testing`.
93
94
94 * As part of merging in the `ipython1-dev` stuff, the `setup.py` script and friends
95 * As part of merging in the `ipython1-dev` stuff, the `setup.py` script and
95 have been completely refactored. Now we are checking for dependencies using
96 friends have been completely refactored. Now we are checking for
96 the approach that matplotlib uses.
97 dependencies using the approach that matplotlib uses.
97
98
98 * The documentation has been completely reorganized to accept the documentation
99 * The documentation has been completely reorganized to accept the documentation
99 from `ipython1-dev`.
100 from `ipython1-dev`.
100
101
101 * We have switched to using Foolscap for all of our network protocols in
102 * We have switched to using Foolscap for all of our network protocols in
102 :mod:`IPython.kernel`. This gives us secure connections that are both encrypted
103 :mod:`IPython.kernel`. This gives us secure connections that are both
103 and authenticated.
104 encrypted and authenticated.
104
105
105 * We have a brand new `COPYING.txt` files that describes the IPython license
106 * We have a brand new `COPYING.txt` files that describes the IPython license
106 and copyright. The biggest change is that we are putting "The IPython
107 and copyright. The biggest change is that we are putting "The IPython
107 Development Team" as the copyright holder. We give more details about exactly
108 Development Team" as the copyright holder. We give more details about
108 what this means in this file. All developer should read this and use the new
109 exactly what this means in this file. All developer should read this and use
109 banner in all IPython source code files.
110 the new banner in all IPython source code files.
110
111
111 * sh profile: ./foo runs foo as system command, no need to do !./foo anymore
112 * sh profile: ./foo runs foo as system command, no need to do !./foo anymore
112
113
113 * String lists now support 'sort(field, nums = True)' method (to easily
114 * String lists now support ``sort(field, nums = True)`` method (to easily sort
114 sort system command output). Try it with 'a = !ls -l ; a.sort(1, nums=1)'
115 system command output). Try it with ``a = !ls -l ; a.sort(1, nums=1)``.
115
116
116 * '%cpaste foo' now assigns the pasted block as string list, instead of string
117 * '%cpaste foo' now assigns the pasted block as string list, instead of string
117
118
118 * The ipcluster script now run by default with no security. This is done because
119 * The ipcluster script now run by default with no security. This is done
119 the main usage of the script is for starting things on localhost. Eventually
120 because the main usage of the script is for starting things on localhost.
120 when ipcluster is able to start things on other hosts, we will put security
121 Eventually when ipcluster is able to start things on other hosts, we will put
121 back.
122 security back.
122
123
123 * 'cd --foo' searches directory history for string foo, and jumps to that dir.
124 * 'cd --foo' searches directory history for string foo, and jumps to that dir.
124 Last part of dir name is checked first. If no matches for that are found,
125 Last part of dir name is checked first. If no matches for that are found,
125 look at the whole path.
126 look at the whole path.
126
127
128
127 Bug fixes
129 Bug fixes
128 ---------
130 ---------
129
131
130 * The Windows installer has been fixed. Now all IPython scripts have ``.bat``
132 * The Windows installer has been fixed. Now all IPython scripts have ``.bat``
131 versions created. Also, the Start Menu shortcuts have been updated.
133 versions created. Also, the Start Menu shortcuts have been updated.
132
134
133 * The colors escapes in the multiengine client are now turned off on win32 as they
135 * The colors escapes in the multiengine client are now turned off on win32 as
134 don't print correctly.
136 they don't print correctly.
135
137
136 * The :mod:`IPython.kernel.scripts.ipengine` script was exec'ing mpi_import_statement
138 * The :mod:`IPython.kernel.scripts.ipengine` script was exec'ing
137 incorrectly, which was leading the engine to crash when mpi was enabled.
139 mpi_import_statement incorrectly, which was leading the engine to crash when
140 mpi was enabled.
138
141
139 * A few subpackages has missing `__init__.py` files.
142 * A few subpackages had missing ``__init__.py`` files.
140
143
141 * The documentation is only created if Sphinx is found. Previously, the `setup.py`
144 * The documentation is only created if Sphinx is found. Previously, the
142 script would fail if it was missing.
145 ``setup.py`` script would fail if it was missing.
143
146
144 * Greedy 'cd' completion has been disabled again (it was enabled in 0.8.4)
147 * Greedy ``cd`` completion has been disabled again (it was enabled in 0.8.4) as
148 it caused problems on certain platforms.
145
149
146
150
147 Backwards incompatible changes
151 Backwards incompatible changes
@@ -184,9 +188,9 b' Backwards incompatible changes'
184 reflect the new Foolscap network protocol and the FURL files. Please see the
188 reflect the new Foolscap network protocol and the FURL files. Please see the
185 help for these scripts for details.
189 help for these scripts for details.
186
190
187 * The configuration files for the kernel have changed because of the Foolscap stuff.
191 * The configuration files for the kernel have changed because of the Foolscap
188 If you were using custom config files before, you should delete them and regenerate
192 stuff. If you were using custom config files before, you should delete them
189 new ones.
193 and regenerate new ones.
190
194
191 Changes merged in from IPython1
195 Changes merged in from IPython1
192 -------------------------------
196 -------------------------------
@@ -194,8 +198,8 b' Changes merged in from IPython1'
194 New features
198 New features
195 ............
199 ............
196
200
197 * Much improved ``setup.py`` and ``setupegg.py`` scripts. Because Twisted
201 * Much improved ``setup.py`` and ``setupegg.py`` scripts. Because Twisted and
198 and zope.interface are now easy installable, we can declare them as dependencies
202 zope.interface are now easy installable, we can declare them as dependencies
199 in our setupegg.py script.
203 in our setupegg.py script.
200
204
201 * IPython is now compatible with Twisted 2.5.0 and 8.x.
205 * IPython is now compatible with Twisted 2.5.0 and 8.x.
@@ -222,7 +226,8 b' New features'
222 :func:`blockingCallFromThread` function that is in recent versions of Twisted.
226 :func:`blockingCallFromThread` function that is in recent versions of Twisted.
223
227
224 * Functions can now be pushed/pulled to/from engines using
228 * Functions can now be pushed/pulled to/from engines using
225 :meth:`MultiEngineClient.push_function` and :meth:`MultiEngineClient.pull_function`.
229 :meth:`MultiEngineClient.push_function` and
230 :meth:`MultiEngineClient.pull_function`.
226
231
227 * Gather/scatter are now implemented in the client to reduce the work load
232 * Gather/scatter are now implemented in the client to reduce the work load
228 of the controller and improve performance.
233 of the controller and improve performance.
@@ -234,9 +239,9 b' New features'
234
239
235 * New developer oriented documentation: development guidelines and roadmap.
240 * New developer oriented documentation: development guidelines and roadmap.
236
241
237 * Traditional ``ChangeLog`` has been changed to a more useful ``changes.txt`` file
242 * Traditional ``ChangeLog`` has been changed to a more useful ``changes.txt``
238 that is organized by release and is meant to provide something more relevant
243 file that is organized by release and is meant to provide something more
239 for users.
244 relevant for users.
240
245
241 Bug fixes
246 Bug fixes
242 .........
247 .........
@@ -261,43 +266,41 b' Backwards incompatible changes'
261 convention. This will require users to change references to all names like
266 convention. This will require users to change references to all names like
262 ``queueStatus`` to ``queue_status``.
267 ``queueStatus`` to ``queue_status``.
263
268
264 * Previously, methods like :meth:`MultiEngineClient.push` and
269 * Previously, methods like :meth:`MultiEngineClient.push` and
265 :meth:`MultiEngineClient.push` used ``*args`` and ``**kwargs``. This was
270 :meth:`MultiEngineClient.push` used ``*args`` and ``**kwargs``. This was
266 becoming a problem as we weren't able to introduce new keyword arguments into
271 becoming a problem as we weren't able to introduce new keyword arguments into
267 the API. Now these methods simple take a dict or sequence. This has also allowed
272 the API. Now these methods simple take a dict or sequence. This has also
268 us to get rid of the ``*All`` methods like :meth:`pushAll` and :meth:`pullAll`.
273 allowed us to get rid of the ``*All`` methods like :meth:`pushAll` and
269 These things are now handled with the ``targets`` keyword argument that defaults
274 :meth:`pullAll`. These things are now handled with the ``targets`` keyword
270 to ``'all'``.
275 argument that defaults to ``'all'``.
271
276
272 * The :attr:`MultiEngineClient.magicTargets` has been renamed to
277 * The :attr:`MultiEngineClient.magicTargets` has been renamed to
273 :attr:`MultiEngineClient.targets`.
278 :attr:`MultiEngineClient.targets`.
274
279
275 * All methods in the MultiEngine interface now accept the optional keyword argument
280 * All methods in the MultiEngine interface now accept the optional keyword
276 ``block``.
281 argument ``block``.
277
282
278 * Renamed :class:`RemoteController` to :class:`MultiEngineClient` and
283 * Renamed :class:`RemoteController` to :class:`MultiEngineClient` and
279 :class:`TaskController` to :class:`TaskClient`.
284 :class:`TaskController` to :class:`TaskClient`.
280
285
281 * Renamed the top-level module from :mod:`api` to :mod:`client`.
286 * Renamed the top-level module from :mod:`api` to :mod:`client`.
282
287
283 * Most methods in the multiengine interface now raise a :exc:`CompositeError` exception
288 * Most methods in the multiengine interface now raise a :exc:`CompositeError`
284 that wraps the user's exceptions, rather than just raising the raw user's exception.
289 exception that wraps the user's exceptions, rather than just raising the raw
290 user's exception.
285
291
286 * Changed the ``setupNS`` and ``resultNames`` in the ``Task`` class to ``push``
292 * Changed the ``setupNS`` and ``resultNames`` in the ``Task`` class to ``push``
287 and ``pull``.
293 and ``pull``.
288
294
295
289 Release 0.8.4
296 Release 0.8.4
290 =============
297 =============
291
298
292 Someone needs to describe what went into 0.8.4.
299 This was a quick release to fix an unfortunate bug that slipped into the 0.8.3
300 release. The ``--twisted`` option was disabled, as it turned out to be broken
301 across several platforms.
293
302
294 Release 0.8.2
295 =============
296
303
297 * %pushd/%popd behave differently; now "pushd /foo" pushes CURRENT directory
298 and jumps to /foo. The current behaviour is closer to the documented
299 behaviour, and should not trip anyone.
300
301 Release 0.8.3
304 Release 0.8.3
302 =============
305 =============
303
306
@@ -305,9 +308,18 b' Release 0.8.3'
305 it by passing -pydb command line argument to IPython. Note that setting
308 it by passing -pydb command line argument to IPython. Note that setting
306 it in config file won't work.
309 it in config file won't work.
307
310
311
312 Release 0.8.2
313 =============
314
315 * %pushd/%popd behave differently; now "pushd /foo" pushes CURRENT directory
316 and jumps to /foo. The current behaviour is closer to the documented
317 behaviour, and should not trip anyone.
318
319
308 Older releases
320 Older releases
309 ==============
321 ==============
310
322
311 Changes in earlier releases of IPython are described in the older file ``ChangeLog``.
323 Changes in earlier releases of IPython are described in the older file
312 Please refer to this document for details.
324 ``ChangeLog``. Please refer to this document for details.
313
325
@@ -1,7 +1,6 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 #
2 #
3 # IPython documentation build configuration file, created by
3 # IPython documentation build configuration file.
4 # sphinx-quickstart on Thu May 8 16:45:02 2008.
5
4
6 # NOTE: This file has been edited manually from the auto-generated one from
5 # NOTE: This file has been edited manually from the auto-generated one from
7 # sphinx. Do NOT delete and re-generate. If any changes from sphinx are
6 # sphinx. Do NOT delete and re-generate. If any changes from sphinx are
@@ -21,7 +20,11 b' import sys, os'
21 # If your extensions are in another directory, add it here. If the directory
20 # If your extensions are in another directory, add it here. If the directory
22 # is relative to the documentation root, use os.path.abspath to make it
21 # is relative to the documentation root, use os.path.abspath to make it
23 # absolute, like shown here.
22 # absolute, like shown here.
24 #sys.path.append(os.path.abspath('some/directory'))
23 sys.path.append(os.path.abspath('../sphinxext'))
24
25 # Import support for ipython console session syntax highlighting (lives
26 # in the sphinxext directory defined above)
27 import ipython_console_highlighting
25
28
26 # We load the ipython release info into a dict by explicit execution
29 # We load the ipython release info into a dict by explicit execution
27 iprelease = {}
30 iprelease = {}
@@ -32,7 +35,11 b" execfile('../../IPython/Release.py',iprelease)"
32
35
33 # Add any Sphinx extension module names here, as strings. They can be extensions
36 # Add any Sphinx extension module names here, as strings. They can be extensions
34 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
37 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
35 #extensions = []
38 extensions = ['sphinx.ext.autodoc',
39 'inheritance_diagram', 'only_directives',
40 'ipython_console_highlighting',
41 # 'plot_directive', # disabled for now, needs matplotlib
42 ]
36
43
37 # Add any paths that contain templates here, relative to this directory.
44 # Add any paths that contain templates here, relative to this directory.
38 templates_path = ['_templates']
45 templates_path = ['_templates']
@@ -67,7 +74,7 b" today_fmt = '%B %d, %Y'"
67
74
68 # List of directories, relative to source directories, that shouldn't be searched
75 # List of directories, relative to source directories, that shouldn't be searched
69 # for source files.
76 # for source files.
70 #exclude_dirs = []
77 exclude_dirs = ['attic']
71
78
72 # If true, '()' will be appended to :func: etc. cross-reference text.
79 # If true, '()' will be appended to :func: etc. cross-reference text.
73 #add_function_parentheses = True
80 #add_function_parentheses = True
@@ -135,7 +142,7 b" html_last_updated_fmt = '%b %d, %Y'"
135 #html_file_suffix = ''
142 #html_file_suffix = ''
136
143
137 # Output file base name for HTML help builder.
144 # Output file base name for HTML help builder.
138 htmlhelp_basename = 'IPythondoc'
145 htmlhelp_basename = 'ipythondoc'
139
146
140
147
141 # Options for LaTeX output
148 # Options for LaTeX output
@@ -173,5 +180,8 b" latex_documents = [ ('index', 'ipython.tex', 'IPython Documentation',"
173 #latex_use_modindex = True
180 #latex_use_modindex = True
174
181
175
182
176 # Cleanup: delete release info to avoid pickling errors from sphinx
183 # Cleanup
184 # -------
185 # delete release info to avoid pickling errors from sphinx
186
177 del iprelease
187 del iprelease
@@ -18,6 +18,8 b' time. A hybrid approach of specifying a few options in ipythonrc and'
18 doing the more advanced configuration in ipy_user_conf.py is also
18 doing the more advanced configuration in ipy_user_conf.py is also
19 possible.
19 possible.
20
20
21 .. _ipythonrc:
22
21 The ipythonrc approach
23 The ipythonrc approach
22 ======================
24 ======================
23
25
@@ -36,11 +38,11 b' fairly primitive). Note that these are not python files, and this is'
36 deliberate, because it allows us to do some things which would be quite
38 deliberate, because it allows us to do some things which would be quite
37 tricky to implement if they were normal python files.
39 tricky to implement if they were normal python files.
38
40
39 First, an rcfile can contain permanent default values for almost all
41 First, an rcfile can contain permanent default values for almost all command
40 command line options (except things like -help or -Version). Sec
42 line options (except things like -help or -Version). :ref:`This section
41 `command line options`_ contains a description of all command-line
43 <command_line_options>` contains a description of all command-line
42 options. However, values you explicitly specify at the command line
44 options. However, values you explicitly specify at the command line override
43 override the values defined in the rcfile.
45 the values defined in the rcfile.
44
46
45 Besides command line option values, the rcfile can specify values for
47 Besides command line option values, the rcfile can specify values for
46 certain extra special options which are not available at the command
48 certain extra special options which are not available at the command
@@ -266,13 +268,13 b' which look like this::'
266 IPython profiles
268 IPython profiles
267 ================
269 ================
268
270
269 As we already mentioned, IPython supports the -profile command-line
271 As we already mentioned, IPython supports the -profile command-line option (see
270 option (see sec. `command line options`_). A profile is nothing more
272 :ref:`here <command_line_options>`). A profile is nothing more than a
271 than a particular configuration file like your basic ipythonrc one,
273 particular configuration file like your basic ipythonrc one, but with
272 but with particular customizations for a specific purpose. When you
274 particular customizations for a specific purpose. When you start IPython with
273 start IPython with 'ipython -profile <name>', it assumes that in your
275 'ipython -profile <name>', it assumes that in your IPYTHONDIR there is a file
274 IPYTHONDIR there is a file called ipythonrc-<name> or
276 called ipythonrc-<name> or ipy_profile_<name>.py, and loads it instead of the
275 ipy_profile_<name>.py, and loads it instead of the normal ipythonrc.
277 normal ipythonrc.
276
278
277 This system allows you to maintain multiple configurations which load
279 This system allows you to maintain multiple configurations which load
278 modules, set options, define functions, etc. suitable for different
280 modules, set options, define functions, etc. suitable for different
@@ -11,28 +11,27 b' in a directory named by default $HOME/.ipython. You can change this by'
11 defining the environment variable IPYTHONDIR, or at runtime with the
11 defining the environment variable IPYTHONDIR, or at runtime with the
12 command line option -ipythondir.
12 command line option -ipythondir.
13
13
14 If all goes well, the first time you run IPython it should
14 If all goes well, the first time you run IPython it should automatically create
15 automatically create a user copy of the config directory for you,
15 a user copy of the config directory for you, based on its builtin defaults. You
16 based on its builtin defaults. You can look at the files it creates to
16 can look at the files it creates to learn more about configuring the
17 learn more about configuring the system. The main file you will modify
17 system. The main file you will modify to configure IPython's behavior is called
18 to configure IPython's behavior is called ipythonrc (with a .ini
18 ipythonrc (with a .ini extension under Windows), included for reference
19 extension under Windows), included for reference in `ipythonrc`_
19 :ref:`here <ipythonrc>`. This file is very commented and has many variables you
20 section. This file is very commented and has many variables you can
20 can change to suit your taste, you can find more details :ref:`here
21 change to suit your taste, you can find more details in
21 <customization>`. Here we discuss the basic things you will want to make sure
22 Sec. customization_. Here we discuss the basic things you will want to
22 things are working properly from the beginning.
23 make sure things are working properly from the beginning.
24
23
25
24
26 .. _Accessing help:
25 .. _accessing_help:
27
26
28 Access to the Python help system
27 Access to the Python help system
29 ================================
28 ================================
30
29
31 This is true for Python in general (not just for IPython): you should
30 This is true for Python in general (not just for IPython): you should have an
32 have an environment variable called PYTHONDOCS pointing to the directory
31 environment variable called PYTHONDOCS pointing to the directory where your
33 where your HTML Python documentation lives. In my system it's
32 HTML Python documentation lives. In my system it's
34 /usr/share/doc/python-docs-2.3.4/html, check your local details or ask
33 :file:`/usr/share/doc/python-doc/html`, check your local details or ask your
35 your systems administrator.
34 systems administrator.
36
35
37 This is the directory which holds the HTML version of the Python
36 This is the directory which holds the HTML version of the Python
38 manuals. Unfortunately it seems that different Linux distributions
37 manuals. Unfortunately it seems that different Linux distributions
@@ -40,8 +39,9 b' package these files differently, so you may have to look around a bit.'
40 Below I show the contents of this directory on my system for reference::
39 Below I show the contents of this directory on my system for reference::
41
40
42 [html]> ls
41 [html]> ls
43 about.dat acks.html dist/ ext/ index.html lib/ modindex.html
42 about.html dist/ icons/ lib/ python2.5.devhelp.gz whatsnew/
44 stdabout.dat tut/ about.html api/ doc/ icons/ inst/ mac/ ref/ style.css
43 acks.html doc/ index.html mac/ ref/
44 api/ ext/ inst/ modindex.html tut/
45
45
46 You should really make sure this variable is correctly set so that
46 You should really make sure this variable is correctly set so that
47 Python's pydoc-based help system works. It is a powerful and convenient
47 Python's pydoc-based help system works. It is a powerful and convenient
@@ -108,6 +108,8 b' The following terminals seem to handle the color sequences fine:'
108 support under cygwin, please post to the IPython mailing list so
108 support under cygwin, please post to the IPython mailing list so
109 this issue can be resolved for all users.
109 this issue can be resolved for all users.
110
110
111 .. _pyreadline: https://code.launchpad.net/pyreadline
112
111 These have shown problems:
113 These have shown problems:
112
114
113 * Windows command prompt in WinXP/2k logged into a Linux machine via
115 * Windows command prompt in WinXP/2k logged into a Linux machine via
@@ -157,13 +159,12 b' $HOME/.ipython/ipythonrc and set the colors option to the desired value.'
157 Object details (types, docstrings, source code, etc.)
159 Object details (types, docstrings, source code, etc.)
158 =====================================================
160 =====================================================
159
161
160 IPython has a set of special functions for studying the objects you
162 IPython has a set of special functions for studying the objects you are working
161 are working with, discussed in detail in Sec. `dynamic object
163 with, discussed in detail :ref:`here <dynamic_object_info>`. But this system
162 information`_. But this system relies on passing information which is
164 relies on passing information which is longer than your screen through a data
163 longer than your screen through a data pager, such as the common Unix
165 pager, such as the common Unix less and more programs. In order to be able to
164 less and more programs. In order to be able to see this information in
166 see this information in color, your pager needs to be properly configured. I
165 color, your pager needs to be properly configured. I strongly
167 strongly recommend using less instead of more, as it seems that more simply can
166 recommend using less instead of more, as it seems that more simply can
167 not understand colored text correctly.
168 not understand colored text correctly.
168
169
169 In order to configure less as your default pager, do the following:
170 In order to configure less as your default pager, do the following:
@@ -6,7 +6,7 b' Credits'
6
6
7 IPython is led by Fernando Pérez.
7 IPython is led by Fernando Pérez.
8
8
9 As of early 2006, the following developers have joined the core team:
9 As of this writing, the following developers have joined the core team:
10
10
11 * [Robert Kern] <rkern-AT-enthought.com>: co-mentored the 2005
11 * [Robert Kern] <rkern-AT-enthought.com>: co-mentored the 2005
12 Google Summer of Code project to develop python interactive
12 Google Summer of Code project to develop python interactive
@@ -24,6 +24,20 b' As of early 2006, the following developers have joined the core team:'
24 to the core of IPython and was the maintainer of the main IPython
24 to the core of IPython and was the maintainer of the main IPython
25 trunk from version 0.7.1 to 0.8.4.
25 trunk from version 0.7.1 to 0.8.4.
26
26
27 * [Gael Varoquaux] <gael.varoquaux-AT-normalesup.org>: work on the merged
28 architecture for the interpreter as of version 0.9, implementing a new WX GUI
29 based on this system.
30
31 * [Barry Wark] <barrywark-AT-gmail.com>: implementing a new Cocoa GUI, as well
32 as work on the new interpreter architecture and Twisted support.
33
34 * [Laurent Dufrechou] <laurent.dufrechou-AT-gmail.com>: development of the WX
35 GUI support.
36
37 * [Jörgen Stenarson] <jorgen.stenarson-AT-bostream.nu>: maintainer of the
38 PyReadline project, necessary for IPython under windows.
39
40
27 The IPython project is also very grateful to:
41 The IPython project is also very grateful to:
28
42
29 Bill Bumgarner <bbum-AT-friday.com>: for providing the DPyGetOpt module
43 Bill Bumgarner <bbum-AT-friday.com>: for providing the DPyGetOpt module
@@ -51,9 +65,9 b" an O'Reilly Python editor. His Oct/11/2001 article about IPP and"
51 LazyPython, was what got this project started. You can read it at:
65 LazyPython, was what got this project started. You can read it at:
52 http://www.onlamp.com/pub/a/python/2001/10/11/pythonnews.html.
66 http://www.onlamp.com/pub/a/python/2001/10/11/pythonnews.html.
53
67
54 And last but not least, all the kind IPython users who have emailed new
68 And last but not least, all the kind IPython users who have emailed new code,
55 code, bug reports, fixes, comments and ideas. A brief list follows,
69 bug reports, fixes, comments and ideas. A brief list follows, please let us
56 please let me know if I have ommitted your name by accident:
70 know if we have ommitted your name by accident:
57
71
58 * Dan Milstein <danmil-AT-comcast.net>. A bold refactoring of the
72 * Dan Milstein <danmil-AT-comcast.net>. A bold refactoring of the
59 core prefilter stuff in the IPython interpreter.
73 core prefilter stuff in the IPython interpreter.
@@ -185,4 +199,9 b' please let me know if I have ommitted your name by accident:'
185 * [Alexander Belchenko] <bialix-AT-ukr.net> Improvements for win32
199 * [Alexander Belchenko] <bialix-AT-ukr.net> Improvements for win32
186 paging system.
200 paging system.
187
201
188 * [Will Maier] <willmaier-AT-ml1.net> Official OpenBSD port. No newline at end of file
202 * [Will Maier] <willmaier-AT-ml1.net> Official OpenBSD port.
203
204 * [Ondrej Certik] <ondrej-AT-certik.cz>: set up the IPython docs to use the new
205 Sphinx system used by Python, Matplotlib and many more projects.
206
207 * [Stefan van der Walt] <stefan-AT-sun.ac.za>: support for the new config system.
@@ -24,11 +24,11 b' There are two, no three, main goals of the IPython effort:'
24 to be used from within a variety of GUI applications.
24 to be used from within a variety of GUI applications.
25 3. Implement a system for interactive parallel computing.
25 3. Implement a system for interactive parallel computing.
26
26
27 While the third goal may seem a bit unrelated to the main focus of IPython, it turns
27 While the third goal may seem a bit unrelated to the main focus of IPython, it
28 out that the technologies required for this goal are nearly identical with those
28 turns out that the technologies required for this goal are nearly identical
29 required for goal two. This is the main reason the interactive parallel computing
29 with those required for goal two. This is the main reason the interactive
30 capabilities are being put into IPython proper. Currently the third of these goals is
30 parallel computing capabilities are being put into IPython proper. Currently
31 furthest along.
31 the third of these goals is furthest along.
32
32
33 This document describes IPython from the perspective of developers.
33 This document describes IPython from the perspective of developers.
34
34
@@ -39,51 +39,59 b' Project organization'
39 Subpackages
39 Subpackages
40 -----------
40 -----------
41
41
42 IPython is organized into semi self-contained subpackages. Each of the subpackages will have its own:
42 IPython is organized into semi self-contained subpackages. Each of the
43 subpackages will have its own:
43
44
44 - **Dependencies**. One of the most important things to keep in mind in
45 - **Dependencies**. One of the most important things to keep in mind in
45 partitioning code amongst subpackages, is that they should be used to cleanly
46 partitioning code amongst subpackages, is that they should be used to cleanly
46 encapsulate dependencies.
47 encapsulate dependencies.
48
47 - **Tests**. Each subpackage shoud have its own ``tests`` subdirectory that
49 - **Tests**. Each subpackage shoud have its own ``tests`` subdirectory that
48 contains all of the tests for that package. For information about writing tests
50 contains all of the tests for that package. For information about writing
49 for IPython, see the `Testing System`_ section of this document.
51 tests for IPython, see the `Testing System`_ section of this document.
50 - **Configuration**. Each subpackage should have its own ``config`` subdirectory
52
51 that contains the configuration information for the components of the
53 - **Configuration**. Each subpackage should have its own ``config``
52 subpackage. For information about how the IPython configuration system
54 subdirectory that contains the configuration information for the components
53 works, see the `Configuration System`_ section of this document.
55 of the subpackage. For information about how the IPython configuration
54 - **Scripts**. Each subpackage should have its own ``scripts`` subdirectory that
56 system works, see the `Configuration System`_ section of this document.
55 contains all of the command line scripts associated with the subpackage.
57
58 - **Scripts**. Each subpackage should have its own ``scripts`` subdirectory
59 that contains all of the command line scripts associated with the subpackage.
56
60
57 Installation and dependencies
61 Installation and dependencies
58 -----------------------------
62 -----------------------------
59
63
60 IPython will not use `setuptools`_ for installation. Instead, we will use standard
64 IPython will not use `setuptools`_ for installation. Instead, we will use
61 ``setup.py`` scripts that use `distutils`_. While there are a number a extremely nice
65 standard ``setup.py`` scripts that use `distutils`_. While there are a number a
62 features that `setuptools`_ has (like namespace packages), the current implementation
66 extremely nice features that `setuptools`_ has (like namespace packages), the
63 of `setuptools`_ has performance problems, particularly on shared file systems. In
67 current implementation of `setuptools`_ has performance problems, particularly
64 particular, when Python packages are installed on NSF file systems, import times
68 on shared file systems. In particular, when Python packages are installed on
65 become much too long (up towards 10 seconds).
69 NSF file systems, import times become much too long (up towards 10 seconds).
66
70
67 Because IPython is being used extensively in the context of high performance
71 Because IPython is being used extensively in the context of high performance
68 computing, where performance is critical but shared file systems are common, we feel
72 computing, where performance is critical but shared file systems are common, we
69 these performance hits are not acceptable. Thus, until the performance problems
73 feel these performance hits are not acceptable. Thus, until the performance
70 associated with `setuptools`_ are addressed, we will stick with plain `distutils`_. We
74 problems associated with `setuptools`_ are addressed, we will stick with plain
71 are hopeful that these problems will be addressed and that we will eventually begin
75 `distutils`_. We are hopeful that these problems will be addressed and that we
72 using `setuptools`_. Because of this, we are trying to organize IPython in a way that
76 will eventually begin using `setuptools`_. Because of this, we are trying to
73 will make the eventual transition to `setuptools`_ as painless as possible.
77 organize IPython in a way that will make the eventual transition to
74
78 `setuptools`_ as painless as possible.
75 Because we will be using `distutils`_, there will be no method for automatically installing dependencies. Instead, we are following the approach of `Matplotlib`_ which can be summarized as follows:
79
80 Because we will be using `distutils`_, there will be no method for
81 automatically installing dependencies. Instead, we are following the approach
82 of `Matplotlib`_ which can be summarized as follows:
76
83
77 - Distinguish between required and optional dependencies. However, the required
84 - Distinguish between required and optional dependencies. However, the required
78 dependencies for IPython should be only the Python standard library.
85 dependencies for IPython should be only the Python standard library.
79 - Upon installation check to see which optional dependencies are present and tell
86
80 the user which parts of IPython need which optional dependencies.
87 - Upon installation check to see which optional dependencies are present and
88 tell the user which parts of IPython need which optional dependencies.
81
89
82 It is absolutely critical that each subpackage of IPython has a clearly specified set
90 It is absolutely critical that each subpackage of IPython has a clearly
83 of dependencies and that dependencies are not carelessly inherited from other IPython
91 specified set of dependencies and that dependencies are not carelessly
84 subpackages. Furthermore, tests that have certain dependencies should not fail if
92 inherited from other IPython subpackages. Furthermore, tests that have certain
85 those dependencies are not present. Instead they should be skipped and print a
93 dependencies should not fail if those dependencies are not present. Instead
86 message.
94 they should be skipped and print a message.
87
95
88 .. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools
96 .. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools
89 .. _distutils: http://docs.python.org/lib/module-distutils.html
97 .. _distutils: http://docs.python.org/lib/module-distutils.html
@@ -106,9 +114,10 b' Specific subpackages'
106
114
107 ``frontends``
115 ``frontends``
108 The various frontends for IPython. A frontend is the end-user application
116 The various frontends for IPython. A frontend is the end-user application
109 that exposes the capabilities of IPython to the user. The most basic frontend
117 that exposes the capabilities of IPython to the user. The most basic
110 will simply be a terminal based application that looks just like today 's
118 frontend will simply be a terminal based application that looks just like
111 IPython. Other frontends will likely be more powerful and based on GUI toolkits.
119 today 's IPython. Other frontends will likely be more powerful and based
120 on GUI toolkits.
112
121
113 ``notebook``
122 ``notebook``
114 An application that allows users to work with IPython notebooks.
123 An application that allows users to work with IPython notebooks.
@@ -120,10 +129,12 b' Specific subpackages'
120 Version control
129 Version control
121 ===============
130 ===============
122
131
123 In the past, IPython development has been done using `Subversion`__. Recently, we made the transition to using `Bazaar`__ and `Launchpad`__. This makes it much easier for people
132 In the past, IPython development has been done using `Subversion`__. Recently,
124 to contribute code to IPython. Here is a sketch of how to use Bazaar for IPython
133 we made the transition to using `Bazaar`__ and `Launchpad`__. This makes it
125 development. First, you should install Bazaar. After you have done that, make
134 much easier for people to contribute code to IPython. Here is a sketch of how
126 sure that it is working by getting the latest main branch of IPython::
135 to use Bazaar for IPython development. First, you should install Bazaar.
136 After you have done that, make sure that it is working by getting the latest
137 main branch of IPython::
127
138
128 $ bzr branch lp:ipython
139 $ bzr branch lp:ipython
129
140
@@ -131,17 +142,17 b' Now you can create a new branch for you to do your work in::'
131
142
132 $ bzr branch ipython ipython-mybranch
143 $ bzr branch ipython ipython-mybranch
133
144
134 The typical work cycle in this branch will be to make changes in `ipython-mybranch`
145 The typical work cycle in this branch will be to make changes in
135 and then commit those changes using the commit command::
146 ``ipython-mybranch`` and then commit those changes using the commit command::
136
147
137 $ ...do work in ipython-mybranch...
148 $ ...do work in ipython-mybranch...
138 $ bzr ci -m "the commit message goes here"
149 $ bzr ci -m "the commit message goes here"
139
150
140 Please note that since we now don't use an old-style linear ChangeLog
151 Please note that since we now don't use an old-style linear ChangeLog (that
141 (that tends to cause problems with distributed version control
152 tends to cause problems with distributed version control systems), you should
142 systems), you should ensure that your log messages are reasonably
153 ensure that your log messages are reasonably detailed. Use a docstring-like
143 detailed. Use a docstring-like approach in the commit messages
154 approach in the commit messages (including the second line being left
144 (including the second line being left *blank*)::
155 *blank*)::
145
156
146 Single line summary of changes being committed.
157 Single line summary of changes being committed.
147
158
@@ -149,27 +160,27 b' detailed. Use a docstring-like approach in the commit messages'
149 - including crediting outside contributors if they sent the
160 - including crediting outside contributors if they sent the
150 code/bug/idea!
161 code/bug/idea!
151
162
152 If we couple this with a policy of making single commits for each
163 If we couple this with a policy of making single commits for each reasonably
153 reasonably atomic change, the bzr log should give an excellent view of
164 atomic change, the bzr log should give an excellent view of the project, and
154 the project, and the `--short` log option becomes a nice summary.
165 the `--short` log option becomes a nice summary.
155
166
156 While working with this branch, it is a good idea to merge in changes that have been
167 While working with this branch, it is a good idea to merge in changes that have
157 made upstream in the parent branch. This can be done by doing::
168 been made upstream in the parent branch. This can be done by doing::
158
169
159 $ bzr pull
170 $ bzr pull
160
171
161 If this command shows that the branches have diverged, then you should do a merge
172 If this command shows that the branches have diverged, then you should do a
162 instead::
173 merge instead::
163
174
164 $ bzr merge lp:ipython
175 $ bzr merge lp:ipython
165
176
166 If you want others to be able to see your branch, you can create an account with
177 If you want others to be able to see your branch, you can create an account
167 launchpad and push the branch to your own workspace::
178 with launchpad and push the branch to your own workspace::
168
179
169 $ bzr push bzr+ssh://<me>@bazaar.launchpad.net/~<me>/+junk/ipython-mybranch
180 $ bzr push bzr+ssh://<me>@bazaar.launchpad.net/~<me>/+junk/ipython-mybranch
170
181
171 Finally, once the work in your branch is done, you can merge your changes back into
182 Finally, once the work in your branch is done, you can merge your changes back
172 the `ipython` branch by using merge::
183 into the `ipython` branch by using merge::
173
184
174 $ cd ipython
185 $ cd ipython
175 $ merge ../ipython-mybranch
186 $ merge ../ipython-mybranch
@@ -177,8 +188,9 b' the `ipython` branch by using merge::'
177 $ bzr ci -m "Fixing that bug"
188 $ bzr ci -m "Fixing that bug"
178 $ bzr push
189 $ bzr push
179
190
180 But this will require you to have write permissions to the `ipython` branch. It you don't
191 But this will require you to have write permissions to the `ipython` branch.
181 you can tell one of the IPython devs about your branch and they can do the merge for you.
192 It you don't you can tell one of the IPython devs about your branch and they
193 can do the merge for you.
182
194
183 More information about Bazaar workflows can be found `here`__.
195 More information about Bazaar workflows can be found `here`__.
184
196
@@ -193,27 +205,29 b' Documentation'
193 Standalone documentation
205 Standalone documentation
194 ------------------------
206 ------------------------
195
207
196 All standalone documentation should be written in plain text (``.txt``) files using
208 All standalone documentation should be written in plain text (``.txt``) files
197 `reStructuredText`_ for markup and formatting. All such documentation should be placed
209 using `reStructuredText`_ for markup and formatting. All such documentation
198 in the top level directory ``docs`` of the IPython source tree. Or, when appropriate,
210 should be placed in the top level directory ``docs`` of the IPython source
199 a suitably named subdirectory should be used. The documentation in this location will
211 tree. Or, when appropriate, a suitably named subdirectory should be used. The
200 serve as the main source for IPython documentation and all existing documentation
212 documentation in this location will serve as the main source for IPython
201 should be converted to this format.
213 documentation and all existing documentation should be converted to this
214 format.
202
215
203 In the future, the text files in the ``docs`` directory will be used to generate all
216 In the future, the text files in the ``docs`` directory will be used to
204 forms of documentation for IPython. This include documentation on the IPython website
217 generate all forms of documentation for IPython. This include documentation on
205 as well as *pdf* documentation.
218 the IPython website as well as *pdf* documentation.
206
219
207 .. _reStructuredText: http://docutils.sourceforge.net/rst.html
220 .. _reStructuredText: http://docutils.sourceforge.net/rst.html
208
221
209 Docstring format
222 Docstring format
210 ----------------
223 ----------------
211
224
212 Good docstrings are very important. All new code will use `Epydoc`_ for generating API
225 Good docstrings are very important. All new code will use `Epydoc`_ for
213 docs, so we will follow the `Epydoc`_ conventions. More specifically, we will use
226 generating API docs, so we will follow the `Epydoc`_ conventions. More
214 `reStructuredText`_ for markup and formatting, since it is understood by a wide
227 specifically, we will use `reStructuredText`_ for markup and formatting, since
215 variety of tools. This means that if in the future we have any reason to change from
228 it is understood by a wide variety of tools. This means that if in the future
216 `Epydoc`_ to something else, we'll have fewer transition pains.
229 we have any reason to change from `Epydoc`_ to something else, we'll have fewer
230 transition pains.
217
231
218 Details about using `reStructuredText`_ for docstrings can be found `here
232 Details about using `reStructuredText`_ for docstrings can be found `here
219 <http://epydoc.sourceforge.net/manual-othermarkup.html>`_.
233 <http://epydoc.sourceforge.net/manual-othermarkup.html>`_.
@@ -233,7 +247,8 b' Coding conventions'
233 General
247 General
234 -------
248 -------
235
249
236 In general, we'll try to follow the standard Python style conventions as described here:
250 In general, we'll try to follow the standard Python style conventions as
251 described here:
237
252
238 - `Style Guide for Python Code <http://www.python.org/peps/pep-0008.html>`_
253 - `Style Guide for Python Code <http://www.python.org/peps/pep-0008.html>`_
239
254
@@ -250,8 +265,8 b' Other comments:'
250 Naming conventions
265 Naming conventions
251 ------------------
266 ------------------
252
267
253 In terms of naming conventions, we'll follow the guidelines from the `Style Guide for
268 In terms of naming conventions, we'll follow the guidelines from the `Style
254 Python Code`_.
269 Guide for Python Code`_.
255
270
256 For all new IPython code (and much existing code is being refactored), we'll use:
271 For all new IPython code (and much existing code is being refactored), we'll use:
257
272
@@ -259,67 +274,81 b" For all new IPython code (and much existing code is being refactored), we'll use"
259
274
260 - ``CamelCase`` for class names.
275 - ``CamelCase`` for class names.
261
276
262 - ``lowercase_with_underscores`` for methods, functions, variables and attributes.
277 - ``lowercase_with_underscores`` for methods, functions, variables and
278 attributes.
263
279
264 This may be confusing as most of the existing IPython codebase uses a different convention (``lowerCamelCase`` for methods and attributes). Slowly, we will move IPython over to the new
280 This may be confusing as most of the existing IPython codebase uses a different
265 convention, providing shadow names for backward compatibility in public interfaces.
281 convention (``lowerCamelCase`` for methods and attributes). Slowly, we will
282 move IPython over to the new convention, providing shadow names for backward
283 compatibility in public interfaces.
266
284
267 There are, however, some important exceptions to these rules. In some cases, IPython
285 There are, however, some important exceptions to these rules. In some cases,
268 code will interface with packages (Twisted, Wx, Qt) that use other conventions. At some level this makes it impossible to adhere to our own standards at all times. In particular, when subclassing classes that use other naming conventions, you must follow their naming conventions. To deal with cases like this, we propose the following policy:
286 IPython code will interface with packages (Twisted, Wx, Qt) that use other
287 conventions. At some level this makes it impossible to adhere to our own
288 standards at all times. In particular, when subclassing classes that use other
289 naming conventions, you must follow their naming conventions. To deal with
290 cases like this, we propose the following policy:
269
291
270 - If you are subclassing a class that uses different conventions, use its
292 - If you are subclassing a class that uses different conventions, use its
271 naming conventions throughout your subclass. Thus, if you are creating a
293 naming conventions throughout your subclass. Thus, if you are creating a
272 Twisted Protocol class, used Twisted's ``namingSchemeForMethodsAndAttributes.``
294 Twisted Protocol class, used Twisted's
273
295 ``namingSchemeForMethodsAndAttributes.``
274 - All IPython's official interfaces should use our conventions. In some cases
296
275 this will mean that you need to provide shadow names (first implement ``fooBar``
297 - All IPython's official interfaces should use our conventions. In some cases
276 and then ``foo_bar = fooBar``). We want to avoid this at all costs, but it
298 this will mean that you need to provide shadow names (first implement
277 will probably be necessary at times. But, please use this sparingly!
299 ``fooBar`` and then ``foo_bar = fooBar``). We want to avoid this at all
278
300 costs, but it will probably be necessary at times. But, please use this
279 Implementation-specific *private* methods will use ``_single_underscore_prefix``.
301 sparingly!
280 Names with a leading double underscore will *only* be used in special cases, as they
302
281 makes subclassing difficult (such names are not easily seen by child classes).
303 Implementation-specific *private* methods will use
282
304 ``_single_underscore_prefix``. Names with a leading double underscore will
283 Occasionally some run-in lowercase names are used, but mostly for very short names or
305 *only* be used in special cases, as they makes subclassing difficult (such
284 where we are implementing methods very similar to existing ones in a base class (like
306 names are not easily seen by child classes).
285 ``runlines()`` where ``runsource()`` and ``runcode()`` had established precedent).
307
308 Occasionally some run-in lowercase names are used, but mostly for very short
309 names or where we are implementing methods very similar to existing ones in a
310 base class (like ``runlines()`` where ``runsource()`` and ``runcode()`` had
311 established precedent).
286
312
287 The old IPython codebase has a big mix of classes and modules prefixed with an
313 The old IPython codebase has a big mix of classes and modules prefixed with an
288 explicit ``IP``. In Python this is mostly unnecessary, redundant and frowned upon, as
314 explicit ``IP``. In Python this is mostly unnecessary, redundant and frowned
289 namespaces offer cleaner prefixing. The only case where this approach is justified is
315 upon, as namespaces offer cleaner prefixing. The only case where this approach
290 for classes which are expected to be imported into external namespaces and a very
316 is justified is for classes which are expected to be imported into external
291 generic name (like Shell) is too likely to clash with something else. We'll need to
317 namespaces and a very generic name (like Shell) is too likely to clash with
292 revisit this issue as we clean up and refactor the code, but in general we should
318 something else. We'll need to revisit this issue as we clean up and refactor
293 remove as many unnecessary ``IP``/``ip`` prefixes as possible. However, if a prefix
319 the code, but in general we should remove as many unnecessary ``IP``/``ip``
294 seems absolutely necessary the more specific ``IPY`` or ``ipy`` are preferred.
320 prefixes as possible. However, if a prefix seems absolutely necessary the more
321 specific ``IPY`` or ``ipy`` are preferred.
295
322
296 .. _devel_testing:
323 .. _devel_testing:
297
324
298 Testing system
325 Testing system
299 ==============
326 ==============
300
327
301 It is extremely important that all code contributed to IPython has tests. Tests should
328 It is extremely important that all code contributed to IPython has tests. Tests
302 be written as unittests, doctests or as entities that the `Nose`_ testing package will
329 should be written as unittests, doctests or as entities that the `Nose`_
303 find. Regardless of how the tests are written, we will use `Nose`_ for discovering and
330 testing package will find. Regardless of how the tests are written, we will use
304 running the tests. `Nose`_ will be required to run the IPython test suite, but will
331 `Nose`_ for discovering and running the tests. `Nose`_ will be required to run
305 not be required to simply use IPython.
332 the IPython test suite, but will not be required to simply use IPython.
306
333
307 .. _Nose: http://code.google.com/p/python-nose/
334 .. _Nose: http://code.google.com/p/python-nose/
308
335
309 Tests of `Twisted`__ using code should be written by subclassing the ``TestCase`` class
336 Tests of `Twisted`__ using code should be written by subclassing the
310 that comes with ``twisted.trial.unittest``. When this is done, `Nose`_ will be able to
337 ``TestCase`` class that comes with ``twisted.trial.unittest``. When this is
311 run the tests and the twisted reactor will be handled correctly.
338 done, `Nose`_ will be able to run the tests and the twisted reactor will be
339 handled correctly.
312
340
313 .. __: http://www.twistedmatrix.com
341 .. __: http://www.twistedmatrix.com
314
342
315 Each subpackage in IPython should have its own ``tests`` directory that contains all
343 Each subpackage in IPython should have its own ``tests`` directory that
316 of the tests for that subpackage. This allows each subpackage to be self-contained. If
344 contains all of the tests for that subpackage. This allows each subpackage to
317 a subpackage has any dependencies beyond the Python standard library, the tests for
345 be self-contained. If a subpackage has any dependencies beyond the Python
318 that subpackage should be skipped if the dependencies are not found. This is very
346 standard library, the tests for that subpackage should be skipped if the
319 important so users don't get tests failing simply because they don't have dependencies.
347 dependencies are not found. This is very important so users don't get tests
348 failing simply because they don't have dependencies.
320
349
321 We also need to look into use Noses ability to tag tests to allow a more modular
350 We also need to look into use Noses ability to tag tests to allow a more
322 approach of running tests.
351 modular approach of running tests.
323
352
324 .. _devel_config:
353 .. _devel_config:
325
354
@@ -327,23 +356,25 b' Configuration system'
327 ====================
356 ====================
328
357
329 IPython uses `.ini`_ files for configuration purposes. This represents a huge
358 IPython uses `.ini`_ files for configuration purposes. This represents a huge
330 improvement over the configuration system used in IPython. IPython works with these
359 improvement over the configuration system used in IPython. IPython works with
331 files using the `ConfigObj`_ package, which IPython includes as
360 these files using the `ConfigObj`_ package, which IPython includes as
332 ``ipython1/external/configobj.py``.
361 ``ipython1/external/configobj.py``.
333
362
334 Currently, we are using raw `ConfigObj`_ objects themselves. Each subpackage of IPython
363 Currently, we are using raw `ConfigObj`_ objects themselves. Each subpackage of
335 should contain a ``config`` subdirectory that contains all of the configuration
364 IPython should contain a ``config`` subdirectory that contains all of the
336 information for the subpackage. To see how configuration information is defined (along
365 configuration information for the subpackage. To see how configuration
337 with defaults) see at the examples in ``ipython1/kernel/config`` and
366 information is defined (along with defaults) see at the examples in
338 ``ipython1/core/config``. Likewise, to see how the configuration information is used,
367 ``ipython1/kernel/config`` and ``ipython1/core/config``. Likewise, to see how
339 see examples in ``ipython1/kernel/scripts/ipengine.py``.
368 the configuration information is used, see examples in
340
369 ``ipython1/kernel/scripts/ipengine.py``.
341 Eventually, we will add a new layer on top of the raw `ConfigObj`_ objects. We are
370
342 calling this new layer, ``tconfig``, as it will use a `Traits`_-like validation model.
371 Eventually, we will add a new layer on top of the raw `ConfigObj`_ objects. We
343 We won't actually use `Traits`_, but will implement something similar in pure Python.
372 are calling this new layer, ``tconfig``, as it will use a `Traits`_-like
344 But, even in this new system, we will still use `ConfigObj`_ and `.ini`_ files
373 validation model. We won't actually use `Traits`_, but will implement
345 underneath the hood. Talk to Fernando if you are interested in working on this part of
374 something similar in pure Python. But, even in this new system, we will still
346 IPython. The current prototype of ``tconfig`` is located in the IPython sandbox.
375 use `ConfigObj`_ and `.ini`_ files underneath the hood. Talk to Fernando if you
376 are interested in working on this part of IPython. The current prototype of
377 ``tconfig`` is located in the IPython sandbox.
347
378
348 .. _.ini: http://docs.python.org/lib/module-ConfigParser.html
379 .. _.ini: http://docs.python.org/lib/module-ConfigParser.html
349 .. _ConfigObj: http://www.voidspace.org.uk/python/configobj.html
380 .. _ConfigObj: http://www.voidspace.org.uk/python/configobj.html
@@ -352,20 +383,26 b' IPython. The current prototype of ``tconfig`` is located in the IPython sandbox.'
352 Installation and testing scenarios
383 Installation and testing scenarios
353 ==================================
384 ==================================
354
385
355 This section outlines the various scenarios that we need to test before we release an IPython version. These scenarios represent different ways of installing IPython and its dependencies.
386 This section outlines the various scenarios that we need to test before we
387 release an IPython version. These scenarios represent different ways of
388 installing IPython and its dependencies.
356
389
357 Installation scenarios under Linux and OS X
390 Installation scenarios under Linux and OS X
358 -------------------------------------------
391 -------------------------------------------
359
392
360 1. Install from tarball using `python setup.py install`.
393 1. Install from tarball using ``python setup.py install``.
361 a. With only readline+nose dependencies installed.
394 a. With only readline+nose dependencies installed.
362 b. With all dependencies installed (readline, zope.interface,
395 b. With all dependencies installed (readline, zope.interface, Twisted,
363 Twisted, foolscap, Sphinx, nose, pyOpenSSL).
396 foolscap, Sphinx, nose, pyOpenSSL).
397
364 2. Install using easy_install.
398 2. Install using easy_install.
399
365 a. With only readline+nose dependencies installed.
400 a. With only readline+nose dependencies installed.
366 i. Default dependencies: `easy_install ipython-0.9.beta3-py2.5.egg`
401 i. Default dependencies: ``easy_install ipython-0.9.beta3-py2.5.egg``
367 ii. Optional dependency sets: `easy_install -f ipython-0.9.beta3-py2.5.egg IPython[kernel,doc,test,security]`
402 ii. Optional dependency sets: ``easy_install -f ipython-0.9.beta3-py2.5.egg IPython[kernel,doc,test,security]``
403
368 b. With all dependencies already installed.
404 b. With all dependencies already installed.
405
369
406
370 Installation scenarios under Win32
407 Installation scenarios under Win32
371 ----------------------------------
408 ----------------------------------
@@ -381,17 +418,9 b' Tests to run for these scenarios'
381 2. Start a controller and engines and try a few things by hand.
418 2. Start a controller and engines and try a few things by hand.
382 a. Using ipcluster.
419 a. Using ipcluster.
383 b. Using ipcontroller/ipengine by hand.
420 b. Using ipcontroller/ipengine by hand.
421
384 3. Run a few of the parallel examples.
422 3. Run a few of the parallel examples.
385 4. Try the kernel with and without security with and without PyOpenSSL
423 4. Try the kernel with and without security with and without PyOpenSSL
386 installed.
424 installed.
387 5. Beat on the IPython terminal a bunch.
425 5. Beat on the IPython terminal a bunch.
388 6. Make sure that furl files are being put in proper locations.
426 6. Make sure that furl files are being put in proper locations.
389
390
391
392
393
394
395
396
397
@@ -8,7 +8,7 b' IPython reference'
8
8
9 .. contents::
9 .. contents::
10
10
11 .. _Command line options:
11 .. _command_line_options:
12
12
13 Command-line usage
13 Command-line usage
14 ==================
14 ==================
@@ -288,12 +288,13 b' All options with a [no] prepended can be specified in negated form'
288 recursive inclusions.
288 recursive inclusions.
289
289
290 -prompt_in1, pi1 <string>
290 -prompt_in1, pi1 <string>
291 Specify the string used for input prompts. Note that if you
291
292 are using numbered prompts, the number is represented with a
292 Specify the string used for input prompts. Note that if you are using
293 '\#' in the string. Don't forget to quote strings with spaces
293 numbered prompts, the number is represented with a '\#' in the
294 embedded in them. Default: 'In [\#]:'. Sec. Prompts_
294 string. Don't forget to quote strings with spaces embedded in
295 discusses in detail all the available escapes to customize
295 them. Default: 'In [\#]:'. The :ref:`prompts section <prompts>`
296 your prompts.
296 discusses in detail all the available escapes to customize your
297 prompts.
297
298
298 -prompt_in2, pi2 <string>
299 -prompt_in2, pi2 <string>
299 Similar to the previous option, but used for the continuation
300 Similar to the previous option, but used for the continuation
@@ -2077,13 +2078,14 b' customizations.'
2077 Access to the standard Python help
2078 Access to the standard Python help
2078 ----------------------------------
2079 ----------------------------------
2079
2080
2080 As of Python 2.1, a help system is available with access to object
2081 As of Python 2.1, a help system is available with access to object docstrings
2081 docstrings and the Python manuals. Simply type 'help' (no quotes) to
2082 and the Python manuals. Simply type 'help' (no quotes) to access it. You can
2082 access it. You can also type help(object) to obtain information about a
2083 also type help(object) to obtain information about a given object, and
2083 given object, and help('keyword') for information on a keyword. As noted
2084 help('keyword') for information on a keyword. As noted :ref:`here
2084 in sec. `accessing help`_, you need to properly configure
2085 <accessing_help>`, you need to properly configure your environment variable
2085 your environment variable PYTHONDOCS for this feature to work correctly.
2086 PYTHONDOCS for this feature to work correctly.
2086
2087
2088 .. _dynamic_object_info:
2087
2089
2088 Dynamic object information
2090 Dynamic object information
2089 --------------------------
2091 --------------------------
@@ -2126,7 +2128,7 b' are not really defined as separate identifiers. Try for example typing'
2126 {}.get? or after doing import os, type os.path.abspath??.
2128 {}.get? or after doing import os, type os.path.abspath??.
2127
2129
2128
2130
2129 .. _Readline:
2131 .. _readline:
2130
2132
2131 Readline-based features
2133 Readline-based features
2132 -----------------------
2134 -----------------------
@@ -2240,10 +2242,9 b' explanation in your ipythonrc file.'
2240 Session logging and restoring
2242 Session logging and restoring
2241 -----------------------------
2243 -----------------------------
2242
2244
2243 You can log all input from a session either by starting IPython with
2245 You can log all input from a session either by starting IPython with the
2244 the command line switches -log or -logfile (see sec. `command line
2246 command line switches -log or -logfile (see :ref:`here <command_line_options>`)
2245 options`_) or by activating the logging at any moment with the magic
2247 or by activating the logging at any moment with the magic function %logstart.
2246 function %logstart.
2247
2248
2248 Log files can later be reloaded with the -logplay option and IPython
2249 Log files can later be reloaded with the -logplay option and IPython
2249 will attempt to 'replay' the log by executing all the lines in it, thus
2250 will attempt to 'replay' the log by executing all the lines in it, thus
@@ -2279,6 +2280,8 b' resume logging to a file which had previously been started with'
2279 %logstart. They will fail (with an explanation) if you try to use them
2280 %logstart. They will fail (with an explanation) if you try to use them
2280 before logging has been started.
2281 before logging has been started.
2281
2282
2283 .. _system_shell_access:
2284
2282 System shell access
2285 System shell access
2283 -------------------
2286 -------------------
2284
2287
@@ -2389,7 +2392,7 b" These features are basically a terminal version of Ka-Ping Yee's cgitb"
2389 module, now part of the standard Python library.
2392 module, now part of the standard Python library.
2390
2393
2391
2394
2392 .. _Input caching:
2395 .. _input_caching:
2393
2396
2394 Input caching system
2397 Input caching system
2395 --------------------
2398 --------------------
@@ -2429,7 +2432,7 b' sec. 6.2 <#sec:magic> for more details on the macro system.'
2429 A history function %hist allows you to see any part of your input
2432 A history function %hist allows you to see any part of your input
2430 history by printing a range of the _i variables.
2433 history by printing a range of the _i variables.
2431
2434
2432 .. _Output caching:
2435 .. _output_caching:
2433
2436
2434 Output caching system
2437 Output caching system
2435 ---------------------
2438 ---------------------
@@ -3034,7 +3037,7 b' which is being shared by the interactive IPython loop and your GUI'
3034 thread, you should really handle it with thread locking and
3037 thread, you should really handle it with thread locking and
3035 syncrhonization properties. The Python documentation discusses these.
3038 syncrhonization properties. The Python documentation discusses these.
3036
3039
3037 .. _Interactive demos:
3040 .. _interactive_demos:
3038
3041
3039 Interactive demos with IPython
3042 Interactive demos with IPython
3040 ==============================
3043 ==============================
@@ -3143,21 +3146,17 b' toolkits, including Tk, GTK and WXPython. It also provides a number of'
3143 commands useful for scientific computing, all with a syntax compatible
3146 commands useful for scientific computing, all with a syntax compatible
3144 with that of the popular Matlab program.
3147 with that of the popular Matlab program.
3145
3148
3146 IPython accepts the special option -pylab (Sec. `Command line
3149 IPython accepts the special option -pylab (see :ref:`here
3147 options`_). This configures it to support matplotlib, honoring the
3150 <command_line_options>`). This configures it to support matplotlib, honoring
3148 settings in the .matplotlibrc file. IPython will detect the user's
3151 the settings in the .matplotlibrc file. IPython will detect the user's choice
3149 choice of matplotlib GUI backend, and automatically select the proper
3152 of matplotlib GUI backend, and automatically select the proper threading model
3150 threading model to prevent blocking. It also sets matplotlib in
3153 to prevent blocking. It also sets matplotlib in interactive mode and modifies
3151 interactive mode and modifies %run slightly, so that any
3154 %run slightly, so that any matplotlib-based script can be executed using %run
3152 matplotlib-based script can be executed using %run and the final
3155 and the final show() command does not block the interactive shell.
3153 show() command does not block the interactive shell.
3156
3154
3157 The -pylab option must be given first in order for IPython to configure its
3155 The -pylab option must be given first in order for IPython to
3158 threading mode. However, you can still issue other options afterwards. This
3156 configure its threading mode. However, you can still issue other
3159 allows you to have a matplotlib-based environment customized with additional
3157 options afterwards. This allows you to have a matplotlib-based
3160 modules using the standard IPython profile mechanism (see :ref:`here
3158 environment customized with additional modules using the standard
3161 <profiles>`): ``ipython -pylab -p myprofile`` will load the profile defined in
3159 IPython profile mechanism (Sec. Profiles_): ''ipython -pylab -p
3162 ipythonrc-myprofile after configuring matplotlib.
3160 myprofile'' will load the profile defined in ipythonrc-myprofile after
3161 configuring matplotlib.
3162
3163
@@ -24,11 +24,11 b' Tab completion'
24 --------------
24 --------------
25
25
26 TAB-completion, especially for attributes, is a convenient way to explore the
26 TAB-completion, especially for attributes, is a convenient way to explore the
27 structure of any object you're dealing with. Simply type object_name.<TAB>
27 structure of any object you're dealing with. Simply type object_name.<TAB> and
28 and a list of the object's attributes will be printed (see readline_ for
28 a list of the object's attributes will be printed (see :ref:`the readline
29 more). Tab completion also works on file and directory names, which combined
29 section <readline>` for more). Tab completion also works on file and directory
30 with IPython's alias system allows you to do from within IPython many of the
30 names, which combined with IPython's alias system allows you to do from within
31 things you normally would need the system shell for.
31 IPython many of the things you normally would need the system shell for.
32
32
33 Explore your objects
33 Explore your objects
34 --------------------
34 --------------------
@@ -39,18 +39,18 b' constructor details for classes. The magic commands %pdoc, %pdef, %psource'
39 and %pfile will respectively print the docstring, function definition line,
39 and %pfile will respectively print the docstring, function definition line,
40 full source code and the complete file for any object (when they can be
40 full source code and the complete file for any object (when they can be
41 found). If automagic is on (it is by default), you don't need to type the '%'
41 found). If automagic is on (it is by default), you don't need to type the '%'
42 explicitly. See sec. `dynamic object information`_ for more.
42 explicitly. See :ref:`this section <dynamic_object_info>` for more.
43
43
44 The `%run` magic command
44 The `%run` magic command
45 ------------------------
45 ------------------------
46
46
47 The %run magic command allows you to run any python script and load all of
47 The %run magic command allows you to run any python script and load all of its
48 its data directly into the interactive namespace. Since the file is re-read
48 data directly into the interactive namespace. Since the file is re-read from
49 from disk each time, changes you make to it are reflected immediately (in
49 disk each time, changes you make to it are reflected immediately (in contrast
50 contrast to the behavior of import). I rarely use import for code I am
50 to the behavior of import). I rarely use import for code I am testing, relying
51 testing, relying on %run instead. See magic_ section for more on this and
51 on %run instead. See :ref:`this section <magic>` for more on this and other
52 other magic commands, or type the name of any magic command and ? to get
52 magic commands, or type the name of any magic command and ? to get details on
53 details on it. See also sec. dreload_ for a recursive reload command. %run
53 it. See also :ref:`this section <dreload>` for a recursive reload command. %run
54 also has special flags for timing the execution of your scripts (-t) and for
54 also has special flags for timing the execution of your scripts (-t) and for
55 executing them under the control of either Python's pdb debugger (-d) or
55 executing them under the control of either Python's pdb debugger (-d) or
56 profiler (-p). With all of these, %run can be used as the main tool for
56 profiler (-p). With all of these, %run can be used as the main tool for
@@ -60,21 +60,21 b' choice.'
60 Debug a Python script
60 Debug a Python script
61 ---------------------
61 ---------------------
62
62
63 Use the Python debugger, pdb. The %pdb command allows you to toggle on and
63 Use the Python debugger, pdb. The %pdb command allows you to toggle on and off
64 off the automatic invocation of an IPython-enhanced pdb debugger (with
64 the automatic invocation of an IPython-enhanced pdb debugger (with coloring,
65 coloring, tab completion and more) at any uncaught exception. The advantage
65 tab completion and more) at any uncaught exception. The advantage of this is
66 of this is that pdb starts inside the function where the exception occurred,
66 that pdb starts inside the function where the exception occurred, with all data
67 with all data still available. You can print variables, see code, execute
67 still available. You can print variables, see code, execute statements and even
68 statements and even walk up and down the call stack to track down the true
68 walk up and down the call stack to track down the true source of the problem
69 source of the problem (which often is many layers in the stack above where
69 (which often is many layers in the stack above where the exception gets
70 the exception gets triggered). Running programs with %run and pdb active can
70 triggered). Running programs with %run and pdb active can be an efficient to
71 be an efficient to develop and debug code, in many cases eliminating the need
71 develop and debug code, in many cases eliminating the need for print statements
72 for print statements or external debugging tools. I often simply put a 1/0 in
72 or external debugging tools. I often simply put a 1/0 in a place where I want
73 a place where I want to take a look so that pdb gets called, quickly view
73 to take a look so that pdb gets called, quickly view whatever variables I need
74 whatever variables I need to or test various pieces of code and then remove
74 to or test various pieces of code and then remove the 1/0. Note also that '%run
75 the 1/0. Note also that '%run -d' activates pdb and automatically sets
75 -d' activates pdb and automatically sets initial breakpoints for you to step
76 initial breakpoints for you to step through your code, watch variables, etc.
76 through your code, watch variables, etc. The :ref:`output caching section
77 See Sec. `Output caching`_ for details.
77 <output_caching>` has more details.
78
78
79 Use the output cache
79 Use the output cache
80 --------------------
80 --------------------
@@ -84,7 +84,8 b' and variables named _1, _2, etc. alias them. For example, the result of input'
84 line 4 is available either as Out[4] or as _4. Additionally, three variables
84 line 4 is available either as Out[4] or as _4. Additionally, three variables
85 named _, __ and ___ are always kept updated with the for the last three
85 named _, __ and ___ are always kept updated with the for the last three
86 results. This allows you to recall any previous result and further use it for
86 results. This allows you to recall any previous result and further use it for
87 new calculations. See Sec. `Output caching`_ for more.
87 new calculations. See :ref:`the output caching section <output_caching>` for
88 more.
88
89
89 Suppress output
90 Suppress output
90 ---------------
91 ---------------
@@ -102,7 +103,7 b' A similar system exists for caching input. All input is stored in a global'
102 list called In , so you can re-execute lines 22 through 28 plus line 34 by
103 list called In , so you can re-execute lines 22 through 28 plus line 34 by
103 typing 'exec In[22:29]+In[34]' (using Python slicing notation). If you need
104 typing 'exec In[22:29]+In[34]' (using Python slicing notation). If you need
104 to execute the same set of lines often, you can assign them to a macro with
105 to execute the same set of lines often, you can assign them to a macro with
105 the %macro function. See sec. `Input caching`_ for more.
106 the %macro function. See :ref:`here <input_caching>` for more.
106
107
107 Use your input history
108 Use your input history
108 ----------------------
109 ----------------------
@@ -134,17 +135,18 b' into Python variables.'
134 Use Python variables when calling the shell
135 Use Python variables when calling the shell
135 -------------------------------------------
136 -------------------------------------------
136
137
137 Expand python variables when calling the shell (either via '!' and '!!' or
138 Expand python variables when calling the shell (either via '!' and '!!' or via
138 via aliases) by prepending a $ in front of them. You can also expand complete
139 aliases) by prepending a $ in front of them. You can also expand complete
139 python expressions. See `System shell access`_ for more.
140 python expressions. See :ref:`our shell section <system_shell_access>` for
141 more details.
140
142
141 Use profiles
143 Use profiles
142 ------------
144 ------------
143
145
144 Use profiles to maintain different configurations (modules to load, function
146 Use profiles to maintain different configurations (modules to load, function
145 definitions, option settings) for particular tasks. You can then have
147 definitions, option settings) for particular tasks. You can then have
146 customized versions of IPython for specific purposes. See sec. profiles_ for
148 customized versions of IPython for specific purposes. :ref:`This section
147 more.
149 <profiles>` has more details.
148
150
149
151
150 Embed IPython in your programs
152 Embed IPython in your programs
@@ -152,7 +154,7 b' Embed IPython in your programs'
152
154
153 A few lines of code are enough to load a complete IPython inside your own
155 A few lines of code are enough to load a complete IPython inside your own
154 programs, giving you the ability to work with your data interactively after
156 programs, giving you the ability to work with your data interactively after
155 automatic processing has been completed. See sec. embedding_ for more.
157 automatic processing has been completed. See :ref:`here <embedding>` for more.
156
158
157 Use the Python profiler
159 Use the Python profiler
158 -----------------------
160 -----------------------
@@ -166,8 +168,8 b' Use IPython to present interactive demos'
166 ----------------------------------------
168 ----------------------------------------
167
169
168 Use the IPython.demo.Demo class to load any Python script as an interactive
170 Use the IPython.demo.Demo class to load any Python script as an interactive
169 demo. With a minimal amount of simple markup, you can control the execution
171 demo. With a minimal amount of simple markup, you can control the execution of
170 of the script, stopping as needed. See sec. `interactive demos`_ for more.
172 the script, stopping as needed. See :ref:`here <interactive_demos>` for more.
171
173
172 Run doctests
174 Run doctests
173 ------------
175 ------------
@@ -10,17 +10,15 b' echo'
10 echo "Releasing IPython version $version"
10 echo "Releasing IPython version $version"
11 echo "=================================="
11 echo "=================================="
12
12
13 echo "Marking ChangeLog with release information and making NEWS file..."
14
15 # Clean up build/dist directories
16 rm -rf $ipdir/build/*
17 rm -rf $ipdir/dist/*
18
19 # Perform local backup
13 # Perform local backup
20 cd $ipdir/tools
14 cd $ipdir/tools
21 ./make_tarball.py
15 ./make_tarball.py
22 mv ipython-*.tgz $ipbackupdir
16 mv ipython-*.tgz $ipbackupdir
23
17
18 # Clean up build/dist directories
19 rm -rf $ipdir/build/*
20 rm -rf $ipdir/dist/*
21
24 # Build source and binary distros
22 # Build source and binary distros
25 cd $ipdir
23 cd $ipdir
26 ./setup.py sdist --formats=gztar
24 ./setup.py sdist --formats=gztar
@@ -28,8 +26,8 b' cd $ipdir'
28 # Build version-specific RPMs, where we must use the --python option to ensure
26 # Build version-specific RPMs, where we must use the --python option to ensure
29 # that the resulting RPM is really built with the requested python version (so
27 # that the resulting RPM is really built with the requested python version (so
30 # things go to lib/python2.X/...)
28 # things go to lib/python2.X/...)
31 python2.4 ./setup.py bdist_rpm --binary-only --release=py24 --python=/usr/bin/python2.4
29 #python2.4 ./setup.py bdist_rpm --binary-only --release=py24 --python=/usr/bin/python2.4
32 python2.5 ./setup.py bdist_rpm --binary-only --release=py25 --python=/usr/bin/python2.5
30 #python2.5 ./setup.py bdist_rpm --binary-only --release=py25 --python=/usr/bin/python2.5
33
31
34 # Build eggs
32 # Build eggs
35 python2.4 ./setup_bdist_egg.py
33 python2.4 ./setup_bdist_egg.py
@@ -15,8 +15,8 b' cd $ipdir'
15 ./setup.py sdist --formats=gztar
15 ./setup.py sdist --formats=gztar
16
16
17 # Build rpms
17 # Build rpms
18 #python2.4 ./setup.py bdist_rpm --binary-only --release=py24 --python=/usr/bin/python2.4
18 python2.4 ./setup.py bdist_rpm --binary-only --release=py24 --python=/usr/bin/python2.4
19 #python2.5 ./setup.py bdist_rpm --binary-only --release=py25 --python=/usr/bin/python2.5
19 python2.5 ./setup.py bdist_rpm --binary-only --release=py25 --python=/usr/bin/python2.5
20
20
21 # Build eggs
21 # Build eggs
22 python2.4 ./setup_bdist_egg.py
22 python2.4 ./setup_bdist_egg.py
General Comments 0
You need to be logged in to leave comments. Login now