Show More
The requested changes are too big and content was truncated. Show full diff
@@ -0,0 +1,77 | |||||
|
1 | IPython is licensed under the terms of the new or revised BSD license, as follows: | |||
|
2 | ||||
|
3 | Copyright (c) 2008, IPython Development Team | |||
|
4 | ||||
|
5 | All rights reserved. | |||
|
6 | ||||
|
7 | Redistribution and use in source and binary forms, with or without modification, | |||
|
8 | are permitted provided that the following conditions are met: | |||
|
9 | ||||
|
10 | Redistributions of source code must retain the above copyright notice, this list of | |||
|
11 | conditions and the following disclaimer. | |||
|
12 | ||||
|
13 | Redistributions in binary form must reproduce the above copyright notice, this list | |||
|
14 | of conditions and the following disclaimer in the documentation and/or other | |||
|
15 | materials provided with the distribution. | |||
|
16 | ||||
|
17 | Neither the name of the IPython Development Team nor the names of its contributors | |||
|
18 | may be used to endorse or promote products derived from this software without | |||
|
19 | specific prior written permission. | |||
|
20 | ||||
|
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY | |||
|
22 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |||
|
23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |||
|
24 | IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |||
|
25 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |||
|
26 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |||
|
27 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |||
|
28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||
|
29 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |||
|
30 | POSSIBILITY OF SUCH DAMAGE. | |||
|
31 | ||||
|
32 | About the IPython Development Team | |||
|
33 | ---------------------------------- | |||
|
34 | ||||
|
35 | Fernando Perez began IPython in 2001 based on code from Janko Hauser <jhauser@zscout.de> | |||
|
36 | and Nathaniel Gray <n8gray@caltech.edu>. Fernando is still the project lead. | |||
|
37 | ||||
|
38 | The IPython Development Team is the set of all contributors to the IPython project. | |||
|
39 | This includes all of the IPython subprojects. Here is a list of the currently active contributors: | |||
|
40 | ||||
|
41 | * Matthieu Brucher | |||
|
42 | * Ondrej Certik | |||
|
43 | * Laurent Dufrechou | |||
|
44 | * Robert Kern | |||
|
45 | * Brian E. Granger | |||
|
46 | * Fernando Perez (project leader) | |||
|
47 | * Benjamin Ragan-Kelley | |||
|
48 | * Ville M. Vainio | |||
|
49 | * Gael Varoququx | |||
|
50 | * Stefan van der Walt | |||
|
51 | * Tech-X Corporation | |||
|
52 | * Barry Wark | |||
|
53 | ||||
|
54 | If your name is missing, please add it. | |||
|
55 | ||||
|
56 | Our Copyright Policy | |||
|
57 | -------------------- | |||
|
58 | ||||
|
59 | IPython uses a shared copyright model. Each contributor maintains copyright over | |||
|
60 | their contributions to IPython. But, it is important to note that these | |||
|
61 | contributions are typically only changes to the repositories. Thus, the IPython | |||
|
62 | source code, in its entirety is not the copyright of any single person or | |||
|
63 | institution. Instead, it is the collective copyright of the entire IPython | |||
|
64 | Development Team. If individual contributors want to maintain a record of what | |||
|
65 | changes/contributions they have specific copyright on, they should indicate their | |||
|
66 | copyright in the commit message of the change, when they commit the change to | |||
|
67 | one of the IPython repositories. | |||
|
68 | ||||
|
69 | With this in mind, the following banner should be used in any source code file to | |||
|
70 | indicate the copyright and license terms: | |||
|
71 | ||||
|
72 | #------------------------------------------------------------------------------- | |||
|
73 | # Copyright (C) 2008 The IPython Development Team | |||
|
74 | # | |||
|
75 | # Distributed under the terms of the BSD License. The full license is in | |||
|
76 | # the file COPYING, distributed as part of this software. | |||
|
77 | #------------------------------------------------------------------------------- No newline at end of file |
@@ -0,0 +1,179 | |||||
|
1 | """Load and store configuration objects. | |||
|
2 | ||||
|
3 | Test this module using | |||
|
4 | ||||
|
5 | nosetests -v --with-doctest --doctest-tests IPython.config | |||
|
6 | ||||
|
7 | """ | |||
|
8 | ||||
|
9 | from __future__ import with_statement | |||
|
10 | from contextlib import contextmanager | |||
|
11 | ||||
|
12 | import inspect | |||
|
13 | import types | |||
|
14 | from IPython.config import traitlets | |||
|
15 | from traitlets import Traitlet | |||
|
16 | from IPython.external.configobj import ConfigObj | |||
|
17 | ||||
|
18 | def debug(s): | |||
|
19 | import sys | |||
|
20 | sys.stderr.write(str(s) + '\n') | |||
|
21 | ||||
|
22 | @contextmanager | |||
|
23 | def raw(config): | |||
|
24 | """Context manager for accessing traitlets directly. | |||
|
25 | ||||
|
26 | """ | |||
|
27 | config.__getattribute__('',raw_access=True) | |||
|
28 | yield config | |||
|
29 | config.__getattribute__('',raw_access=False) | |||
|
30 | ||||
|
31 | class Config(object): | |||
|
32 | """ | |||
|
33 | Implementation Notes | |||
|
34 | ==================== | |||
|
35 | All instances of the same Config class share properties. Therefore, | |||
|
36 | ||||
|
37 | >>> class Sample(Config): | |||
|
38 | ... my_float = traitlets.Float(3) | |||
|
39 | ||||
|
40 | >>> s0 = Sample() | |||
|
41 | >>> s1 = Sample() | |||
|
42 | >>> s0.my_float = 5 | |||
|
43 | >>> s0.my_float == s1.my_float | |||
|
44 | True | |||
|
45 | ||||
|
46 | """ | |||
|
47 | def __init__(self): | |||
|
48 | # Instantiate subconfigs | |||
|
49 | with raw(self): | |||
|
50 | subconfigs = [(n,v) for n,v in | |||
|
51 | inspect.getmembers(self, inspect.isclass) | |||
|
52 | if not n.startswith('__')] | |||
|
53 | ||||
|
54 | for n,v in subconfigs: | |||
|
55 | setattr(self, n, v()) | |||
|
56 | ||||
|
57 | def __getattribute__(self,attr,raw_access=None, | |||
|
58 | _ns={'raw_access':False}): | |||
|
59 | if raw_access is not None: | |||
|
60 | _ns['raw_access'] = raw_access | |||
|
61 | return | |||
|
62 | ||||
|
63 | obj = object.__getattribute__(self,attr) | |||
|
64 | if isinstance(obj,Traitlet) and not _ns['raw_access']: | |||
|
65 | return obj.__call__() | |||
|
66 | else: | |||
|
67 | return obj | |||
|
68 | ||||
|
69 | def __setattr__(self,attr,value): | |||
|
70 | obj = object.__getattribute__(self,attr) | |||
|
71 | if isinstance(obj,Traitlet): | |||
|
72 | obj(value) | |||
|
73 | else: | |||
|
74 | self.__dict__[attr] = value | |||
|
75 | ||||
|
76 | def __str__(self,level=1,only_modified=True): | |||
|
77 | ci = ConfigInspector(self) | |||
|
78 | out = '' | |||
|
79 | spacer = ' '*(level-1) | |||
|
80 | ||||
|
81 | # Add traitlet representations | |||
|
82 | for p,v in ci.properties: | |||
|
83 | if (v.modified and only_modified) or not only_modified: | |||
|
84 | out += spacer + '%s = %s\n' % (p,v) | |||
|
85 | ||||
|
86 | # Add subconfig representations | |||
|
87 | for (n,v) in ci.subconfigs: | |||
|
88 | sub_str = v.__str__(level=level+1,only_modified=only_modified) | |||
|
89 | if sub_str: | |||
|
90 | out += '\n' + spacer + '[' * level + ('%s' % n) \ | |||
|
91 | + ']'*level + '\n' | |||
|
92 | out += sub_str | |||
|
93 | ||||
|
94 | return out | |||
|
95 | ||||
|
96 | def __iadd__(self,source): | |||
|
97 | """Load configuration from filename, and update self. | |||
|
98 | ||||
|
99 | """ | |||
|
100 | if not isinstance(source,dict): | |||
|
101 | source = ConfigObj(source, unrepr=True) | |||
|
102 | update_from_dict(self,source) | |||
|
103 | return self | |||
|
104 | ||||
|
105 | ||||
|
106 | class ConfigInspector(object): | |||
|
107 | """Allow the inspection of Config objects. | |||
|
108 | ||||
|
109 | """ | |||
|
110 | def __init__(self,config): | |||
|
111 | self._config = config | |||
|
112 | ||||
|
113 | @property | |||
|
114 | def properties(self): | |||
|
115 | "Return all traitlet names." | |||
|
116 | with raw(self._config): | |||
|
117 | return inspect.getmembers(self._config, | |||
|
118 | lambda obj: isinstance(obj, Traitlet)) | |||
|
119 | ||||
|
120 | @property | |||
|
121 | def subconfigs(self): | |||
|
122 | "Return all subconfig names and values." | |||
|
123 | with raw(self._config): | |||
|
124 | return [(n,v) for n,v in | |||
|
125 | inspect.getmembers(self._config, | |||
|
126 | lambda obj: isinstance(obj,Config)) | |||
|
127 | if not n.startswith('__')] | |||
|
128 | ||||
|
129 | def reset(self): | |||
|
130 | for (p,v) in self.properties: | |||
|
131 | v.reset() | |||
|
132 | ||||
|
133 | for (s,v) in self.subconfigs: | |||
|
134 | ConfigInspector(v).reset() | |||
|
135 | ||||
|
136 | def update_from_dict(config,d): | |||
|
137 | """Propagate the values of the dictionary to the given configuration. | |||
|
138 | ||||
|
139 | Useful to load configobj instances. | |||
|
140 | ||||
|
141 | """ | |||
|
142 | for k,v in d.items(): | |||
|
143 | try: | |||
|
144 | prop_or_subconfig = getattr(config, k) | |||
|
145 | except AttributeError: | |||
|
146 | print "Invalid section/property in config file: %s" % k | |||
|
147 | else: | |||
|
148 | if isinstance(v,dict): | |||
|
149 | update_from_dict(prop_or_subconfig,v) | |||
|
150 | else: | |||
|
151 | setattr(config, k, v) | |||
|
152 | ||||
|
153 | def dict_from_config(config,only_modified=True): | |||
|
154 | """Create a dictionary from a Config object.""" | |||
|
155 | ci = ConfigInspector(config) | |||
|
156 | out = {} | |||
|
157 | ||||
|
158 | for p,v in ci.properties: | |||
|
159 | if (v.modified and only_modified) or not only_modified: | |||
|
160 | out[p] = v | |||
|
161 | ||||
|
162 | for s,v in ci.subconfigs: | |||
|
163 | d = dict_from_config(v,only_modified) | |||
|
164 | if d != {}: | |||
|
165 | out[s] = d | |||
|
166 | ||||
|
167 | return out | |||
|
168 | ||||
|
169 | def write(config, target): | |||
|
170 | """Write a configuration to file. | |||
|
171 | ||||
|
172 | """ | |||
|
173 | if isinstance(target, str): | |||
|
174 | target = open(target, 'w+') | |||
|
175 | target.flush() | |||
|
176 | target.seek(0) | |||
|
177 | ||||
|
178 | confobj = ConfigObj(dict_from_config(config), unrepr=True) | |||
|
179 | confobj.write(target) |
@@ -0,0 +1,19 | |||||
|
1 | from IPython.config.api import * | |||
|
2 | ||||
|
3 | class SubSubSample(Config): | |||
|
4 | my_int = Int(3) | |||
|
5 | ||||
|
6 | ||||
|
7 | class Sample(Config): | |||
|
8 | my_float = Float(3) | |||
|
9 | my_choice = Enum('a','b','c') | |||
|
10 | ||||
|
11 | class MiddleSection(Config): | |||
|
12 | left_alone = Enum('1','2','c') | |||
|
13 | unknown_mod = Module('asd') | |||
|
14 | ||||
|
15 | class SubSample(Config): | |||
|
16 | subsample_uri = URI('http://localhost:8080') | |||
|
17 | ||||
|
18 | # Example of how to include external config | |||
|
19 | SubSubSample = SubSubSample() |
@@ -0,0 +1,135 | |||||
|
1 | """ | |||
|
2 | # Test utilities | |||
|
3 | ||||
|
4 | >>> import os | |||
|
5 | ||||
|
6 | >>> def dict_as_sorted_list(d): | |||
|
7 | ... for k in d: | |||
|
8 | ... if isinstance(d[k],dict): | |||
|
9 | ... d[k] = dict_as_sorted_list(d[k]) | |||
|
10 | ... return sorted(d.items()) | |||
|
11 | ||||
|
12 | >>> def pprint(d,level=0): | |||
|
13 | ... if isinstance(d,dict): | |||
|
14 | ... d = dict_as_sorted_list(d) | |||
|
15 | ... for item,value in d: | |||
|
16 | ... if isinstance(value,list): | |||
|
17 | ... print "%s%s" % (' '*level, item) | |||
|
18 | ... pprint(value,level+2) | |||
|
19 | ... else: | |||
|
20 | ... print "%s%s: %s" % (' '*level, item, value) | |||
|
21 | ||||
|
22 | ||||
|
23 | # Tests | |||
|
24 | ||||
|
25 | >>> from IPython.config.api import * | |||
|
26 | >>> from sample_config import * | |||
|
27 | ||||
|
28 | >>> s = Sample() | |||
|
29 | >>> print s.my_float | |||
|
30 | 3.0 | |||
|
31 | >>> s.my_float = 4 | |||
|
32 | >>> print s.my_float | |||
|
33 | 4.0 | |||
|
34 | >>> print type(s.my_float) | |||
|
35 | <type 'float'> | |||
|
36 | >>> s.SubSample.SubSubSample.my_int = 5.0 | |||
|
37 | >>> print s.SubSample.SubSubSample.my_int | |||
|
38 | 5 | |||
|
39 | ||||
|
40 | >>> i = ConfigInspector(s) | |||
|
41 | >>> print i.properties | |||
|
42 | [('my_choice', 'a'), ('my_float', 4.0)] | |||
|
43 | >>> print tuple(s for s,v in i.subconfigs) | |||
|
44 | ('MiddleSection', 'SubSample') | |||
|
45 | ||||
|
46 | >>> print s | |||
|
47 | my_float = 4.0 | |||
|
48 | <BLANKLINE> | |||
|
49 | [SubSample] | |||
|
50 | <BLANKLINE> | |||
|
51 | [[SubSubSample]] | |||
|
52 | my_int = 5 | |||
|
53 | <BLANKLINE> | |||
|
54 | ||||
|
55 | >>> import tempfile | |||
|
56 | >>> fn = tempfile.mktemp() | |||
|
57 | >>> f = open(fn,'w') | |||
|
58 | >>> f.write(str(s)) | |||
|
59 | >>> f.close() | |||
|
60 | ||||
|
61 | >>> s += fn | |||
|
62 | ||||
|
63 | >>> from IPython.external.configobj import ConfigObj | |||
|
64 | >>> c = ConfigObj(fn) | |||
|
65 | >>> c['SubSample']['subsample_uri'] = 'http://ipython.scipy.org' | |||
|
66 | ||||
|
67 | >>> s += c | |||
|
68 | >>> print s | |||
|
69 | my_float = 4.0 | |||
|
70 | <BLANKLINE> | |||
|
71 | [SubSample] | |||
|
72 | subsample_uri = 'http://ipython.scipy.org' | |||
|
73 | <BLANKLINE> | |||
|
74 | [[SubSubSample]] | |||
|
75 | my_int = 5 | |||
|
76 | <BLANKLINE> | |||
|
77 | ||||
|
78 | >>> pprint(dict_from_config(s,only_modified=False)) | |||
|
79 | MiddleSection | |||
|
80 | left_alone: '1' | |||
|
81 | unknown_mod: 'asd' | |||
|
82 | SubSample | |||
|
83 | SubSubSample | |||
|
84 | my_int: 5 | |||
|
85 | subsample_uri: 'http://ipython.scipy.org' | |||
|
86 | my_choice: 'a' | |||
|
87 | my_float: 4.0 | |||
|
88 | ||||
|
89 | >>> pprint(dict_from_config(s)) | |||
|
90 | SubSample | |||
|
91 | SubSubSample | |||
|
92 | my_int: 5 | |||
|
93 | subsample_uri: 'http://ipython.scipy.org' | |||
|
94 | my_float: 4.0 | |||
|
95 | ||||
|
96 | Test roundtripping: | |||
|
97 | ||||
|
98 | >>> fn = tempfile.mktemp() | |||
|
99 | >>> f = open(fn, 'w') | |||
|
100 | >>> f.write(''' | |||
|
101 | ... [MiddleSection] | |||
|
102 | ... # some comment here | |||
|
103 | ... left_alone = 'c' | |||
|
104 | ... ''') | |||
|
105 | >>> f.close() | |||
|
106 | ||||
|
107 | >>> s += fn | |||
|
108 | ||||
|
109 | >>> pprint(dict_from_config(s)) | |||
|
110 | MiddleSection | |||
|
111 | left_alone: 'c' | |||
|
112 | SubSample | |||
|
113 | SubSubSample | |||
|
114 | my_int: 5 | |||
|
115 | subsample_uri: 'http://ipython.scipy.org' | |||
|
116 | my_float: 4.0 | |||
|
117 | ||||
|
118 | >>> write(s, fn) | |||
|
119 | >>> f = file(fn,'r') | |||
|
120 | >>> ConfigInspector(s).reset() | |||
|
121 | >>> pprint(dict_from_config(s)) | |||
|
122 | ||||
|
123 | >>> s += fn | |||
|
124 | >>> os.unlink(fn) | |||
|
125 | >>> pprint(dict_from_config(s)) | |||
|
126 | MiddleSection | |||
|
127 | left_alone: 'c' | |||
|
128 | SubSample | |||
|
129 | SubSubSample | |||
|
130 | my_int: 5 | |||
|
131 | subsample_uri: 'http://ipython.scipy.org' | |||
|
132 | my_float: 4.0 | |||
|
133 | ||||
|
134 | ||||
|
135 | """ |
@@ -0,0 +1,322 | |||||
|
1 | """Traitlets -- a light-weight meta-class free stand-in for Traits. | |||
|
2 | ||||
|
3 | Traitlet behaviour | |||
|
4 | ================== | |||
|
5 | - Automatic casting, equivalent to traits.C* classes, e.g. CFloat, CBool etc. | |||
|
6 | ||||
|
7 | - By default, validation is done by attempting to cast a given value | |||
|
8 | to the underlying type, e.g. bool for Bool, float for Float etc. | |||
|
9 | ||||
|
10 | - To set or get a Traitlet value, use the ()-operator. E.g. | |||
|
11 | ||||
|
12 | >>> b = Bool(False) | |||
|
13 | >>> b(True) | |||
|
14 | >>> print b # returns a string representation of the Traitlet | |||
|
15 | True | |||
|
16 | >>> print b() # returns the underlying bool object | |||
|
17 | True | |||
|
18 | ||||
|
19 | This makes it possible to change values "in-place", unlike an assigment | |||
|
20 | of the form | |||
|
21 | ||||
|
22 | >>> c = Bool(False) | |||
|
23 | >>> c = True | |||
|
24 | ||||
|
25 | which results in | |||
|
26 | ||||
|
27 | >>> print type(b), type(c) | |||
|
28 | <class 'IPython.config.traitlets.Bool'> <type 'bool'> | |||
|
29 | ||||
|
30 | - Each Traitlet keeps track of its modification state, e.g. | |||
|
31 | ||||
|
32 | >>> c = Bool(False) | |||
|
33 | >>> print c.modified | |||
|
34 | False | |||
|
35 | >>> c(False) | |||
|
36 | >>> print c.modified | |||
|
37 | False | |||
|
38 | >>> c(True) | |||
|
39 | >>> print c.modified | |||
|
40 | True | |||
|
41 | ||||
|
42 | How to customize Traitlets | |||
|
43 | ========================== | |||
|
44 | ||||
|
45 | The easiest way to create a new Traitlet is by wrapping an underlying | |||
|
46 | Python type. This is done by setting the "_type" class attribute. For | |||
|
47 | example, creating an int-like Traitlet is done as follows: | |||
|
48 | ||||
|
49 | >>> class MyInt(Traitlet): | |||
|
50 | ... _type = int | |||
|
51 | ||||
|
52 | >>> i = MyInt(3) | |||
|
53 | >>> i(4) | |||
|
54 | >>> print i | |||
|
55 | 4 | |||
|
56 | ||||
|
57 | >>> try: | |||
|
58 | ... i('a') | |||
|
59 | ... except ValidationError: | |||
|
60 | ... pass # this is expected | |||
|
61 | ... else: | |||
|
62 | ... "This should not be reached." | |||
|
63 | ||||
|
64 | Furthermore, the following methods are provided for finer grained | |||
|
65 | control of validation and assignment: | |||
|
66 | ||||
|
67 | - validate(self,value) | |||
|
68 | Ensure that "value" is valid. If not, raise an exception of any kind | |||
|
69 | with a suitable error message, which is reported to the user. | |||
|
70 | ||||
|
71 | - prepare_value(self) | |||
|
72 | When using the ()-operator to query the underlying Traitlet value, | |||
|
73 | that value is first passed through prepare_value. For example: | |||
|
74 | ||||
|
75 | >>> class Eval(Traitlet): | |||
|
76 | ... _type = str | |||
|
77 | ... | |||
|
78 | ... def prepare_value(self): | |||
|
79 | ... return eval(self._value) | |||
|
80 | ||||
|
81 | >>> x = Eval('1+1') | |||
|
82 | >>> print x | |||
|
83 | '1+1' | |||
|
84 | >>> print x() | |||
|
85 | 2 | |||
|
86 | ||||
|
87 | - __repr__(self) | |||
|
88 | By default, repr(self._value) is returned. This can be customised | |||
|
89 | to, for example, first call prepare_value and return the repr of | |||
|
90 | the resulting object. | |||
|
91 | ||||
|
92 | """ | |||
|
93 | ||||
|
94 | import re | |||
|
95 | import types | |||
|
96 | ||||
|
97 | class ValidationError(Exception): | |||
|
98 | pass | |||
|
99 | ||||
|
100 | class Traitlet(object): | |||
|
101 | """Traitlet which knows its modification state. | |||
|
102 | ||||
|
103 | """ | |||
|
104 | def __init__(self, value): | |||
|
105 | "Validate and store the default value. State is 'unmodified'." | |||
|
106 | self._type = getattr(self,'_type',None) | |||
|
107 | value = self._parse_validation(value) | |||
|
108 | self._default_value = value | |||
|
109 | self.reset() | |||
|
110 | ||||
|
111 | def reset(self): | |||
|
112 | self._value = self._default_value | |||
|
113 | self._changed = False | |||
|
114 | ||||
|
115 | def validate(self, value): | |||
|
116 | "Validate the given value." | |||
|
117 | if self._type is not None: | |||
|
118 | self._type(value) | |||
|
119 | ||||
|
120 | def _parse_validation(self, value): | |||
|
121 | """Run validation and return a descriptive error if needed. | |||
|
122 | ||||
|
123 | """ | |||
|
124 | try: | |||
|
125 | self.validate(value) | |||
|
126 | except Exception, e: | |||
|
127 | err_message = 'Cannot convert "%s" to %s' % \ | |||
|
128 | (value, self.__class__.__name__.lower()) | |||
|
129 | if e.message: | |||
|
130 | err_message += ': %s' % e.message | |||
|
131 | raise ValidationError(err_message) | |||
|
132 | else: | |||
|
133 | # Cast to appropriate type before storing | |||
|
134 | if self._type is not None: | |||
|
135 | value = self._type(value) | |||
|
136 | return value | |||
|
137 | ||||
|
138 | def prepare_value(self): | |||
|
139 | """Run on value before it is ever returned to the user. | |||
|
140 | ||||
|
141 | """ | |||
|
142 | return self._value | |||
|
143 | ||||
|
144 | def __call__(self,value=None): | |||
|
145 | """Query or set value depending on whether `value` is specified. | |||
|
146 | ||||
|
147 | """ | |||
|
148 | if value is None: | |||
|
149 | return self.prepare_value() | |||
|
150 | ||||
|
151 | self._value = self._parse_validation(value) | |||
|
152 | self._changed = (self._value != self._default_value) | |||
|
153 | ||||
|
154 | @property | |||
|
155 | def modified(self): | |||
|
156 | "Whether value has changed from original definition." | |||
|
157 | return self._changed | |||
|
158 | ||||
|
159 | def __repr__(self): | |||
|
160 | """This class is represented by the underlying repr. Used when | |||
|
161 | dumping value to file. | |||
|
162 | ||||
|
163 | """ | |||
|
164 | return repr(self._value) | |||
|
165 | ||||
|
166 | class Float(Traitlet): | |||
|
167 | """ | |||
|
168 | >>> f = Float(0) | |||
|
169 | >>> print f.modified | |||
|
170 | False | |||
|
171 | ||||
|
172 | >>> f(3) | |||
|
173 | >>> print f() | |||
|
174 | 3.0 | |||
|
175 | >>> print f.modified | |||
|
176 | True | |||
|
177 | ||||
|
178 | >>> f(0) | |||
|
179 | >>> print f() | |||
|
180 | 0.0 | |||
|
181 | >>> print f.modified | |||
|
182 | False | |||
|
183 | ||||
|
184 | >>> try: | |||
|
185 | ... f('a') | |||
|
186 | ... except ValidationError: | |||
|
187 | ... pass | |||
|
188 | ||||
|
189 | """ | |||
|
190 | _type = float | |||
|
191 | ||||
|
192 | class Enum(Traitlet): | |||
|
193 | """ | |||
|
194 | >>> c = Enum('a','b','c') | |||
|
195 | >>> print c() | |||
|
196 | a | |||
|
197 | ||||
|
198 | >>> try: | |||
|
199 | ... c('unknown') | |||
|
200 | ... except ValidationError: | |||
|
201 | ... pass | |||
|
202 | ||||
|
203 | >>> print c.modified | |||
|
204 | False | |||
|
205 | ||||
|
206 | >>> c('b') | |||
|
207 | >>> print c() | |||
|
208 | b | |||
|
209 | ||||
|
210 | """ | |||
|
211 | def __init__(self, *options): | |||
|
212 | self._options = options | |||
|
213 | super(Enum,self).__init__(options[0]) | |||
|
214 | ||||
|
215 | def validate(self, value): | |||
|
216 | if not value in self._options: | |||
|
217 | raise ValueError('must be one of %s' % str(self._options)) | |||
|
218 | ||||
|
219 | class Module(Traitlet): | |||
|
220 | """ | |||
|
221 | >>> m = Module('some.unknown.module') | |||
|
222 | >>> print m | |||
|
223 | 'some.unknown.module' | |||
|
224 | ||||
|
225 | >>> m = Module('re') | |||
|
226 | >>> assert type(m()) is types.ModuleType | |||
|
227 | ||||
|
228 | """ | |||
|
229 | _type = str | |||
|
230 | ||||
|
231 | def prepare_value(self): | |||
|
232 | try: | |||
|
233 | module = eval(self._value) | |||
|
234 | except: | |||
|
235 | module = None | |||
|
236 | ||||
|
237 | if type(module) is not types.ModuleType: | |||
|
238 | raise ValueError("Invalid module name: %s" % self._value) | |||
|
239 | else: | |||
|
240 | return module | |||
|
241 | ||||
|
242 | ||||
|
243 | class URI(Traitlet): | |||
|
244 | """ | |||
|
245 | >>> u = URI('http://') | |||
|
246 | ||||
|
247 | >>> try: | |||
|
248 | ... u = URI('something.else') | |||
|
249 | ... except ValidationError: | |||
|
250 | ... pass | |||
|
251 | ||||
|
252 | >>> u = URI('http://ipython.scipy.org/') | |||
|
253 | >>> print u | |||
|
254 | 'http://ipython.scipy.org/' | |||
|
255 | ||||
|
256 | """ | |||
|
257 | _regexp = re.compile(r'^[a-zA-Z]+:\/\/') | |||
|
258 | _type = str | |||
|
259 | ||||
|
260 | def validate(self, uri): | |||
|
261 | if not self._regexp.match(uri): | |||
|
262 | raise ValueError() | |||
|
263 | ||||
|
264 | class Int(Traitlet): | |||
|
265 | """ | |||
|
266 | >>> i = Int(3.5) | |||
|
267 | >>> print i | |||
|
268 | 3 | |||
|
269 | >>> print i() | |||
|
270 | 3 | |||
|
271 | ||||
|
272 | >>> i = Int('4') | |||
|
273 | >>> print i | |||
|
274 | 4 | |||
|
275 | ||||
|
276 | >>> try: | |||
|
277 | ... i = Int('a') | |||
|
278 | ... except ValidationError: | |||
|
279 | ... pass | |||
|
280 | ... else: | |||
|
281 | ... raise "Should fail" | |||
|
282 | ||||
|
283 | """ | |||
|
284 | _type = int | |||
|
285 | ||||
|
286 | class Bool(Traitlet): | |||
|
287 | """ | |||
|
288 | >>> b = Bool(2) | |||
|
289 | >>> print b | |||
|
290 | True | |||
|
291 | >>> print b() | |||
|
292 | True | |||
|
293 | ||||
|
294 | >>> b = Bool('True') | |||
|
295 | >>> print b | |||
|
296 | True | |||
|
297 | >>> b(True) | |||
|
298 | >>> print b.modified | |||
|
299 | False | |||
|
300 | ||||
|
301 | >>> print Bool(0) | |||
|
302 | False | |||
|
303 | ||||
|
304 | """ | |||
|
305 | _type = bool | |||
|
306 | ||||
|
307 | class Unicode(Traitlet): | |||
|
308 | """ | |||
|
309 | >>> u = Unicode(123) | |||
|
310 | >>> print u | |||
|
311 | u'123' | |||
|
312 | ||||
|
313 | >>> u = Unicode('123') | |||
|
314 | >>> print u.modified | |||
|
315 | False | |||
|
316 | ||||
|
317 | >>> u('hello world') | |||
|
318 | >>> print u | |||
|
319 | u'hello world' | |||
|
320 | ||||
|
321 | """ | |||
|
322 | _type = unicode |
@@ -0,0 +1,11 | |||||
|
1 | =============== | |||
|
2 | IPython1 README | |||
|
3 | =============== | |||
|
4 | ||||
|
5 | .. contents:: | |||
|
6 | ||||
|
7 | Overview | |||
|
8 | ======== | |||
|
9 | ||||
|
10 | Welcome to IPython. New users should consult our documentation, which can be found | |||
|
11 | in the docs/source subdirectory. |
@@ -0,0 +1,70 | |||||
|
1 | # Makefile for Sphinx documentation | |||
|
2 | # | |||
|
3 | ||||
|
4 | # You can set these variables from the command line. | |||
|
5 | SPHINXOPTS = | |||
|
6 | SPHINXBUILD = sphinx-build | |||
|
7 | PAPER = | |||
|
8 | ||||
|
9 | # Internal variables. | |||
|
10 | PAPEROPT_a4 = -D latex_paper_size=a4 | |||
|
11 | PAPEROPT_letter = -D latex_paper_size=letter | |||
|
12 | ALLSPHINXOPTS = -d build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source | |||
|
13 | ||||
|
14 | .PHONY: help clean html web pickle htmlhelp latex changes linkcheck | |||
|
15 | ||||
|
16 | help: | |||
|
17 | @echo "Please use \`make <target>' where <target> is one of" | |||
|
18 | @echo " html to make standalone HTML files" | |||
|
19 | @echo " pickle to make pickle files (usable by e.g. sphinx-web)" | |||
|
20 | @echo " htmlhelp to make HTML files and a HTML help project" | |||
|
21 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" | |||
|
22 | @echo " changes to make an overview over all changed/added/deprecated items" | |||
|
23 | @echo " linkcheck to check all external links for integrity" | |||
|
24 | ||||
|
25 | clean: | |||
|
26 | -rm -rf build/* | |||
|
27 | ||||
|
28 | html: | |||
|
29 | mkdir -p build/html build/doctrees | |||
|
30 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html | |||
|
31 | @echo | |||
|
32 | @echo "Build finished. The HTML pages are in build/html." | |||
|
33 | ||||
|
34 | pickle: | |||
|
35 | mkdir -p build/pickle build/doctrees | |||
|
36 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) build/pickle | |||
|
37 | @echo | |||
|
38 | @echo "Build finished; now you can process the pickle files or run" | |||
|
39 | @echo " sphinx-web build/pickle" | |||
|
40 | @echo "to start the sphinx-web server." | |||
|
41 | ||||
|
42 | web: pickle | |||
|
43 | ||||
|
44 | htmlhelp: | |||
|
45 | mkdir -p build/htmlhelp build/doctrees | |||
|
46 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp | |||
|
47 | @echo | |||
|
48 | @echo "Build finished; now you can run HTML Help Workshop with the" \ | |||
|
49 | ".hhp project file in build/htmlhelp." | |||
|
50 | ||||
|
51 | latex: | |||
|
52 | mkdir -p build/latex build/doctrees | |||
|
53 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex | |||
|
54 | @echo | |||
|
55 | @echo "Build finished; the LaTeX files are in build/latex." | |||
|
56 | @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ | |||
|
57 | "run these through (pdf)latex." | |||
|
58 | ||||
|
59 | changes: | |||
|
60 | mkdir -p build/changes build/doctrees | |||
|
61 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes | |||
|
62 | @echo | |||
|
63 | @echo "The overview file is in build/changes." | |||
|
64 | ||||
|
65 | linkcheck: | |||
|
66 | mkdir -p build/linkcheck build/doctrees | |||
|
67 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck | |||
|
68 | @echo | |||
|
69 | @echo "Link check complete; look for any errors in the above output " \ | |||
|
70 | "or in build/linkcheck/output.txt." |
@@ -0,0 +1,161 | |||||
|
1 | .. _changes: | |||
|
2 | ||||
|
3 | ========== | |||
|
4 | What's new | |||
|
5 | ========== | |||
|
6 | ||||
|
7 | .. contents:: | |||
|
8 | ||||
|
9 | Release 0.9 | |||
|
10 | =========== | |||
|
11 | ||||
|
12 | New features | |||
|
13 | ------------ | |||
|
14 | ||||
|
15 | * All of the parallel computing capabilities from `ipython1-dev` have been merged into | |||
|
16 | IPython proper. This resulted in the following new subpackages: | |||
|
17 | :mod:`IPython.kernel`, :mod:`IPython.kernel.core`, :mod:`IPython.config`, | |||
|
18 | :mod:`IPython.tools` and :mod:`IPython.testing`. | |||
|
19 | * As part of merging in the `ipython1-dev` stuff, the `setup.py` script and friends | |||
|
20 | have been completely refactored. Now we are checking for dependencies using | |||
|
21 | the approach that matplotlib uses. | |||
|
22 | * The documentation has been completely reorganized to accept the documentation | |||
|
23 | from `ipython1-dev`. | |||
|
24 | * We have switched to using Foolscap for all of our network protocols in | |||
|
25 | :mod:`IPython.kernel`. This gives us secure connections that are both encrypted | |||
|
26 | and authenticated. | |||
|
27 | * We have a brand new `COPYING.txt` files that describes the IPython license | |||
|
28 | and copyright. The biggest change is that we are putting "The IPython | |||
|
29 | Development Team" as the copyright holder. We give more details about exactly | |||
|
30 | what this means in this file. All developer should read this and use the new | |||
|
31 | banner in all IPython source code files. | |||
|
32 | ||||
|
33 | Bug fixes | |||
|
34 | --------- | |||
|
35 | ||||
|
36 | * A few subpackages has missing `__init__.py` files. | |||
|
37 | * The documentation is only created is Sphinx is found. Previously, the `setup.py` | |||
|
38 | script would fail if it was missing. | |||
|
39 | ||||
|
40 | Backwards incompatible changes | |||
|
41 | ------------------------------ | |||
|
42 | ||||
|
43 | * IPython has a larger set of dependencies if you want all of its capabilities. | |||
|
44 | See the `setup.py` script for details. | |||
|
45 | * The constructors for :class:`IPython.kernel.client.MultiEngineClient` and | |||
|
46 | :class:`IPython.kernel.client.TaskClient` no longer take the (ip,port) tuple. | |||
|
47 | Instead they take the filename of a file that contains the FURL for that | |||
|
48 | client. If the FURL file is in your IPYTHONDIR, it will be found automatically | |||
|
49 | and the constructor can be left empty. | |||
|
50 | * The asynchronous clients in :mod:`IPython.kernel.asyncclient` are now created | |||
|
51 | using the factory functions :func:`get_multiengine_client` and | |||
|
52 | :func:`get_task_client`. These return a `Deferred` to the actual client. | |||
|
53 | * The command line options to `ipcontroller` and `ipengine` have changed to | |||
|
54 | reflect the new Foolscap network protocol and the FURL files. Please see the | |||
|
55 | help for these scripts for details. | |||
|
56 | * The configuration files for the kernel have changed because of the Foolscap stuff. | |||
|
57 | If you were using custom config files before, you should delete them and regenerate | |||
|
58 | new ones. | |||
|
59 | ||||
|
60 | Changes merged in from IPython1 | |||
|
61 | ------------------------------- | |||
|
62 | ||||
|
63 | New features | |||
|
64 | ............ | |||
|
65 | ||||
|
66 | * Much improved ``setup.py`` and ``setupegg.py`` scripts. Because Twisted | |||
|
67 | and zope.interface are now easy installable, we can declare them as dependencies | |||
|
68 | in our setupegg.py script. | |||
|
69 | * IPython is now compatible with Twisted 2.5.0 and 8.x. | |||
|
70 | * Added a new example of how to use :mod:`ipython1.kernel.asynclient`. | |||
|
71 | * Initial draft of a process daemon in :mod:`ipython1.daemon`. This has not | |||
|
72 | been merged into IPython and is still in `ipython1-dev`. | |||
|
73 | * The ``TaskController`` now has methods for getting the queue status. | |||
|
74 | * The ``TaskResult`` objects not have information about how long the task | |||
|
75 | took to run. | |||
|
76 | * We are attaching additional attributes to exceptions ``(_ipython_*)`` that | |||
|
77 | we use to carry additional info around. | |||
|
78 | * New top-level module :mod:`asyncclient` that has asynchronous versions (that | |||
|
79 | return deferreds) of the client classes. This is designed to users who want | |||
|
80 | to run their own Twisted reactor | |||
|
81 | * All the clients in :mod:`client` are now based on Twisted. This is done by | |||
|
82 | running the Twisted reactor in a separate thread and using the | |||
|
83 | :func:`blockingCallFromThread` function that is in recent versions of Twisted. | |||
|
84 | * Functions can now be pushed/pulled to/from engines using | |||
|
85 | :meth:`MultiEngineClient.push_function` and :meth:`MultiEngineClient.pull_function`. | |||
|
86 | * Gather/scatter are now implemented in the client to reduce the work load | |||
|
87 | of the controller and improve performance. | |||
|
88 | * Complete rewrite of the IPython docuementation. All of the documentation | |||
|
89 | from the IPython website has been moved into docs/source as restructured | |||
|
90 | text documents. PDF and HTML documentation are being generated using | |||
|
91 | Sphinx. | |||
|
92 | * New developer oriented documentation: development guidelines and roadmap. | |||
|
93 | * Traditional ``ChangeLog`` has been changed to a more useful ``changes.txt`` file | |||
|
94 | that is organized by release and is meant to provide something more relevant | |||
|
95 | for users. | |||
|
96 | ||||
|
97 | Bug fixes | |||
|
98 | ......... | |||
|
99 | ||||
|
100 | * Created a proper ``MANIFEST.in`` file to create source distributions. | |||
|
101 | * Fixed a bug in the ``MultiEngine`` interface. Previously, multi-engine | |||
|
102 | actions were being collected with a :class:`DeferredList` with | |||
|
103 | ``fireononeerrback=1``. This meant that methods were returning | |||
|
104 | before all engines had given their results. This was causing extremely odd | |||
|
105 | bugs in certain cases. To fix this problem, we have 1) set | |||
|
106 | ``fireononeerrback=0`` to make sure all results (or exceptions) are in | |||
|
107 | before returning and 2) introduced a :exc:`CompositeError` exception | |||
|
108 | that wraps all of the engine exceptions. This is a huge change as it means | |||
|
109 | that users will have to catch :exc:`CompositeError` rather than the actual | |||
|
110 | exception. | |||
|
111 | ||||
|
112 | Backwards incompatible changes | |||
|
113 | .............................. | |||
|
114 | ||||
|
115 | * All names have been renamed to conform to the lowercase_with_underscore | |||
|
116 | convention. This will require users to change references to all names like | |||
|
117 | ``queueStatus`` to ``queue_status``. | |||
|
118 | * Previously, methods like :meth:`MultiEngineClient.push` and | |||
|
119 | :meth:`MultiEngineClient.push` used ``*args`` and ``**kwargs``. This was | |||
|
120 | becoming a problem as we weren't able to introduce new keyword arguments into | |||
|
121 | the API. Now these methods simple take a dict or sequence. This has also allowed | |||
|
122 | us to get rid of the ``*All`` methods like :meth:`pushAll` and :meth:`pullAll`. | |||
|
123 | These things are now handled with the ``targets`` keyword argument that defaults | |||
|
124 | to ``'all'``. | |||
|
125 | * The :attr:`MultiEngineClient.magicTargets` has been renamed to | |||
|
126 | :attr:`MultiEngineClient.targets`. | |||
|
127 | * All methods in the MultiEngine interface now accept the optional keyword argument | |||
|
128 | ``block``. | |||
|
129 | * Renamed :class:`RemoteController` to :class:`MultiEngineClient` and | |||
|
130 | :class:`TaskController` to :class:`TaskClient`. | |||
|
131 | * Renamed the top-level module from :mod:`api` to :mod:`client`. | |||
|
132 | * Most methods in the multiengine interface now raise a :exc:`CompositeError` exception | |||
|
133 | that wraps the user's exceptions, rather than just raising the raw user's exception. | |||
|
134 | * Changed the ``setupNS`` and ``resultNames`` in the ``Task`` class to ``push`` | |||
|
135 | and ``pull``. | |||
|
136 | ||||
|
137 | Release 0.8.4 | |||
|
138 | ============= | |||
|
139 | ||||
|
140 | Someone needs to describe what went into 0.8.4. | |||
|
141 | ||||
|
142 | Release 0.8.2 | |||
|
143 | ============= | |||
|
144 | ||||
|
145 | * %pushd/%popd behave differently; now "pushd /foo" pushes CURRENT directory | |||
|
146 | and jumps to /foo. The current behaviour is closer to the documented | |||
|
147 | behaviour, and should not trip anyone. | |||
|
148 | ||||
|
149 | Release 0.8.3 | |||
|
150 | ============= | |||
|
151 | ||||
|
152 | * pydb is now disabled by default (due to %run -d problems). You can enable | |||
|
153 | it by passing -pydb command line argument to IPython. Note that setting | |||
|
154 | it in config file won't work. | |||
|
155 | ||||
|
156 | Older releases | |||
|
157 | ============== | |||
|
158 | ||||
|
159 | Changes in earlier releases of IPython are described in the older file ``ChangeLog``. | |||
|
160 | Please refer to this document for details. | |||
|
161 |
@@ -0,0 +1,284 | |||||
|
1 | .. _customization: | |||
|
2 | ||||
|
3 | ======================== | |||
|
4 | Customization of IPython | |||
|
5 | ======================== | |||
|
6 | ||||
|
7 | There are 2 ways to configure IPython - the old way of using ipythonrc | |||
|
8 | files (an INI-file like format), and the new way that involves editing | |||
|
9 | your ipy_user_conf.py. Both configuration systems work at the same | |||
|
10 | time, so you can set your options in both, but if you are hesitating | |||
|
11 | about which alternative to choose, we recommend the ipy_user_conf.py | |||
|
12 | approach, as it will give you more power and control in the long | |||
|
13 | run. However, there are few options such as pylab_import_all that can | |||
|
14 | only be specified in ipythonrc file or command line - the reason for | |||
|
15 | this is that they are needed before IPython has been started up, and | |||
|
16 | the IPApi object used in ipy_user_conf.py is not yet available at that | |||
|
17 | 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 | |||
|
19 | possible. | |||
|
20 | ||||
|
21 | The ipythonrc approach | |||
|
22 | ====================== | |||
|
23 | ||||
|
24 | As we've already mentioned, IPython reads a configuration file which can | |||
|
25 | be specified at the command line (-rcfile) or which by default is | |||
|
26 | assumed to be called ipythonrc. Such a file is looked for in the current | |||
|
27 | directory where IPython is started and then in your IPYTHONDIR, which | |||
|
28 | allows you to have local configuration files for specific projects. In | |||
|
29 | this section we will call these types of configuration files simply | |||
|
30 | rcfiles (short for resource configuration file). | |||
|
31 | ||||
|
32 | The syntax of an rcfile is one of key-value pairs separated by | |||
|
33 | whitespace, one per line. Lines beginning with a # are ignored as | |||
|
34 | comments, but comments can not be put on lines with data (the parser is | |||
|
35 | 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 | |||
|
37 | tricky to implement if they were normal python files. | |||
|
38 | ||||
|
39 | First, an rcfile can contain permanent default values for almost all | |||
|
40 | command line options (except things like -help or -Version). Sec | |||
|
41 | `command line options`_ contains a description of all command-line | |||
|
42 | options. However, values you explicitly specify at the command line | |||
|
43 | override the values defined in the rcfile. | |||
|
44 | ||||
|
45 | Besides command line option values, the rcfile can specify values for | |||
|
46 | certain extra special options which are not available at the command | |||
|
47 | line. These options are briefly described below. | |||
|
48 | ||||
|
49 | Each of these options may appear as many times as you need it in the file. | |||
|
50 | ||||
|
51 | * include <file1> <file2> ...: you can name other rcfiles you want | |||
|
52 | to recursively load up to 15 levels (don't use the <> brackets in | |||
|
53 | your names!). This feature allows you to define a 'base' rcfile | |||
|
54 | with general options and special-purpose files which can be loaded | |||
|
55 | only when needed with particular configuration options. To make | |||
|
56 | this more convenient, IPython accepts the -profile <name> option | |||
|
57 | (abbreviates to -p <name>) which tells it to look for an rcfile | |||
|
58 | named ipythonrc-<name>. | |||
|
59 | * import_mod <mod1> <mod2> ...: import modules with 'import | |||
|
60 | <mod1>,<mod2>,...' | |||
|
61 | * import_some <mod> <f1> <f2> ...: import functions with 'from | |||
|
62 | <mod> import <f1>,<f2>,...' | |||
|
63 | * import_all <mod1> <mod2> ...: for each module listed import | |||
|
64 | functions with ``from <mod> import *``. | |||
|
65 | * execute <python code>: give any single-line python code to be | |||
|
66 | executed. | |||
|
67 | * execfile <filename>: execute the python file given with an | |||
|
68 | 'execfile(filename)' command. Username expansion is performed on | |||
|
69 | the given names. So if you need any amount of extra fancy | |||
|
70 | customization that won't fit in any of the above 'canned' options, | |||
|
71 | you can just put it in a separate python file and execute it. | |||
|
72 | * alias <alias_def>: this is equivalent to calling | |||
|
73 | '%alias <alias_def>' at the IPython command line. This way, from | |||
|
74 | within IPython you can do common system tasks without having to | |||
|
75 | exit it or use the ! escape. IPython isn't meant to be a shell | |||
|
76 | replacement, but it is often very useful to be able to do things | |||
|
77 | with files while testing code. This gives you the flexibility to | |||
|
78 | have within IPython any aliases you may be used to under your | |||
|
79 | normal system shell. | |||
|
80 | ||||
|
81 | ipy_user_conf.py | |||
|
82 | ================ | |||
|
83 | ||||
|
84 | There should be a simple template ipy_user_conf.py file in your | |||
|
85 | ~/.ipython directory. It is a plain python module that is imported | |||
|
86 | during IPython startup, so you can do pretty much what you want there | |||
|
87 | - import modules, configure extensions, change options, define magic | |||
|
88 | commands, put variables and functions in the IPython namespace, | |||
|
89 | etc. You use the IPython extension api object, acquired by | |||
|
90 | IPython.ipapi.get() and documented in the "IPython extension API" | |||
|
91 | chapter, to interact with IPython. A sample ipy_user_conf.py is listed | |||
|
92 | below for reference:: | |||
|
93 | ||||
|
94 | # Most of your config files and extensions will probably start | |||
|
95 | # with this import | |||
|
96 | ||||
|
97 | import IPython.ipapi | |||
|
98 | ip = IPython.ipapi.get() | |||
|
99 | ||||
|
100 | # You probably want to uncomment this if you did %upgrade -nolegacy | |||
|
101 | # import ipy_defaults | |||
|
102 | ||||
|
103 | import os | |||
|
104 | ||||
|
105 | def main(): | |||
|
106 | ||||
|
107 | #ip.dbg.debugmode = True | |||
|
108 | ip.dbg.debug_stack() | |||
|
109 | ||||
|
110 | # uncomment if you want to get ipython -p sh behaviour | |||
|
111 | # without having to use command line switches | |||
|
112 | import ipy_profile_sh | |||
|
113 | import jobctrl | |||
|
114 | ||||
|
115 | # Configure your favourite editor? | |||
|
116 | # Good idea e.g. for %edit os.path.isfile | |||
|
117 | ||||
|
118 | #import ipy_editors | |||
|
119 | ||||
|
120 | # Choose one of these: | |||
|
121 | ||||
|
122 | #ipy_editors.scite() | |||
|
123 | #ipy_editors.scite('c:/opt/scite/scite.exe') | |||
|
124 | #ipy_editors.komodo() | |||
|
125 | #ipy_editors.idle() | |||
|
126 | # ... or many others, try 'ipy_editors??' after import to see them | |||
|
127 | ||||
|
128 | # Or roll your own: | |||
|
129 | #ipy_editors.install_editor("c:/opt/jed +$line $file") | |||
|
130 | ||||
|
131 | ||||
|
132 | o = ip.options | |||
|
133 | # An example on how to set options | |||
|
134 | #o.autocall = 1 | |||
|
135 | o.system_verbose = 0 | |||
|
136 | ||||
|
137 | #import_all("os sys") | |||
|
138 | #execf('~/_ipython/ns.py') | |||
|
139 | ||||
|
140 | ||||
|
141 | # -- prompt | |||
|
142 | # A different, more compact set of prompts from the default ones, that | |||
|
143 | # always show your current location in the filesystem: | |||
|
144 | ||||
|
145 | #o.prompt_in1 = r'\C_LightBlue[\C_LightCyan\Y2\C_LightBlue]\C_Normal\n\C_Green|\#>' | |||
|
146 | #o.prompt_in2 = r'.\D: ' | |||
|
147 | #o.prompt_out = r'[\#] ' | |||
|
148 | ||||
|
149 | # Try one of these color settings if you can't read the text easily | |||
|
150 | # autoexec is a list of IPython commands to execute on startup | |||
|
151 | #o.autoexec.append('%colors LightBG') | |||
|
152 | #o.autoexec.append('%colors NoColor') | |||
|
153 | o.autoexec.append('%colors Linux') | |||
|
154 | ||||
|
155 | ||||
|
156 | # some config helper functions you can use | |||
|
157 | def import_all(modules): | |||
|
158 | """ Usage: import_all("os sys") """ | |||
|
159 | for m in modules.split(): | |||
|
160 | ip.ex("from %s import *" % m) | |||
|
161 | ||||
|
162 | def execf(fname): | |||
|
163 | """ Execute a file in user namespace """ | |||
|
164 | ip.ex('execfile("%s")' % os.path.expanduser(fname)) | |||
|
165 | ||||
|
166 | main() | |||
|
167 | ||||
|
168 | .. _Prompts: | |||
|
169 | ||||
|
170 | Fine-tuning your prompt | |||
|
171 | ======================= | |||
|
172 | ||||
|
173 | IPython's prompts can be customized using a syntax similar to that of | |||
|
174 | the bash shell. Many of bash's escapes are supported, as well as a few | |||
|
175 | additional ones. We list them below:: | |||
|
176 | ||||
|
177 | \# | |||
|
178 | the prompt/history count number. This escape is automatically | |||
|
179 | wrapped in the coloring codes for the currently active color scheme. | |||
|
180 | \N | |||
|
181 | the 'naked' prompt/history count number: this is just the number | |||
|
182 | itself, without any coloring applied to it. This lets you produce | |||
|
183 | numbered prompts with your own colors. | |||
|
184 | \D | |||
|
185 | the prompt/history count, with the actual digits replaced by dots. | |||
|
186 | Used mainly in continuation prompts (prompt_in2) | |||
|
187 | \w | |||
|
188 | the current working directory | |||
|
189 | \W | |||
|
190 | the basename of current working directory | |||
|
191 | \Xn | |||
|
192 | where $n=0\ldots5.$ The current working directory, with $HOME | |||
|
193 | replaced by ~, and filtered out to contain only $n$ path elements | |||
|
194 | \Yn | |||
|
195 | Similar to \Xn, but with the $n+1$ element included if it is ~ (this | |||
|
196 | is similar to the behavior of the %cn escapes in tcsh) | |||
|
197 | \u | |||
|
198 | the username of the current user | |||
|
199 | \$ | |||
|
200 | if the effective UID is 0, a #, otherwise a $ | |||
|
201 | \h | |||
|
202 | the hostname up to the first '.' | |||
|
203 | \H | |||
|
204 | the hostname | |||
|
205 | \n | |||
|
206 | a newline | |||
|
207 | \r | |||
|
208 | a carriage return | |||
|
209 | \v | |||
|
210 | IPython version string | |||
|
211 | ||||
|
212 | In addition to these, ANSI color escapes can be insterted into the | |||
|
213 | prompts, as \C_ColorName. The list of valid color names is: Black, Blue, | |||
|
214 | Brown, Cyan, DarkGray, Green, LightBlue, LightCyan, LightGray, | |||
|
215 | LightGreen, LightPurple, LightRed, NoColor, Normal, Purple, Red, White, | |||
|
216 | Yellow. | |||
|
217 | ||||
|
218 | Finally, IPython supports the evaluation of arbitrary expressions in | |||
|
219 | your prompt string. The prompt strings are evaluated through the syntax | |||
|
220 | of PEP 215, but basically you can use $x.y to expand the value of x.y, | |||
|
221 | and for more complicated expressions you can use braces: ${foo()+x} will | |||
|
222 | call function foo and add to it the value of x, before putting the | |||
|
223 | result into your prompt. For example, using | |||
|
224 | prompt_in1 '${commands.getoutput("uptime")}\nIn [\#]: ' | |||
|
225 | will print the result of the uptime command on each prompt (assuming the | |||
|
226 | commands module has been imported in your ipythonrc file). | |||
|
227 | ||||
|
228 | ||||
|
229 | Prompt examples | |||
|
230 | ||||
|
231 | The following options in an ipythonrc file will give you IPython's | |||
|
232 | default prompts:: | |||
|
233 | ||||
|
234 | prompt_in1 'In [\#]:' | |||
|
235 | prompt_in2 ' .\D.:' | |||
|
236 | prompt_out 'Out[\#]:' | |||
|
237 | ||||
|
238 | which look like this:: | |||
|
239 | ||||
|
240 | In [1]: 1+2 | |||
|
241 | Out[1]: 3 | |||
|
242 | ||||
|
243 | In [2]: for i in (1,2,3): | |||
|
244 | ...: print i, | |||
|
245 | ...: | |||
|
246 | 1 2 3 | |||
|
247 | ||||
|
248 | These will give you a very colorful prompt with path information:: | |||
|
249 | ||||
|
250 | #prompt_in1 '\C_Red\u\C_Blue[\C_Cyan\Y1\C_Blue]\C_LightGreen\#>' | |||
|
251 | prompt_in2 ' ..\D>' | |||
|
252 | prompt_out '<\#>' | |||
|
253 | ||||
|
254 | which look like this:: | |||
|
255 | ||||
|
256 | fperez[~/ipython]1> 1+2 | |||
|
257 | <1> 3 | |||
|
258 | fperez[~/ipython]2> for i in (1,2,3): | |||
|
259 | ...> print i, | |||
|
260 | ...> | |||
|
261 | 1 2 3 | |||
|
262 | ||||
|
263 | ||||
|
264 | .. _Profiles: | |||
|
265 | ||||
|
266 | IPython profiles | |||
|
267 | ================ | |||
|
268 | ||||
|
269 | As we already mentioned, IPython supports the -profile command-line | |||
|
270 | option (see sec. `command line options`_). A profile is nothing more | |||
|
271 | than a particular configuration file like your basic ipythonrc one, | |||
|
272 | but with particular customizations for a specific purpose. When you | |||
|
273 | start IPython with 'ipython -profile <name>', it assumes that in your | |||
|
274 | IPYTHONDIR there is a file called ipythonrc-<name> or | |||
|
275 | ipy_profile_<name>.py, and loads it instead of the normal ipythonrc. | |||
|
276 | ||||
|
277 | This system allows you to maintain multiple configurations which load | |||
|
278 | modules, set options, define functions, etc. suitable for different | |||
|
279 | tasks and activate them in a very simple manner. In order to avoid | |||
|
280 | having to repeat all of your basic options (common things that don't | |||
|
281 | change such as your color preferences, for example), any profile can | |||
|
282 | include another configuration file. The most common way to use profiles | |||
|
283 | is then to have each one include your basic ipythonrc file as a starting | |||
|
284 | point, and then add further customizations. No newline at end of file |
@@ -0,0 +1,10 | |||||
|
1 | =============================== | |||
|
2 | Configuration and customization | |||
|
3 | =============================== | |||
|
4 | ||||
|
5 | .. toctree:: | |||
|
6 | :maxdepth: 1 | |||
|
7 | ||||
|
8 | initial_config.txt | |||
|
9 | customization.txt | |||
|
10 | new_config.txt |
@@ -0,0 +1,238 | |||||
|
1 | .. _initial config: | |||
|
2 | ||||
|
3 | ========================================= | |||
|
4 | Initial configuration of your environment | |||
|
5 | ========================================= | |||
|
6 | ||||
|
7 | This section will help you set various things in your environment for | |||
|
8 | your IPython sessions to be as efficient as possible. All of IPython's | |||
|
9 | configuration information, along with several example files, is stored | |||
|
10 | in a directory named by default $HOME/.ipython. You can change this by | |||
|
11 | defining the environment variable IPYTHONDIR, or at runtime with the | |||
|
12 | command line option -ipythondir. | |||
|
13 | ||||
|
14 | If all goes well, the first time you run IPython it should | |||
|
15 | automatically create a user copy of the config directory for you, | |||
|
16 | based on its builtin defaults. You can look at the files it creates to | |||
|
17 | learn more about configuring the system. The main file you will modify | |||
|
18 | to configure IPython's behavior is called ipythonrc (with a .ini | |||
|
19 | extension under Windows), included for reference in `ipythonrc`_ | |||
|
20 | section. This file is very commented and has many variables you can | |||
|
21 | change to suit your taste, you can find more details in | |||
|
22 | Sec. customization_. Here we discuss the basic things you will want to | |||
|
23 | make sure things are working properly from the beginning. | |||
|
24 | ||||
|
25 | ||||
|
26 | .. _Accessing help: | |||
|
27 | ||||
|
28 | Access to the Python help system | |||
|
29 | ================================ | |||
|
30 | ||||
|
31 | This is true for Python in general (not just for IPython): you should | |||
|
32 | have an environment variable called PYTHONDOCS pointing to the directory | |||
|
33 | where your 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 | |||
|
35 | your systems administrator. | |||
|
36 | ||||
|
37 | This is the directory which holds the HTML version of the Python | |||
|
38 | manuals. Unfortunately it seems that different Linux distributions | |||
|
39 | 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:: | |||
|
41 | ||||
|
42 | [html]> ls | |||
|
43 | about.dat acks.html dist/ ext/ index.html lib/ modindex.html | |||
|
44 | stdabout.dat tut/ about.html api/ doc/ icons/ inst/ mac/ ref/ style.css | |||
|
45 | ||||
|
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 | |||
|
48 | system with full access to the Python manuals and all modules accessible | |||
|
49 | to you. | |||
|
50 | ||||
|
51 | Under Windows it seems that pydoc finds the documentation automatically, | |||
|
52 | so no extra setup appears necessary. | |||
|
53 | ||||
|
54 | ||||
|
55 | Editor | |||
|
56 | ====== | |||
|
57 | ||||
|
58 | The %edit command (and its alias %ed) will invoke the editor set in your | |||
|
59 | environment as EDITOR. If this variable is not set, it will default to | |||
|
60 | vi under Linux/Unix and to notepad under Windows. You may want to set | |||
|
61 | this variable properly and to a lightweight editor which doesn't take | |||
|
62 | too long to start (that is, something other than a new instance of | |||
|
63 | Emacs). This way you can edit multi-line code quickly and with the power | |||
|
64 | of a real editor right inside IPython. | |||
|
65 | ||||
|
66 | If you are a dedicated Emacs user, you should set up the Emacs server so | |||
|
67 | that new requests are handled by the original process. This means that | |||
|
68 | almost no time is spent in handling the request (assuming an Emacs | |||
|
69 | process is already running). For this to work, you need to set your | |||
|
70 | EDITOR environment variable to 'emacsclient'. The code below, supplied | |||
|
71 | by Francois Pinard, can then be used in your .emacs file to enable the | |||
|
72 | server:: | |||
|
73 | ||||
|
74 | (defvar server-buffer-clients) | |||
|
75 | (when (and (fboundp 'server-start) (string-equal (getenv "TERM") 'xterm)) | |||
|
76 | (server-start) | |||
|
77 | (defun fp-kill-server-with-buffer-routine () | |||
|
78 | (and server-buffer-clients (server-done))) | |||
|
79 | (add-hook 'kill-buffer-hook 'fp-kill-server-with-buffer-routine)) | |||
|
80 | ||||
|
81 | You can also set the value of this editor via the commmand-line option | |||
|
82 | '-editor' or in your ipythonrc file. This is useful if you wish to use | |||
|
83 | specifically for IPython an editor different from your typical default | |||
|
84 | (and for Windows users who tend to use fewer environment variables). | |||
|
85 | ||||
|
86 | ||||
|
87 | Color | |||
|
88 | ===== | |||
|
89 | ||||
|
90 | The default IPython configuration has most bells and whistles turned on | |||
|
91 | (they're pretty safe). But there's one that may cause problems on some | |||
|
92 | systems: the use of color on screen for displaying information. This is | |||
|
93 | very useful, since IPython can show prompts and exception tracebacks | |||
|
94 | with various colors, display syntax-highlighted source code, and in | |||
|
95 | general make it easier to visually parse information. | |||
|
96 | ||||
|
97 | The following terminals seem to handle the color sequences fine: | |||
|
98 | ||||
|
99 | * Linux main text console, KDE Konsole, Gnome Terminal, E-term, | |||
|
100 | rxvt, xterm. | |||
|
101 | * CDE terminal (tested under Solaris). This one boldfaces light colors. | |||
|
102 | * (X)Emacs buffers. See the emacs_ section for more details on | |||
|
103 | using IPython with (X)Emacs. | |||
|
104 | * A Windows (XP/2k) command prompt with pyreadline_. | |||
|
105 | * A Windows (XP/2k) CygWin shell. Although some users have reported | |||
|
106 | problems; it is not clear whether there is an issue for everyone | |||
|
107 | or only under specific configurations. If you have full color | |||
|
108 | support under cygwin, please post to the IPython mailing list so | |||
|
109 | this issue can be resolved for all users. | |||
|
110 | ||||
|
111 | These have shown problems: | |||
|
112 | ||||
|
113 | * Windows command prompt in WinXP/2k logged into a Linux machine via | |||
|
114 | telnet or ssh. | |||
|
115 | * Windows native command prompt in WinXP/2k, without Gary Bishop's | |||
|
116 | extensions. Once Gary's readline library is installed, the normal | |||
|
117 | WinXP/2k command prompt works perfectly. | |||
|
118 | ||||
|
119 | Currently the following color schemes are available: | |||
|
120 | ||||
|
121 | * NoColor: uses no color escapes at all (all escapes are empty '' '' | |||
|
122 | strings). This 'scheme' is thus fully safe to use in any terminal. | |||
|
123 | * Linux: works well in Linux console type environments: dark | |||
|
124 | background with light fonts. It uses bright colors for | |||
|
125 | information, so it is difficult to read if you have a light | |||
|
126 | colored background. | |||
|
127 | * LightBG: the basic colors are similar to those in the Linux scheme | |||
|
128 | but darker. It is easy to read in terminals with light backgrounds. | |||
|
129 | ||||
|
130 | IPython uses colors for two main groups of things: prompts and | |||
|
131 | tracebacks which are directly printed to the terminal, and the object | |||
|
132 | introspection system which passes large sets of data through a pager. | |||
|
133 | ||||
|
134 | ||||
|
135 | Input/Output prompts and exception tracebacks | |||
|
136 | ============================================= | |||
|
137 | ||||
|
138 | You can test whether the colored prompts and tracebacks work on your | |||
|
139 | system interactively by typing '%colors Linux' at the prompt (use | |||
|
140 | '%colors LightBG' if your terminal has a light background). If the input | |||
|
141 | prompt shows garbage like:: | |||
|
142 | ||||
|
143 | [0;32mIn [[1;32m1[0;32m]: [0;00m | |||
|
144 | ||||
|
145 | instead of (in color) something like:: | |||
|
146 | ||||
|
147 | In [1]: | |||
|
148 | ||||
|
149 | this means that your terminal doesn't properly handle color escape | |||
|
150 | sequences. You can go to a 'no color' mode by typing '%colors NoColor'. | |||
|
151 | ||||
|
152 | You can try using a different terminal emulator program (Emacs users, | |||
|
153 | see below). To permanently set your color preferences, edit the file | |||
|
154 | $HOME/.ipython/ipythonrc and set the colors option to the desired value. | |||
|
155 | ||||
|
156 | ||||
|
157 | Object details (types, docstrings, source code, etc.) | |||
|
158 | ===================================================== | |||
|
159 | ||||
|
160 | IPython has a set of special functions for studying the objects you | |||
|
161 | are working with, discussed in detail in Sec. `dynamic object | |||
|
162 | information`_. But this system relies on passing information which is | |||
|
163 | longer than your screen through a data pager, such as the common Unix | |||
|
164 | less and more programs. In order to be able to see this information in | |||
|
165 | color, your pager needs to be properly configured. I strongly | |||
|
166 | recommend using less instead of more, as it seems that more simply can | |||
|
167 | not understand colored text correctly. | |||
|
168 | ||||
|
169 | In order to configure less as your default pager, do the following: | |||
|
170 | ||||
|
171 | 1. Set the environment PAGER variable to less. | |||
|
172 | 2. Set the environment LESS variable to -r (plus any other options | |||
|
173 | you always want to pass to less by default). This tells less to | |||
|
174 | properly interpret control sequences, which is how color | |||
|
175 | information is given to your terminal. | |||
|
176 | ||||
|
177 | For the csh or tcsh shells, add to your ~/.cshrc file the lines:: | |||
|
178 | ||||
|
179 | setenv PAGER less | |||
|
180 | setenv LESS -r | |||
|
181 | ||||
|
182 | There is similar syntax for other Unix shells, look at your system | |||
|
183 | documentation for details. | |||
|
184 | ||||
|
185 | If you are on a system which lacks proper data pagers (such as Windows), | |||
|
186 | IPython will use a very limited builtin pager. | |||
|
187 | ||||
|
188 | .. _emacs: | |||
|
189 | ||||
|
190 | (X)Emacs configuration | |||
|
191 | ====================== | |||
|
192 | ||||
|
193 | Thanks to the work of Alexander Schmolck and Prabhu Ramachandran, | |||
|
194 | currently (X)Emacs and IPython get along very well. | |||
|
195 | ||||
|
196 | Important note: You will need to use a recent enough version of | |||
|
197 | python-mode.el, along with the file ipython.el. You can check that the | |||
|
198 | version you have of python-mode.el is new enough by either looking at | |||
|
199 | the revision number in the file itself, or asking for it in (X)Emacs via | |||
|
200 | M-x py-version. Versions 4.68 and newer contain the necessary fixes for | |||
|
201 | proper IPython support. | |||
|
202 | ||||
|
203 | The file ipython.el is included with the IPython distribution, in the | |||
|
204 | documentation directory (where this manual resides in PDF and HTML | |||
|
205 | formats). | |||
|
206 | ||||
|
207 | Once you put these files in your Emacs path, all you need in your .emacs | |||
|
208 | file is:: | |||
|
209 | ||||
|
210 | (require 'ipython) | |||
|
211 | ||||
|
212 | This should give you full support for executing code snippets via | |||
|
213 | IPython, opening IPython as your Python shell via C-c !, etc. | |||
|
214 | ||||
|
215 | If you happen to get garbage instead of colored prompts as described in | |||
|
216 | the previous section, you may need to set also in your .emacs file:: | |||
|
217 | ||||
|
218 | (setq ansi-color-for-comint-mode t) | |||
|
219 | ||||
|
220 | ||||
|
221 | Notes: | |||
|
222 | ||||
|
223 | * There is one caveat you should be aware of: you must start the | |||
|
224 | IPython shell before attempting to execute any code regions via | |||
|
225 | ``C-c |``. Simply type C-c ! to start IPython before passing any code | |||
|
226 | regions to the interpreter, and you shouldn't experience any | |||
|
227 | problems. | |||
|
228 | This is due to a bug in Python itself, which has been fixed for | |||
|
229 | Python 2.3, but exists as of Python 2.2.2 (reported as SF bug [ | |||
|
230 | 737947 ]). | |||
|
231 | * The (X)Emacs support is maintained by Alexander Schmolck, so all | |||
|
232 | comments/requests should be directed to him through the IPython | |||
|
233 | mailing lists. | |||
|
234 | * This code is still somewhat experimental so it's a bit rough | |||
|
235 | around the edges (although in practice, it works quite well). | |||
|
236 | * Be aware that if you customize py-python-command previously, this | |||
|
237 | value will override what ipython.el does (because loading the | |||
|
238 | customization variables comes later). No newline at end of file |
@@ -0,0 +1,27 | |||||
|
1 | ======================== | |||
|
2 | New configuration system | |||
|
3 | ======================== | |||
|
4 | ||||
|
5 | IPython has a configuration system. When running IPython for the first time, | |||
|
6 | reasonable defaults are used for the configuration. The configuration of IPython | |||
|
7 | can be changed in two ways: | |||
|
8 | ||||
|
9 | * Configuration files | |||
|
10 | * Commands line options (which override the configuration files) | |||
|
11 | ||||
|
12 | IPython has a separate configuration file for each subpackage. Thus, the main | |||
|
13 | configuration files are (in your ``~/.ipython`` directory): | |||
|
14 | ||||
|
15 | * ``ipython1.core.ini`` | |||
|
16 | * ``ipython1.kernel.ini`` | |||
|
17 | * ``ipython1.notebook.ini`` | |||
|
18 | ||||
|
19 | To create these files for the first time, do the following:: | |||
|
20 | ||||
|
21 | from ipython1.kernel.config import config_manager as kernel_config | |||
|
22 | kernel_config.write_default_config_file() | |||
|
23 | ||||
|
24 | But, you should only need to do this if you need to modify the defaults. If needed | |||
|
25 | repeat this process with the ``notebook`` and ``core`` configuration as well. If you | |||
|
26 | are running into problems with IPython, you might try deleting these configuration | |||
|
27 | files. No newline at end of file |
@@ -0,0 +1,139 | |||||
|
1 | .. _credits: | |||
|
2 | ||||
|
3 | ======= | |||
|
4 | Credits | |||
|
5 | ======= | |||
|
6 | ||||
|
7 | IPython is mainly developed by Fernando Pérez | |||
|
8 | <Fernando.Perez@colorado.edu>, but the project was born from mixing in | |||
|
9 | Fernando's code with the IPP project by Janko Hauser | |||
|
10 | <jhauser-AT-zscout.de> and LazyPython by Nathan Gray | |||
|
11 | <n8gray-AT-caltech.edu>. For all IPython-related requests, please | |||
|
12 | contact Fernando. | |||
|
13 | ||||
|
14 | As of early 2006, the following developers have joined the core team: | |||
|
15 | ||||
|
16 | * [Robert Kern] <rkern-AT-enthought.com>: co-mentored the 2005 | |||
|
17 | Google Summer of Code project to develop python interactive | |||
|
18 | notebooks (XML documents) and graphical interface. This project | |||
|
19 | was awarded to the students Tzanko Matev <tsanko-AT-gmail.com> and | |||
|
20 | Toni Alatalo <antont-AT-an.org> | |||
|
21 | * [Brian Granger] <bgranger-AT-scu.edu>: extending IPython to allow | |||
|
22 | support for interactive parallel computing. | |||
|
23 | * [Ville Vainio] <vivainio-AT-gmail.com>: Ville is the new | |||
|
24 | maintainer for the main trunk of IPython after version 0.7.1. | |||
|
25 | ||||
|
26 | The IPython project is also very grateful to: | |||
|
27 | ||||
|
28 | Bill Bumgarner <bbum-AT-friday.com>: for providing the DPyGetOpt module | |||
|
29 | which gives very powerful and convenient handling of command-line | |||
|
30 | options (light years ahead of what Python 2.1.1's getopt module does). | |||
|
31 | ||||
|
32 | Ka-Ping Yee <ping-AT-lfw.org>: for providing the Itpl module for | |||
|
33 | convenient and powerful string interpolation with a much nicer syntax | |||
|
34 | than formatting through the '%' operator. | |||
|
35 | ||||
|
36 | Arnd Baecker <baecker-AT-physik.tu-dresden.de>: for his many very useful | |||
|
37 | suggestions and comments, and lots of help with testing and | |||
|
38 | documentation checking. Many of IPython's newer features are a result of | |||
|
39 | discussions with him (bugs are still my fault, not his). | |||
|
40 | ||||
|
41 | Obviously Guido van Rossum and the whole Python development team, that | |||
|
42 | goes without saying. | |||
|
43 | ||||
|
44 | IPython's website is generously hosted at http://ipython.scipy.orgby | |||
|
45 | Enthought (http://www.enthought.com). I am very grateful to them and all | |||
|
46 | of the SciPy team for their contribution. | |||
|
47 | ||||
|
48 | Fernando would also like to thank Stephen Figgins <fig-AT-monitor.net>, | |||
|
49 | an O'Reilly Python editor. His Oct/11/2001 article about IPP and | |||
|
50 | LazyPython, was what got this project started. You can read it at: | |||
|
51 | http://www.onlamp.com/pub/a/python/2001/10/11/pythonnews.html. | |||
|
52 | ||||
|
53 | And last but not least, all the kind IPython users who have emailed new | |||
|
54 | code, bug reports, fixes, comments and ideas. A brief list follows, | |||
|
55 | please let me know if I have ommitted your name by accident: | |||
|
56 | ||||
|
57 | * [Jack Moffit] <jack-AT-xiph.org> Bug fixes, including the infamous | |||
|
58 | color problem. This bug alone caused many lost hours and | |||
|
59 | frustration, many thanks to him for the fix. I've always been a | |||
|
60 | fan of Ogg & friends, now I have one more reason to like these folks. | |||
|
61 | Jack is also contributing with Debian packaging and many other | |||
|
62 | things. | |||
|
63 | * [Alexander Schmolck] <a.schmolck-AT-gmx.net> Emacs work, bug | |||
|
64 | reports, bug fixes, ideas, lots more. The ipython.el mode for | |||
|
65 | (X)Emacs is Alex's code, providing full support for IPython under | |||
|
66 | (X)Emacs. | |||
|
67 | * [Andrea Riciputi] <andrea.riciputi-AT-libero.it> Mac OSX | |||
|
68 | information, Fink package management. | |||
|
69 | * [Gary Bishop] <gb-AT-cs.unc.edu> Bug reports, and patches to work | |||
|
70 | around the exception handling idiosyncracies of WxPython. Readline | |||
|
71 | and color support for Windows. | |||
|
72 | * [Jeffrey Collins] <Jeff.Collins-AT-vexcel.com> Bug reports. Much | |||
|
73 | improved readline support, including fixes for Python 2.3. | |||
|
74 | * [Dryice Liu] <dryice-AT-liu.com.cn> FreeBSD port. | |||
|
75 | * [Mike Heeter] <korora-AT-SDF.LONESTAR.ORG> | |||
|
76 | * [Christopher Hart] <hart-AT-caltech.edu> PDB integration. | |||
|
77 | * [Milan Zamazal] <pdm-AT-zamazal.org> Emacs info. | |||
|
78 | * [Philip Hisley] <compsys-AT-starpower.net> | |||
|
79 | * [Holger Krekel] <pyth-AT-devel.trillke.net> Tab completion, lots | |||
|
80 | more. | |||
|
81 | * [Robin Siebler] <robinsiebler-AT-starband.net> | |||
|
82 | * [Ralf Ahlbrink] <ralf_ahlbrink-AT-web.de> | |||
|
83 | * [Thorsten Kampe] <thorsten-AT-thorstenkampe.de> | |||
|
84 | * [Fredrik Kant] <fredrik.kant-AT-front.com> Windows setup. | |||
|
85 | * [Syver Enstad] <syver-en-AT-online.no> Windows setup. | |||
|
86 | * [Richard] <rxe-AT-renre-europe.com> Global embedding. | |||
|
87 | * [Hayden Callow] <h.callow-AT-elec.canterbury.ac.nz> Gnuplot.py 1.6 | |||
|
88 | compatibility. | |||
|
89 | * [Leonardo Santagada] <retype-AT-terra.com.br> Fixes for Windows | |||
|
90 | installation. | |||
|
91 | * [Christopher Armstrong] <radix-AT-twistedmatrix.com> Bugfixes. | |||
|
92 | * [Francois Pinard] <pinard-AT-iro.umontreal.ca> Code and | |||
|
93 | documentation fixes. | |||
|
94 | * [Cory Dodt] <cdodt-AT-fcoe.k12.ca.us> Bug reports and Windows | |||
|
95 | ideas. Patches for Windows installer. | |||
|
96 | * [Olivier Aubert] <oaubert-AT-bat710.univ-lyon1.fr> New magics. | |||
|
97 | * [King C. Shu] <kingshu-AT-myrealbox.com> Autoindent patch. | |||
|
98 | * [Chris Drexler] <chris-AT-ac-drexler.de> Readline packages for | |||
|
99 | Win32/CygWin. | |||
|
100 | * [Gustavo Cordova Avila] <gcordova-AT-sismex.com> EvalDict code for | |||
|
101 | nice, lightweight string interpolation. | |||
|
102 | * [Kasper Souren] <Kasper.Souren-AT-ircam.fr> Bug reports, ideas. | |||
|
103 | * [Gever Tulley] <gever-AT-helium.com> Code contributions. | |||
|
104 | * [Ralf Schmitt] <ralf-AT-brainbot.com> Bug reports & fixes. | |||
|
105 | * [Oliver Sander] <osander-AT-gmx.de> Bug reports. | |||
|
106 | * [Rod Holland] <rhh-AT-structurelabs.com> Bug reports and fixes to | |||
|
107 | logging module. | |||
|
108 | * [Daniel 'Dang' Griffith] <pythondev-dang-AT-lazytwinacres.net> | |||
|
109 | Fixes, enhancement suggestions for system shell use. | |||
|
110 | * [Viktor Ransmayr] <viktor.ransmayr-AT-t-online.de> Tests and | |||
|
111 | reports on Windows installation issues. Contributed a true Windows | |||
|
112 | binary installer. | |||
|
113 | * [Mike Salib] <msalib-AT-mit.edu> Help fixing a subtle bug related | |||
|
114 | to traceback printing. | |||
|
115 | * [W.J. van der Laan] <gnufnork-AT-hetdigitalegat.nl> Bash-like | |||
|
116 | prompt specials. | |||
|
117 | * [Antoon Pardon] <Antoon.Pardon-AT-rece.vub.ac.be> Critical fix for | |||
|
118 | the multithreaded IPython. | |||
|
119 | * [John Hunter] <jdhunter-AT-nitace.bsd.uchicago.edu> Matplotlib | |||
|
120 | author, helped with all the development of support for matplotlib | |||
|
121 | in IPyhton, including making necessary changes to matplotlib itself. | |||
|
122 | * [Matthew Arnison] <maffew-AT-cat.org.au> Bug reports, '%run -d' idea. | |||
|
123 | * [Prabhu Ramachandran] <prabhu_r-AT-users.sourceforge.net> Help | |||
|
124 | with (X)Emacs support, threading patches, ideas... | |||
|
125 | * [Norbert Tretkowski] <tretkowski-AT-inittab.de> help with Debian | |||
|
126 | packaging and distribution. | |||
|
127 | * [George Sakkis] <gsakkis-AT-eden.rutgers.edu> New matcher for | |||
|
128 | tab-completing named arguments of user-defined functions. | |||
|
129 | * [Jörgen Stenarson] <jorgen.stenarson-AT-bostream.nu> Wildcard | |||
|
130 | support implementation for searching namespaces. | |||
|
131 | * [Vivian De Smedt] <vivian-AT-vdesmedt.com> Debugger enhancements, | |||
|
132 | so that when pdb is activated from within IPython, coloring, tab | |||
|
133 | completion and other features continue to work seamlessly. | |||
|
134 | * [Scott Tsai] <scottt958-AT-yahoo.com.tw> Support for automatic | |||
|
135 | editor invocation on syntax errors (see | |||
|
136 | http://www.scipy.net/roundup/ipython/issue36). | |||
|
137 | * [Alexander Belchenko] <bialix-AT-ukr.net> Improvements for win32 | |||
|
138 | paging system. | |||
|
139 | * [Will Maier] <willmaier-AT-ml1.net> Official OpenBSD port. No newline at end of file |
@@ -0,0 +1,315 | |||||
|
1 | .. _development: | |||
|
2 | ||||
|
3 | ================================== | |||
|
4 | IPython development guidelines | |||
|
5 | ================================== | |||
|
6 | ||||
|
7 | .. contents:: | |||
|
8 | .. | |||
|
9 | 1 Overview | |||
|
10 | 2 Project organization | |||
|
11 | 2.1 Subpackages | |||
|
12 | 2.2 Installation and dependencies | |||
|
13 | 2.3 Specific subpackages | |||
|
14 | 3 Version control | |||
|
15 | 4 Documentation | |||
|
16 | 4.1 Standalone documentation | |||
|
17 | 4.2 Docstring format | |||
|
18 | 5 Coding conventions | |||
|
19 | 5.1 General | |||
|
20 | 5.2 Naming conventions | |||
|
21 | 6 Testing | |||
|
22 | 7 Configuration | |||
|
23 | .. | |||
|
24 | ||||
|
25 | ||||
|
26 | Overview | |||
|
27 | ======== | |||
|
28 | ||||
|
29 | IPython is the next generation of IPython. It is named such for two reasons: | |||
|
30 | ||||
|
31 | - Eventually, IPython will become IPython version 1.0. | |||
|
32 | - This new code base needs to be able to co-exist with the existing IPython until | |||
|
33 | it is a full replacement for it. Thus we needed a different name. We couldn't | |||
|
34 | use ``ipython`` (lowercase) as some files systems are case insensitive. | |||
|
35 | ||||
|
36 | There are two, no three, main goals of the IPython effort: | |||
|
37 | ||||
|
38 | 1. Clean up the existing codebase and write lots of tests. | |||
|
39 | 2. Separate the core functionality of IPython from the terminal to enable IPython | |||
|
40 | to be used from within a variety of GUI applications. | |||
|
41 | 3. Implement a system for interactive parallel computing. | |||
|
42 | ||||
|
43 | While the third goal may seem a bit unrelated to the main focus of IPython, it turns | |||
|
44 | out that the technologies required for this goal are nearly identical with those | |||
|
45 | required for goal two. This is the main reason the interactive parallel computing | |||
|
46 | capabilities are being put into IPython proper. Currently the third of these goals is | |||
|
47 | furthest along. | |||
|
48 | ||||
|
49 | This document describes IPython from the perspective of developers. | |||
|
50 | ||||
|
51 | ||||
|
52 | Project organization | |||
|
53 | ==================== | |||
|
54 | ||||
|
55 | Subpackages | |||
|
56 | ----------- | |||
|
57 | ||||
|
58 | IPython is organized into semi self-contained subpackages. Each of the subpackages will have its own: | |||
|
59 | ||||
|
60 | - **Dependencies**. One of the most important things to keep in mind in | |||
|
61 | partitioning code amongst subpackages, is that they should be used to cleanly | |||
|
62 | encapsulate dependencies. | |||
|
63 | - **Tests**. Each subpackage shoud have its own ``tests`` subdirectory that | |||
|
64 | contains all of the tests for that package. For information about writing tests | |||
|
65 | for IPython, see the `Testing System`_ section of this document. | |||
|
66 | - **Configuration**. Each subpackage should have its own ``config`` subdirectory | |||
|
67 | that contains the configuration information for the components of the | |||
|
68 | subpackage. For information about how the IPython configuration system | |||
|
69 | works, see the `Configuration System`_ section of this document. | |||
|
70 | - **Scripts**. Each subpackage should have its own ``scripts`` subdirectory that | |||
|
71 | contains all of the command line scripts associated with the subpackage. | |||
|
72 | ||||
|
73 | Installation and dependencies | |||
|
74 | ----------------------------- | |||
|
75 | ||||
|
76 | IPython will not use `setuptools`_ for installation. Instead, we will use standard | |||
|
77 | ``setup.py`` scripts that use `distutils`_. While there are a number a extremely nice | |||
|
78 | features that `setuptools`_ has (like namespace packages), the current implementation | |||
|
79 | of `setuptools`_ has performance problems, particularly on shared file systems. In | |||
|
80 | particular, when Python packages are installed on NSF file systems, import times | |||
|
81 | become much too long (up towards 10 seconds). | |||
|
82 | ||||
|
83 | Because IPython is being used extensively in the context of high performance | |||
|
84 | computing, where performance is critical but shared file systems are common, we feel | |||
|
85 | these performance hits are not acceptable. Thus, until the performance problems | |||
|
86 | associated with `setuptools`_ are addressed, we will stick with plain `distutils`_. We | |||
|
87 | are hopeful that these problems will be addressed and that we will eventually begin | |||
|
88 | using `setuptools`_. Because of this, we are trying to organize IPython in a way that | |||
|
89 | will make the eventual transition to `setuptools`_ as painless as possible. | |||
|
90 | ||||
|
91 | 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: | |||
|
92 | ||||
|
93 | - Distinguish between required and optional dependencies. However, the required | |||
|
94 | dependencies for IPython should be only the Python standard library. | |||
|
95 | - Upon installation check to see which optional dependencies are present and tell | |||
|
96 | the user which parts of IPython need which optional dependencies. | |||
|
97 | ||||
|
98 | It is absolutely critical that each subpackage of IPython has a clearly specified set | |||
|
99 | of dependencies and that dependencies are not carelessly inherited from other IPython | |||
|
100 | subpackages. Furthermore, tests that have certain dependencies should not fail if | |||
|
101 | those dependencies are not present. Instead they should be skipped and print a | |||
|
102 | message. | |||
|
103 | ||||
|
104 | .. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools | |||
|
105 | .. _distutils: http://docs.python.org/lib/module-distutils.html | |||
|
106 | .. _Matplotlib: http://matplotlib.sourceforge.net/ | |||
|
107 | ||||
|
108 | Specific subpackages | |||
|
109 | -------------------- | |||
|
110 | ||||
|
111 | ``core`` | |||
|
112 | This is the core functionality of IPython that is independent of the | |||
|
113 | terminal, network and GUIs. Most of the code that is in the current | |||
|
114 | IPython trunk will be refactored, cleaned up and moved here. | |||
|
115 | ||||
|
116 | ``kernel`` | |||
|
117 | The enables the IPython core to be expose to a the network. This is | |||
|
118 | also where all of the parallel computing capabilities are to be found. | |||
|
119 | ||||
|
120 | ``config`` | |||
|
121 | The configuration package used by IPython. | |||
|
122 | ||||
|
123 | ``frontends`` | |||
|
124 | The various frontends for IPython. A frontend is the end-user application | |||
|
125 | that exposes the capabilities of IPython to the user. The most basic frontend | |||
|
126 | will simply be a terminal based application that looks just like today 's | |||
|
127 | IPython. Other frontends will likely be more powerful and based on GUI toolkits. | |||
|
128 | ||||
|
129 | ``notebook`` | |||
|
130 | An application that allows users to work with IPython notebooks. | |||
|
131 | ||||
|
132 | ``tools`` | |||
|
133 | This is where general utilities go. | |||
|
134 | ||||
|
135 | ||||
|
136 | Version control | |||
|
137 | =============== | |||
|
138 | ||||
|
139 | In the past, IPython development has been done using `Subversion`__. We are currently trying out `Bazaar`__ and `Launchpad`__. | |||
|
140 | ||||
|
141 | .. __: http://subversion.tigris.org/ | |||
|
142 | .. __: http://bazaar-vcs.org/ | |||
|
143 | .. __: http://www.launchpad.net/ipython | |||
|
144 | ||||
|
145 | Documentation | |||
|
146 | ============= | |||
|
147 | ||||
|
148 | Standalone documentation | |||
|
149 | ------------------------ | |||
|
150 | ||||
|
151 | All standalone documentation should be written in plain text (``.txt``) files using | |||
|
152 | `reStructuredText`_ for markup and formatting. All such documentation should be placed | |||
|
153 | in the top level directory ``docs`` of the IPython source tree. Or, when appropriate, | |||
|
154 | a suitably named subdirectory should be used. The documentation in this location will | |||
|
155 | serve as the main source for IPython documentation and all existing documentation | |||
|
156 | should be converted to this format. | |||
|
157 | ||||
|
158 | In the future, the text files in the ``docs`` directory will be used to generate all | |||
|
159 | forms of documentation for IPython. This include documentation on the IPython website | |||
|
160 | as well as *pdf* documentation. | |||
|
161 | ||||
|
162 | .. _reStructuredText: http://docutils.sourceforge.net/rst.html | |||
|
163 | ||||
|
164 | Docstring format | |||
|
165 | ---------------- | |||
|
166 | ||||
|
167 | Good docstrings are very important. All new code will use `Epydoc`_ for generating API | |||
|
168 | docs, so we will follow the `Epydoc`_ conventions. More specifically, we will use | |||
|
169 | `reStructuredText`_ for markup and formatting, since it is understood by a wide | |||
|
170 | variety of tools. This means that if in the future we have any reason to change from | |||
|
171 | `Epydoc`_ to something else, we'll have fewer transition pains. | |||
|
172 | ||||
|
173 | Details about using `reStructuredText`_ for docstrings can be found `here | |||
|
174 | <http://epydoc.sourceforge.net/manual-othermarkup.html>`_. | |||
|
175 | ||||
|
176 | .. _Epydoc: http://epydoc.sourceforge.net/ | |||
|
177 | ||||
|
178 | Additional PEPs of interest regarding documentation of code: | |||
|
179 | ||||
|
180 | - `Docstring Conventions <http://www.python.org/peps/pep-0257.html>`_ | |||
|
181 | - `Docstring Processing System Framework <http://www.python.org/peps/pep-0256.html>`_ | |||
|
182 | - `Docutils Design Specification <http://www.python.org/peps/pep-0258.html>`_ | |||
|
183 | ||||
|
184 | ||||
|
185 | Coding conventions | |||
|
186 | ================== | |||
|
187 | ||||
|
188 | General | |||
|
189 | ------- | |||
|
190 | ||||
|
191 | In general, we'll try to follow the standard Python style conventions as described here: | |||
|
192 | ||||
|
193 | - `Style Guide for Python Code <http://www.python.org/peps/pep-0008.html>`_ | |||
|
194 | ||||
|
195 | ||||
|
196 | Other comments: | |||
|
197 | ||||
|
198 | - In a large file, top level classes and functions should be | |||
|
199 | separated by 2-3 lines to make it easier to separate them visually. | |||
|
200 | - Use 4 spaces for indentation. | |||
|
201 | - Keep the ordering of methods the same in classes that have the same | |||
|
202 | methods. This is particularly true for classes that implement | |||
|
203 | similar interfaces and for interfaces that are similar. | |||
|
204 | ||||
|
205 | Naming conventions | |||
|
206 | ------------------ | |||
|
207 | ||||
|
208 | In terms of naming conventions, we'll follow the guidelines from the `Style Guide for | |||
|
209 | Python Code`_. | |||
|
210 | ||||
|
211 | For all new IPython code (and much existing code is being refactored), we'll use: | |||
|
212 | ||||
|
213 | - All ``lowercase`` module names. | |||
|
214 | ||||
|
215 | - ``CamelCase`` for class names. | |||
|
216 | ||||
|
217 | - ``lowercase_with_underscores`` for methods, functions, variables and attributes. | |||
|
218 | ||||
|
219 | 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 | |||
|
220 | convention, providing shadow names for backward compatibility in public interfaces. | |||
|
221 | ||||
|
222 | There are, however, some important exceptions to these rules. In some cases, IPython | |||
|
223 | 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: | |||
|
224 | ||||
|
225 | - If you are subclassing a class that uses different conventions, use its | |||
|
226 | naming conventions throughout your subclass. Thus, if you are creating a | |||
|
227 | Twisted Protocol class, used Twisted's ``namingSchemeForMethodsAndAttributes.`` | |||
|
228 | ||||
|
229 | - All IPython's official interfaces should use our conventions. In some cases | |||
|
230 | this will mean that you need to provide shadow names (first implement ``fooBar`` | |||
|
231 | and then ``foo_bar = fooBar``). We want to avoid this at all costs, but it | |||
|
232 | will probably be necessary at times. But, please use this sparingly! | |||
|
233 | ||||
|
234 | Implementation-specific *private* methods will use ``_single_underscore_prefix``. | |||
|
235 | Names with a leading double underscore will *only* be used in special cases, as they | |||
|
236 | makes subclassing difficult (such names are not easily seen by child classes). | |||
|
237 | ||||
|
238 | Occasionally some run-in lowercase names are used, but mostly for very short names or | |||
|
239 | where we are implementing methods very similar to existing ones in a base class (like | |||
|
240 | ``runlines()`` where ``runsource()`` and ``runcode()`` had established precedent). | |||
|
241 | ||||
|
242 | The old IPython codebase has a big mix of classes and modules prefixed with an | |||
|
243 | explicit ``IP``. In Python this is mostly unnecessary, redundant and frowned upon, as | |||
|
244 | namespaces offer cleaner prefixing. The only case where this approach is justified is | |||
|
245 | for classes which are expected to be imported into external namespaces and a very | |||
|
246 | generic name (like Shell) is too likely to clash with something else. We'll need to | |||
|
247 | revisit this issue as we clean up and refactor the code, but in general we should | |||
|
248 | remove as many unnecessary ``IP``/``ip`` prefixes as possible. However, if a prefix | |||
|
249 | seems absolutely necessary the more specific ``IPY`` or ``ipy`` are preferred. | |||
|
250 | ||||
|
251 | .. _devel_testing: | |||
|
252 | ||||
|
253 | Testing system | |||
|
254 | ============== | |||
|
255 | ||||
|
256 | It is extremely important that all code contributed to IPython has tests. Tests should | |||
|
257 | be written as unittests, doctests or as entities that the `Nose`_ testing package will | |||
|
258 | find. Regardless of how the tests are written, we will use `Nose`_ for discovering and | |||
|
259 | running the tests. `Nose`_ will be required to run the IPython test suite, but will | |||
|
260 | not be required to simply use IPython. | |||
|
261 | ||||
|
262 | .. _Nose: http://code.google.com/p/python-nose/ | |||
|
263 | ||||
|
264 | Tests of `Twisted`__ using code should be written by subclassing the ``TestCase`` class | |||
|
265 | that comes with ``twisted.trial.unittest``. When this is done, `Nose`_ will be able to | |||
|
266 | run the tests and the twisted reactor will be handled correctly. | |||
|
267 | ||||
|
268 | .. __: http://www.twistedmatrix.com | |||
|
269 | ||||
|
270 | Each subpackage in IPython should have its own ``tests`` directory that contains all | |||
|
271 | of the tests for that subpackage. This allows each subpackage to be self-contained. If | |||
|
272 | a subpackage has any dependencies beyond the Python standard library, the tests for | |||
|
273 | that subpackage should be skipped if the dependencies are not found. This is very | |||
|
274 | important so users don't get tests failing simply because they don't have dependencies. | |||
|
275 | ||||
|
276 | We also need to look into use Noses ability to tag tests to allow a more modular | |||
|
277 | approach of running tests. | |||
|
278 | ||||
|
279 | .. _devel_config: | |||
|
280 | ||||
|
281 | Configuration system | |||
|
282 | ==================== | |||
|
283 | ||||
|
284 | IPython uses `.ini`_ files for configuration purposes. This represents a huge | |||
|
285 | improvement over the configuration system used in IPython. IPython works with these | |||
|
286 | files using the `ConfigObj`_ package, which IPython includes as | |||
|
287 | ``ipython1/external/configobj.py``. | |||
|
288 | ||||
|
289 | Currently, we are using raw `ConfigObj`_ objects themselves. Each subpackage of IPython | |||
|
290 | should contain a ``config`` subdirectory that contains all of the configuration | |||
|
291 | information for the subpackage. To see how configuration information is defined (along | |||
|
292 | with defaults) see at the examples in ``ipython1/kernel/config`` and | |||
|
293 | ``ipython1/core/config``. Likewise, to see how the configuration information is used, | |||
|
294 | see examples in ``ipython1/kernel/scripts/ipengine.py``. | |||
|
295 | ||||
|
296 | Eventually, we will add a new layer on top of the raw `ConfigObj`_ objects. We are | |||
|
297 | calling this new layer, ``tconfig``, as it will use a `Traits`_-like validation model. | |||
|
298 | We won't actually use `Traits`_, but will implement something similar in pure Python. | |||
|
299 | But, even in this new system, we will still use `ConfigObj`_ and `.ini`_ files | |||
|
300 | underneath the hood. Talk to Fernando if you are interested in working on this part of | |||
|
301 | IPython. The current prototype of ``tconfig`` is located in the IPython sandbox. | |||
|
302 | ||||
|
303 | .. _.ini: http://docs.python.org/lib/module-ConfigParser.html | |||
|
304 | .. _ConfigObj: http://www.voidspace.org.uk/python/configobj.html | |||
|
305 | .. _Traits: http://code.enthought.com/traits/ | |||
|
306 | ||||
|
307 | ||||
|
308 | ||||
|
309 | ||||
|
310 | ||||
|
311 | ||||
|
312 | ||||
|
313 | ||||
|
314 | ||||
|
315 |
@@ -0,0 +1,9 | |||||
|
1 | ================== | |||
|
2 | Development | |||
|
3 | ================== | |||
|
4 | ||||
|
5 | .. toctree:: | |||
|
6 | :maxdepth: 2 | |||
|
7 | ||||
|
8 | development.txt | |||
|
9 | roadmap.txt |
@@ -0,0 +1,96 | |||||
|
1 | .. _roadmap: | |||
|
2 | ||||
|
3 | =================== | |||
|
4 | Development roadmap | |||
|
5 | =================== | |||
|
6 | ||||
|
7 | .. contents:: | |||
|
8 | ||||
|
9 | IPython is an ambitious project that is still under heavy development. However, we want IPython to become useful to as many people as possible, as quickly as possible. To help us accomplish this, we are laying out a roadmap of where we are headed and what needs to happen to get there. Hopefully, this will help the IPython developers figure out the best things to work on for each upcoming release. | |||
|
10 | ||||
|
11 | Speaking of releases, we are going to begin releasing a new version of IPython every four weeks. We are hoping that a regular release schedule, along with a clear roadmap of where we are headed will propel the project forward. | |||
|
12 | ||||
|
13 | Where are we headed | |||
|
14 | =================== | |||
|
15 | ||||
|
16 | Our goal with IPython is simple: to provide a *powerful*, *robust* and *easy to use* framework for parallel computing. While there are other secondary goals you will hear us talking about at various times, this is the primary goal of IPython that frames the roadmap. | |||
|
17 | ||||
|
18 | Steps along the way | |||
|
19 | =================== | |||
|
20 | ||||
|
21 | Here we describe the various things that we need to work on to accomplish this goal. | |||
|
22 | ||||
|
23 | Setting up for regular release schedule | |||
|
24 | --------------------------------------- | |||
|
25 | ||||
|
26 | We would like to begin to release IPython regularly (probably a 4 week release cycle). To get ready for this, we need to revisit the development guidelines and put in information about releasing IPython. | |||
|
27 | ||||
|
28 | Process startup and management | |||
|
29 | ------------------------------ | |||
|
30 | ||||
|
31 | IPython is implemented using a distributed set of processes that communicate using TCP/IP network channels. Currently, users have to start each of the various processes separately using command line scripts. This is both difficult and error prone. Furthermore, there are a number of things that often need to be managed once the processes have been started, such as the sending of signals and the shutting down and cleaning up of processes. | |||
|
32 | ||||
|
33 | We need to build a system that makes it trivial for users to start and manage IPython processes. This system should have the following properties: | |||
|
34 | ||||
|
35 | * It should possible to do everything through an extremely simple API that users | |||
|
36 | can call from their own Python script. No shell commands should be needed. | |||
|
37 | * This simple API should be configured using standard .ini files. | |||
|
38 | * The system should make it possible to start processes using a number of different | |||
|
39 | approaches: SSH, PBS/Torque, Xgrid, Windows Server, mpirun, etc. | |||
|
40 | * The controller and engine processes should each have a daemon for monitoring, | |||
|
41 | signaling and clean up. | |||
|
42 | * The system should be secure. | |||
|
43 | * The system should work under all the major operating systems, including | |||
|
44 | Windows. | |||
|
45 | ||||
|
46 | Initial work has begun on the daemon infrastructure, and some of the needed logic is contained in the ipcluster script. | |||
|
47 | ||||
|
48 | Ease of use/high-level approaches to parallelism | |||
|
49 | ------------------------------------------------ | |||
|
50 | ||||
|
51 | While our current API for clients is well designed, we can still do a lot better in designing a user-facing API that is super simple. The main goal here is that it should take *almost no extra code* for users to get their code running in parallel. For this to be possible, we need to tie into Python's standard idioms that enable efficient coding. The biggest ones we are looking at are using context managers (i.e., Python 2.5's ``with`` statement) and decorators. Initial work on this front has begun, but more work is needed. | |||
|
52 | ||||
|
53 | We also need to think about new models for expressing parallelism. This is fun work as most of the foundation has already been established. | |||
|
54 | ||||
|
55 | Security | |||
|
56 | -------- | |||
|
57 | ||||
|
58 | Currently, IPython has no built in security or security model. Because we would like IPython to be usable on public computer systems and over wide area networks, we need to come up with a robust solution for security. Here are some of the specific things that need to be included: | |||
|
59 | ||||
|
60 | * User authentication between all processes (engines, controller and clients). | |||
|
61 | * Optional TSL/SSL based encryption of all communication channels. | |||
|
62 | * A good way of picking network ports so multiple users on the same system can | |||
|
63 | run their own controller and engines without interfering with those of others. | |||
|
64 | * A clear model for security that enables users to evaluate the security risks | |||
|
65 | associated with using IPython in various manners. | |||
|
66 | ||||
|
67 | For the implementation of this, we plan on using Twisted's support for SSL and authentication. One things that we really should look at is the `Foolscap`_ network protocol, which provides many of these things out of the box. | |||
|
68 | ||||
|
69 | .. _Foolscap: http://foolscap.lothar.com/trac | |||
|
70 | ||||
|
71 | The security work needs to be done in conjunction with other network protocol stuff. | |||
|
72 | ||||
|
73 | Latent performance issues | |||
|
74 | ------------------------- | |||
|
75 | ||||
|
76 | Currently, we have a number of performance issues that are waiting to bite users: | |||
|
77 | ||||
|
78 | * The controller store a large amount of state in Python dictionaries. Under heavy | |||
|
79 | usage, these dicts with get very large, causing memory usage problems. We need to | |||
|
80 | develop more scalable solutions to this problem, such as using a sqlite database | |||
|
81 | to store this state. This will also help the controller to be more fault tolerant. | |||
|
82 | * Currently, the client to controller connections are done through XML-RPC using | |||
|
83 | HTTP 1.0. This is very inefficient as XML-RPC is a very verbose protocol and | |||
|
84 | each request must be handled with a new connection. We need to move these network | |||
|
85 | connections over to PB or Foolscap. | |||
|
86 | * We currently don't have a good way of handling large objects in the controller. | |||
|
87 | The biggest problem is that because we don't have any way of streaming objects, | |||
|
88 | we get lots of temporary copies in the low-level buffers. We need to implement | |||
|
89 | a better serialization approach and true streaming support. | |||
|
90 | * The controller currently unpickles and repickles objects. We need to use the | |||
|
91 | [push|pull]_serialized methods instead. | |||
|
92 | * Currently the controller is a bottleneck. We need the ability to scale the | |||
|
93 | controller by aggregating multiple controllers into one effective controller. | |||
|
94 | ||||
|
95 | ||||
|
96 |
@@ -0,0 +1,93 | |||||
|
1 | .. _faq: | |||
|
2 | ||||
|
3 | ======================================== | |||
|
4 | Frequently asked questions | |||
|
5 | ======================================== | |||
|
6 | ||||
|
7 | General questions | |||
|
8 | ================= | |||
|
9 | ||||
|
10 | Questions about parallel computing with IPython | |||
|
11 | ================================================ | |||
|
12 | ||||
|
13 | Will IPython speed my Python code up? | |||
|
14 | -------------------------------------- | |||
|
15 | ||||
|
16 | Yes and no. When converting a serial code to run in parallel, there often many | |||
|
17 | difficulty questions that need to be answered, such as: | |||
|
18 | ||||
|
19 | * How should data be decomposed onto the set of processors? | |||
|
20 | * What are the data movement patterns? | |||
|
21 | * Can the algorithm be structured to minimize data movement? | |||
|
22 | * Is dynamic load balancing important? | |||
|
23 | ||||
|
24 | We can't answer such questions for you. This is the hard (but fun) work of parallel | |||
|
25 | computing. But, once you understand these things IPython will make it easier for you to | |||
|
26 | implement a good solution quickly. Most importantly, you will be able to use the | |||
|
27 | resulting parallel code interactively. | |||
|
28 | ||||
|
29 | With that said, if your problem is trivial to parallelize, IPython has a number of | |||
|
30 | different interfaces that will enable you to parallelize things is almost no time at | |||
|
31 | all. A good place to start is the ``map`` method of our `multiengine interface`_. | |||
|
32 | ||||
|
33 | .. _multiengine interface: ./parallel_multiengine | |||
|
34 | ||||
|
35 | What is the best way to use MPI from Python? | |||
|
36 | -------------------------------------------- | |||
|
37 | ||||
|
38 | What about all the other parallel computing packages in Python? | |||
|
39 | --------------------------------------------------------------- | |||
|
40 | ||||
|
41 | Some of the unique characteristic of IPython are: | |||
|
42 | ||||
|
43 | * IPython is the only architecture that abstracts out the notion of a | |||
|
44 | parallel computation in such a way that new models of parallel computing | |||
|
45 | can be explored quickly and easily. If you don't like the models we | |||
|
46 | provide, you can simply create your own using the capabilities we provide. | |||
|
47 | * IPython is asynchronous from the ground up (we use `Twisted`_). | |||
|
48 | * IPython's architecture is designed to avoid subtle problems | |||
|
49 | that emerge because of Python's global interpreter lock (GIL). | |||
|
50 | * While IPython'1 architecture is designed to support a wide range | |||
|
51 | of novel parallel computing models, it is fully interoperable with | |||
|
52 | traditional MPI applications. | |||
|
53 | * IPython has been used and tested extensively on modern supercomputers. | |||
|
54 | * IPython's networking layers are completely modular. Thus, is | |||
|
55 | straightforward to replace our existing network protocols with | |||
|
56 | high performance alternatives (ones based upon Myranet/Infiniband). | |||
|
57 | * IPython is designed from the ground up to support collaborative | |||
|
58 | parallel computing. This enables multiple users to actively develop | |||
|
59 | and run the *same* parallel computation. | |||
|
60 | * Interactivity is a central goal for us. While IPython does not have | |||
|
61 | to be used interactivly, is can be. | |||
|
62 | ||||
|
63 | .. _Twisted: http://www.twistedmatrix.com | |||
|
64 | ||||
|
65 | Why The IPython controller a bottleneck in my parallel calculation? | |||
|
66 | ------------------------------------------------------------------- | |||
|
67 | ||||
|
68 | A golden rule in parallel computing is that you should only move data around if you | |||
|
69 | absolutely need to. The main reason that the controller becomes a bottleneck is that | |||
|
70 | too much data is being pushed and pulled to and from the engines. If your algorithm | |||
|
71 | is structured in this way, you really should think about alternative ways of | |||
|
72 | handling the data movement. Here are some ideas: | |||
|
73 | ||||
|
74 | 1. Have the engines write data to files on the locals disks of the engines. | |||
|
75 | 2. Have the engines write data to files on a file system that is shared by | |||
|
76 | the engines. | |||
|
77 | 3. Have the engines write data to a database that is shared by the engines. | |||
|
78 | 4. Simply keep data in the persistent memory of the engines and move the | |||
|
79 | computation to the data (rather than the data to the computation). | |||
|
80 | 5. See if you can pass data directly between engines using MPI. | |||
|
81 | ||||
|
82 | Isn't Python slow to be used for high-performance parallel computing? | |||
|
83 | --------------------------------------------------------------------- | |||
|
84 | ||||
|
85 | ||||
|
86 | ||||
|
87 | ||||
|
88 | ||||
|
89 | ||||
|
90 | ||||
|
91 | ||||
|
92 | ||||
|
93 |
@@ -0,0 +1,56 | |||||
|
1 | .. _history: | |||
|
2 | ||||
|
3 | ======= | |||
|
4 | History | |||
|
5 | ======= | |||
|
6 | ||||
|
7 | Origins | |||
|
8 | ======= | |||
|
9 | ||||
|
10 | The current IPython system grew out of the following three projects: | |||
|
11 | ||||
|
12 | * [ipython] by Fernando Pérez. I was working on adding | |||
|
13 | Mathematica-type prompts and a flexible configuration system | |||
|
14 | (something better than $PYTHONSTARTUP) to the standard Python | |||
|
15 | interactive interpreter. | |||
|
16 | * [IPP] by Janko Hauser. Very well organized, great usability. Had | |||
|
17 | an old help system. IPP was used as the 'container' code into | |||
|
18 | which I added the functionality from ipython and LazyPython. | |||
|
19 | * [LazyPython] by Nathan Gray. Simple but very powerful. The quick | |||
|
20 | syntax (auto parens, auto quotes) and verbose/colored tracebacks | |||
|
21 | were all taken from here. | |||
|
22 | ||||
|
23 | When I found out about IPP and LazyPython I tried to join all three | |||
|
24 | into a unified system. I thought this could provide a very nice | |||
|
25 | working environment, both for regular programming and scientific | |||
|
26 | computing: shell-like features, IDL/Matlab numerics, Mathematica-type | |||
|
27 | prompt history and great object introspection and help facilities. I | |||
|
28 | think it worked reasonably well, though it was a lot more work than I | |||
|
29 | had initially planned. | |||
|
30 | ||||
|
31 | ||||
|
32 | Current status | |||
|
33 | ============== | |||
|
34 | ||||
|
35 | The above listed features work, and quite well for the most part. But | |||
|
36 | until a major internal restructuring is done (see below), only bug | |||
|
37 | fixing will be done, no other features will be added (unless very minor | |||
|
38 | and well localized in the cleaner parts of the code). | |||
|
39 | ||||
|
40 | IPython consists of some 18000 lines of pure python code, of which | |||
|
41 | roughly two thirds is reasonably clean. The rest is, messy code which | |||
|
42 | needs a massive restructuring before any further major work is done. | |||
|
43 | Even the messy code is fairly well documented though, and most of the | |||
|
44 | problems in the (non-existent) class design are well pointed to by a | |||
|
45 | PyChecker run. So the rewriting work isn't that bad, it will just be | |||
|
46 | time-consuming. | |||
|
47 | ||||
|
48 | ||||
|
49 | Future | |||
|
50 | ------ | |||
|
51 | ||||
|
52 | See the separate new_design document for details. Ultimately, I would | |||
|
53 | like to see IPython become part of the standard Python distribution as a | |||
|
54 | 'big brother with batteries' to the standard Python interactive | |||
|
55 | interpreter. But that will never happen with the current state of the | |||
|
56 | code, so all contributions are welcome. No newline at end of file |
@@ -0,0 +1,28 | |||||
|
1 | ===================== | |||
|
2 | IPython Documentation | |||
|
3 | ===================== | |||
|
4 | ||||
|
5 | Contents | |||
|
6 | ======== | |||
|
7 | ||||
|
8 | .. toctree:: | |||
|
9 | :maxdepth: 1 | |||
|
10 | ||||
|
11 | overview.txt | |||
|
12 | install/index.txt | |||
|
13 | interactive/index.txt | |||
|
14 | parallel/index.txt | |||
|
15 | config/index.txt | |||
|
16 | changes.txt | |||
|
17 | development/index.txt | |||
|
18 | faq.txt | |||
|
19 | history.txt | |||
|
20 | license_and_copyright.txt | |||
|
21 | credits.txt | |||
|
22 | ||||
|
23 | Indices and tables | |||
|
24 | ================== | |||
|
25 | ||||
|
26 | * :ref:`genindex` | |||
|
27 | * :ref:`modindex` | |||
|
28 | * :ref:`search` No newline at end of file |
@@ -0,0 +1,138 | |||||
|
1 | ========================================= | |||
|
2 | Advanced installation options for IPython | |||
|
3 | ========================================= | |||
|
4 | ||||
|
5 | .. contents:: | |||
|
6 | ||||
|
7 | Introduction | |||
|
8 | ============ | |||
|
9 | ||||
|
10 | IPython enables parallel applications to be developed in Python. This document | |||
|
11 | describes the steps required to install IPython. For an overview of IPython's | |||
|
12 | architecture as it relates to parallel computing, see our :ref:`introduction to | |||
|
13 | parallel computing with IPython <ip1par>`. | |||
|
14 | ||||
|
15 | Please let us know if you have problems installing IPython or any of its | |||
|
16 | dependencies. We have tested IPython extensively with Python 2.4 and 2.5. | |||
|
17 | ||||
|
18 | .. warning:: | |||
|
19 | ||||
|
20 | IPython will not work with Python 2.3 or below. | |||
|
21 | ||||
|
22 | IPython has three required dependencies: | |||
|
23 | ||||
|
24 | 1. `IPython`__ | |||
|
25 | 2. `Zope Interface`__ | |||
|
26 | 3. `Twisted`__ | |||
|
27 | 4. `Foolscap`__ | |||
|
28 | ||||
|
29 | .. __: http://ipython.scipy.org | |||
|
30 | .. __: http://pypi.python.org/pypi/zope.interface | |||
|
31 | .. __: http://twistedmatrix.com | |||
|
32 | .. __: http://foolscap.lothar.com/trac | |||
|
33 | ||||
|
34 | It also has the following optional dependencies: | |||
|
35 | ||||
|
36 | 1. pexpect (used for certain tests) | |||
|
37 | 2. nose (used to run our test suite) | |||
|
38 | 3. sqlalchemy (used for database support) | |||
|
39 | 4. mpi4py (for MPI support) | |||
|
40 | 5. Sphinx and pygments (for building documentation) | |||
|
41 | 6. pyOpenSSL (for security) | |||
|
42 | ||||
|
43 | Getting IPython | |||
|
44 | ================ | |||
|
45 | ||||
|
46 | IPython development has been moved to `Launchpad`_. The development branch of IPython can be checkout out using `Bazaar`_:: | |||
|
47 | ||||
|
48 | $ bzr branch lp:///~ipython/ipython/ipython1-dev | |||
|
49 | ||||
|
50 | .. _Launchpad: http://www.launchpad.net/ipython | |||
|
51 | .. _Bazaar: http://bazaar-vcs.org/ | |||
|
52 | ||||
|
53 | Installation using setuptools | |||
|
54 | ============================= | |||
|
55 | ||||
|
56 | The easiest way of installing IPython and its dependencies is using | |||
|
57 | `setuptools`_. If you have setuptools installed you can simple use the ``easy_install`` | |||
|
58 | script that comes with setuptools (this should be on your path if you have setuptools):: | |||
|
59 | ||||
|
60 | $ easy_install ipython1 | |||
|
61 | ||||
|
62 | This will download and install the latest version of IPython as well as all of its dependencies. For this to work, you will need to be connected to the internet when you run this command. This will install everything info the ``site-packages`` directory of your Python distribution. If this is the system wide Python, you will likely need admin privileges. For information about installing Python packages to other locations (that don't require admin privileges) see the `setuptools`_ documentation. | |||
|
63 | ||||
|
64 | .. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools | |||
|
65 | ||||
|
66 | If you don't want `setuptools`_ to automatically install the dependencies, you can also get the dependencies yourself, using ``easy_install``:: | |||
|
67 | ||||
|
68 | $ easy_install IPython | |||
|
69 | $ easy_install zope.interface | |||
|
70 | $ easy_install Twisted | |||
|
71 | $ easy_install foolscap | |||
|
72 | ||||
|
73 | or by simply downloading and installing the dependencies manually. | |||
|
74 | ||||
|
75 | If you want to have secure (highly recommended) network connections, you will also | |||
|
76 | need to get `pyOpenSSL`__, version 0.6, or just do: | |||
|
77 | ||||
|
78 | $ easy_install ipython1[security] | |||
|
79 | ||||
|
80 | .. hint:: If you want to do development on IPython and want to always | |||
|
81 | run off your development branch, you can run | |||
|
82 | :command:`python setupegg.py develop` in the IPython source tree. | |||
|
83 | ||||
|
84 | .. __: http://pyopenssl.sourceforge.net/ | |||
|
85 | ||||
|
86 | Installation using plain distutils | |||
|
87 | ================================== | |||
|
88 | ||||
|
89 | If you don't have `setuptools`_ installed or don't want to use it, you can also install IPython and its dependencies using ``distutils``. In this approach, you will need to get the most recent stable releases of IPython's dependencies and install each of them by doing:: | |||
|
90 | ||||
|
91 | $ python setup.py install | |||
|
92 | ||||
|
93 | The dependencies need to be installed before installing IPython. After installing the dependencies, install IPython by running:: | |||
|
94 | ||||
|
95 | $ cd ipython1-dev | |||
|
96 | $ python setup.py install | |||
|
97 | ||||
|
98 | .. note:: Here we are using setup.py rather than setupegg.py. | |||
|
99 | ||||
|
100 | .. _install_testing: | |||
|
101 | ||||
|
102 | Testing | |||
|
103 | ======= | |||
|
104 | ||||
|
105 | Once you have completed the installation of the IPython kernel you can run our test suite | |||
|
106 | with the command:: | |||
|
107 | ||||
|
108 | trial ipython1 | |||
|
109 | ||||
|
110 | Or if you have `nose`__ installed:: | |||
|
111 | ||||
|
112 | nosetests -v ipython1 | |||
|
113 | ||||
|
114 | The ``trial`` command is part of Twisted and allows asynchronous network based | |||
|
115 | applications to be tested using Python's unittest framework. Please let us know | |||
|
116 | if the tests do not pass. The best way to get in touch with us is on the `IPython | |||
|
117 | developer mailing list`_. | |||
|
118 | ||||
|
119 | .. __: http://somethingaboutorange.com/mrl/projects/nose/ | |||
|
120 | .. _IPython developer mailing list: http://projects.scipy.org/mailman/listinfo/ipython-dev | |||
|
121 | ||||
|
122 | MPI Support | |||
|
123 | =========== | |||
|
124 | ||||
|
125 | IPython includes optional support for the Message Passing Interface (`MPI`_), | |||
|
126 | which enables the IPython Engines to pass data between each other using `MPI`_. To use MPI with IPython, the minimal requirements are: | |||
|
127 | ||||
|
128 | * An MPI implementation (we recommend `Open MPI`_) | |||
|
129 | * A way to call MPI (we recommend `mpi4py`_) | |||
|
130 | ||||
|
131 | But, IPython should work with any MPI implementation and with any code | |||
|
132 | (Python/C/C++/Fortran) that uses MPI. Please contact us for more information about | |||
|
133 | this. | |||
|
134 | ||||
|
135 | .. _MPI: http://www-unix.mcs.anl.gov/mpi/ | |||
|
136 | .. _mpi4py: http://mpi4py.scipy.org/ | |||
|
137 | .. _Open MPI: http://www.open-mpi.org/ | |||
|
138 |
@@ -0,0 +1,272 | |||||
|
1 | ============================= | |||
|
2 | Basic installation of IPython | |||
|
3 | ============================= | |||
|
4 | ||||
|
5 | Installation | |||
|
6 | ============ | |||
|
7 | ||||
|
8 | Instant instructions | |||
|
9 | -------------------- | |||
|
10 | ||||
|
11 | If you are of the impatient kind, under Linux/Unix simply untar/unzip | |||
|
12 | the download, then install with 'python setup.py install'. Under | |||
|
13 | Windows, double-click on the provided .exe binary installer. | |||
|
14 | ||||
|
15 | Then, take a look at Customization_ section for configuring things | |||
|
16 | optimally and `Quick tips`_ for quick tips on efficient use of | |||
|
17 | IPython. You can later refer to the rest of the manual for all the | |||
|
18 | gory details. | |||
|
19 | ||||
|
20 | See the notes in upgrading_ section for upgrading IPython versions. | |||
|
21 | ||||
|
22 | ||||
|
23 | Detailed Unix instructions (Linux, Mac OS X, etc.) | |||
|
24 | ||||
|
25 | For RPM based systems, simply install the supplied package in the usual | |||
|
26 | manner. If you download the tar archive, the process is: | |||
|
27 | ||||
|
28 | 1. Unzip/untar the ipython-XXX.tar.gz file wherever you want (XXX is | |||
|
29 | the version number). It will make a directory called ipython-XXX. | |||
|
30 | Change into that directory where you will find the files README | |||
|
31 | and setup.py. Once you've completed the installation, you can | |||
|
32 | safely remove this directory. | |||
|
33 | 2. If you are installing over a previous installation of version | |||
|
34 | 0.2.0 or earlier, first remove your $HOME/.ipython directory, | |||
|
35 | since the configuration file format has changed somewhat (the '=' | |||
|
36 | were removed from all option specifications). Or you can call | |||
|
37 | ipython with the -upgrade option and it will do this automatically | |||
|
38 | for you. | |||
|
39 | 3. IPython uses distutils, so you can install it by simply typing at | |||
|
40 | the system prompt (don't type the $):: | |||
|
41 | ||||
|
42 | $ python setup.py install | |||
|
43 | ||||
|
44 | Note that this assumes you have root access to your machine. If | |||
|
45 | you don't have root access or don't want IPython to go in the | |||
|
46 | default python directories, you'll need to use the ``--home`` option | |||
|
47 | (or ``--prefix``). For example:: | |||
|
48 | ||||
|
49 | $ python setup.py install --home $HOME/local | |||
|
50 | ||||
|
51 | will install IPython into $HOME/local and its subdirectories | |||
|
52 | (creating them if necessary). | |||
|
53 | You can type:: | |||
|
54 | ||||
|
55 | $ python setup.py --help | |||
|
56 | ||||
|
57 | for more details. | |||
|
58 | ||||
|
59 | Note that if you change the default location for ``--home`` at | |||
|
60 | installation, IPython may end up installed at a location which is | |||
|
61 | not part of your $PYTHONPATH environment variable. In this case, | |||
|
62 | you'll need to configure this variable to include the actual | |||
|
63 | directory where the IPython/ directory ended (typically the value | |||
|
64 | you give to ``--home`` plus /lib/python). | |||
|
65 | ||||
|
66 | ||||
|
67 | Mac OSX information | |||
|
68 | ------------------- | |||
|
69 | ||||
|
70 | Under OSX, there is a choice you need to make. Apple ships its own build | |||
|
71 | of Python, which lives in the core OSX filesystem hierarchy. You can | |||
|
72 | also manually install a separate Python, either purely by hand | |||
|
73 | (typically in /usr/local) or by using Fink, which puts everything under | |||
|
74 | /sw. Which route to follow is a matter of personal preference, as I've | |||
|
75 | seen users who favor each of the approaches. Here I will simply list the | |||
|
76 | known installation issues under OSX, along with their solutions. | |||
|
77 | ||||
|
78 | This page: http://geosci.uchicago.edu/~tobis/pylab.html contains | |||
|
79 | information on this topic, with additional details on how to make | |||
|
80 | IPython and matplotlib play nicely under OSX. | |||
|
81 | ||||
|
82 | To run IPython and readline on OSX "Leopard" system python, see the | |||
|
83 | wiki page at http://ipython.scipy.org/moin/InstallationOSXLeopard | |||
|
84 | ||||
|
85 | ||||
|
86 | GUI problems | |||
|
87 | ------------ | |||
|
88 | ||||
|
89 | The following instructions apply to an install of IPython under OSX from | |||
|
90 | unpacking the .tar.gz distribution and installing it for the default | |||
|
91 | Python interpreter shipped by Apple. If you are using a fink install, | |||
|
92 | fink will take care of these details for you, by installing IPython | |||
|
93 | against fink's Python. | |||
|
94 | ||||
|
95 | IPython offers various forms of support for interacting with graphical | |||
|
96 | applications from the command line, from simple Tk apps (which are in | |||
|
97 | principle always supported by Python) to interactive control of WX, Qt | |||
|
98 | and GTK apps. Under OSX, however, this requires that ipython is | |||
|
99 | installed by calling the special pythonw script at installation time, | |||
|
100 | which takes care of coordinating things with Apple's graphical environment. | |||
|
101 | ||||
|
102 | So when installing under OSX, it is best to use the following command:: | |||
|
103 | ||||
|
104 | $ sudo pythonw setup.py install --install-scripts=/usr/local/bin | |||
|
105 | ||||
|
106 | or | |||
|
107 | ||||
|
108 | $ sudo pythonw setup.py install --install-scripts=/usr/bin | |||
|
109 | ||||
|
110 | depending on where you like to keep hand-installed executables. | |||
|
111 | ||||
|
112 | The resulting script will have an appropriate shebang line (the first | |||
|
113 | line in the script whic begins with #!...) such that the ipython | |||
|
114 | interpreter can interact with the OS X GUI. If the installed version | |||
|
115 | does not work and has a shebang line that points to, for example, just | |||
|
116 | /usr/bin/python, then you might have a stale, cached version in your | |||
|
117 | build/scripts-<python-version> directory. Delete that directory and | |||
|
118 | rerun the setup.py. | |||
|
119 | ||||
|
120 | It is also a good idea to use the special flag ``--install-scripts`` as | |||
|
121 | indicated above, to ensure that the ipython scripts end up in a location | |||
|
122 | which is part of your $PATH. Otherwise Apple's Python will put the | |||
|
123 | scripts in an internal directory not available by default at the command | |||
|
124 | line (if you use /usr/local/bin, you need to make sure this is in your | |||
|
125 | $PATH, which may not be true by default). | |||
|
126 | ||||
|
127 | ||||
|
128 | Readline problems | |||
|
129 | ----------------- | |||
|
130 | ||||
|
131 | By default, the Python version shipped by Apple does not include the | |||
|
132 | readline library, so central to IPython's behavior. If you install | |||
|
133 | IPython against Apple's Python, you will not have arrow keys, tab | |||
|
134 | completion, etc. For Mac OSX 10.3 (Panther), you can find a prebuilt | |||
|
135 | readline library here: | |||
|
136 | http://pythonmac.org/packages/readline-5.0-py2.3-macosx10.3.zip | |||
|
137 | ||||
|
138 | If you are using OSX 10.4 (Tiger), after installing this package you | |||
|
139 | need to either: | |||
|
140 | ||||
|
141 | 1. move readline.so from /Library/Python/2.3 to | |||
|
142 | /Library/Python/2.3/site-packages, or | |||
|
143 | 2. install http://pythonmac.org/packages/TigerPython23Compat.pkg.zip | |||
|
144 | ||||
|
145 | Users installing against Fink's Python or a properly hand-built one | |||
|
146 | should not have this problem. | |||
|
147 | ||||
|
148 | ||||
|
149 | DarwinPorts | |||
|
150 | ----------- | |||
|
151 | ||||
|
152 | I report here a message from an OSX user, who suggests an alternative | |||
|
153 | means of using IPython under this operating system with good results. | |||
|
154 | Please let me know of any updates that may be useful for this section. | |||
|
155 | His message is reproduced verbatim below: | |||
|
156 | ||||
|
157 | From: Markus Banfi <markus.banfi-AT-mospheira.net> | |||
|
158 | ||||
|
159 | As a MacOS X (10.4.2) user I prefer to install software using | |||
|
160 | DawinPorts instead of Fink. I had no problems installing ipython | |||
|
161 | with DarwinPorts. It's just: | |||
|
162 | ||||
|
163 | sudo port install py-ipython | |||
|
164 | ||||
|
165 | It automatically resolved all dependencies (python24, readline, | |||
|
166 | py-readline). So far I did not encounter any problems with the | |||
|
167 | DarwinPorts port of ipython. | |||
|
168 | ||||
|
169 | ||||
|
170 | ||||
|
171 | Windows instructions | |||
|
172 | -------------------- | |||
|
173 | ||||
|
174 | Some of IPython's very useful features are: | |||
|
175 | ||||
|
176 | * Integrated readline support (Tab-based file, object and attribute | |||
|
177 | completion, input history across sessions, editable command line, | |||
|
178 | etc.) | |||
|
179 | * Coloring of prompts, code and tracebacks. | |||
|
180 | ||||
|
181 | .. _pyreadline: | |||
|
182 | ||||
|
183 | These, by default, are only available under Unix-like operating systems. | |||
|
184 | However, thanks to Gary Bishop's work, Windows XP/2k users can also | |||
|
185 | benefit from them. His readline library originally implemented both GNU | |||
|
186 | readline functionality and color support, so that IPython under Windows | |||
|
187 | XP/2k can be as friendly and powerful as under Unix-like environments. | |||
|
188 | ||||
|
189 | This library, now named PyReadline, has been absorbed by the IPython | |||
|
190 | team (Jörgen Stenarson, in particular), and it continues to be developed | |||
|
191 | with new features, as well as being distributed directly from the | |||
|
192 | IPython site. | |||
|
193 | ||||
|
194 | The PyReadline extension requires CTypes and the windows IPython | |||
|
195 | installer needs PyWin32, so in all you need: | |||
|
196 | ||||
|
197 | 1. PyWin32 from http://sourceforge.net/projects/pywin32. | |||
|
198 | 2. PyReadline for Windows from | |||
|
199 | http://ipython.scipy.org/moin/PyReadline/Intro. That page contains | |||
|
200 | further details on using and configuring the system to your liking. | |||
|
201 | 3. Finally, only if you are using Python 2.3 or 2.4, you need CTypes | |||
|
202 | from http://starship.python.net/crew/theller/ctypes(you must use | |||
|
203 | version 0.9.1 or newer). This package is included in Python 2.5, | |||
|
204 | so you don't need to manually get it if your Python version is 2.5 | |||
|
205 | or newer. | |||
|
206 | ||||
|
207 | Warning about a broken readline-like library: several users have | |||
|
208 | reported problems stemming from using the pseudo-readline library at | |||
|
209 | http://newcenturycomputers.net/projects/readline.html. This is a broken | |||
|
210 | library which, while called readline, only implements an incomplete | |||
|
211 | subset of the readline API. Since it is still called readline, it fools | |||
|
212 | IPython's detection mechanisms and causes unpredictable crashes later. | |||
|
213 | If you wish to use IPython under Windows, you must NOT use this library, | |||
|
214 | which for all purposes is (at least as of version 1.6) terminally broken. | |||
|
215 | ||||
|
216 | ||||
|
217 | Installation procedure | |||
|
218 | ---------------------- | |||
|
219 | ||||
|
220 | Once you have the above installed, from the IPython download directory | |||
|
221 | grab the ipython-XXX.win32.exe file, where XXX represents the version | |||
|
222 | number. This is a regular windows executable installer, which you can | |||
|
223 | simply double-click to install. It will add an entry for IPython to your | |||
|
224 | Start Menu, as well as registering IPython in the Windows list of | |||
|
225 | applications, so you can later uninstall it from the Control Panel. | |||
|
226 | ||||
|
227 | IPython tries to install the configuration information in a directory | |||
|
228 | named .ipython (_ipython under Windows) located in your 'home' | |||
|
229 | directory. IPython sets this directory by looking for a HOME environment | |||
|
230 | variable; if such a variable does not exist, it uses HOMEDRIVE\HOMEPATH | |||
|
231 | (these are always defined by Windows). This typically gives something | |||
|
232 | like C:\Documents and Settings\YourUserName, but your local details may | |||
|
233 | vary. In this directory you will find all the files that configure | |||
|
234 | IPython's defaults, and you can put there your profiles and extensions. | |||
|
235 | This directory is automatically added by IPython to sys.path, so | |||
|
236 | anything you place there can be found by import statements. | |||
|
237 | ||||
|
238 | ||||
|
239 | Upgrading | |||
|
240 | --------- | |||
|
241 | ||||
|
242 | For an IPython upgrade, you should first uninstall the previous version. | |||
|
243 | This will ensure that all files and directories (such as the | |||
|
244 | documentation) which carry embedded version strings in their names are | |||
|
245 | properly removed. | |||
|
246 | ||||
|
247 | ||||
|
248 | Manual installation under Win32 | |||
|
249 | ------------------------------- | |||
|
250 | ||||
|
251 | In case the automatic installer does not work for some reason, you can | |||
|
252 | download the ipython-XXX.tar.gz file, which contains the full IPython | |||
|
253 | source distribution (the popular WinZip can read .tar.gz files). After | |||
|
254 | uncompressing the archive, you can install it at a command terminal just | |||
|
255 | like any other Python module, by using 'python setup.py install'. | |||
|
256 | ||||
|
257 | After the installation, run the supplied win32_manual_post_install.py | |||
|
258 | script, which creates the necessary Start Menu shortcuts for you. | |||
|
259 | ||||
|
260 | ||||
|
261 | .. upgrading: | |||
|
262 | ||||
|
263 | Upgrading from a previous version | |||
|
264 | --------------------------------- | |||
|
265 | ||||
|
266 | If you are upgrading from a previous version of IPython, you may want | |||
|
267 | to upgrade the contents of your ~/.ipython directory. Just run | |||
|
268 | %upgrade, look at the diffs and delete the suggested files manually, | |||
|
269 | if you think you can lose the old versions. %upgrade will never | |||
|
270 | overwrite or delete anything. | |||
|
271 | ||||
|
272 |
@@ -0,0 +1,9 | |||||
|
1 | ================== | |||
|
2 | Installation | |||
|
3 | ================== | |||
|
4 | ||||
|
5 | .. toctree:: | |||
|
6 | :maxdepth: 2 | |||
|
7 | ||||
|
8 | basic.txt | |||
|
9 | advanced.txt |
@@ -0,0 +1,252 | |||||
|
1 | ===================== | |||
|
2 | IPython extension API | |||
|
3 | ===================== | |||
|
4 | ||||
|
5 | IPython api (defined in IPython/ipapi.py) is the public api that | |||
|
6 | should be used for | |||
|
7 | ||||
|
8 | * Configuration of user preferences (.ipython/ipy_user_conf.py) | |||
|
9 | * Creating new profiles (.ipython/ipy_profile_PROFILENAME.py) | |||
|
10 | * Writing extensions | |||
|
11 | ||||
|
12 | Note that by using the extension api for configuration (editing | |||
|
13 | ipy_user_conf.py instead of ipythonrc), you get better validity checks | |||
|
14 | and get richer functionality - for example, you can import an | |||
|
15 | extension and call functions in it to configure it for your purposes. | |||
|
16 | ||||
|
17 | For an example extension (the 'sh' profile), see | |||
|
18 | IPython/Extensions/ipy_profile_sh.py. | |||
|
19 | ||||
|
20 | For the last word on what's available, see the source code of | |||
|
21 | IPython/ipapi.py. | |||
|
22 | ||||
|
23 | ||||
|
24 | Getting started | |||
|
25 | =============== | |||
|
26 | ||||
|
27 | If you want to define an extension, create a normal python module that | |||
|
28 | can be imported. The module will access IPython functionality through | |||
|
29 | the 'ip' object defined below. | |||
|
30 | ||||
|
31 | If you are creating a new profile (e.g. foobar), name the module as | |||
|
32 | 'ipy_profile_foobar.py' and put it in your ~/.ipython directory. Then, | |||
|
33 | when you start ipython with the '-p foobar' argument, the module is | |||
|
34 | automatically imported on ipython startup. | |||
|
35 | ||||
|
36 | If you are just doing some per-user configuration, you can either | |||
|
37 | ||||
|
38 | * Put the commands directly into ipy_user_conf.py. | |||
|
39 | ||||
|
40 | * Create a new module with your customization code and import *that* | |||
|
41 | module in ipy_user_conf.py. This is preferable to the first approach, | |||
|
42 | because now you can reuse and distribute your customization code. | |||
|
43 | ||||
|
44 | Getting a handle to the api | |||
|
45 | =========================== | |||
|
46 | ||||
|
47 | Put this in the start of your module:: | |||
|
48 | ||||
|
49 | #!python | |||
|
50 | import IPython.ipapi | |||
|
51 | ip = IPython.ipapi.get() | |||
|
52 | ||||
|
53 | The 'ip' object will then be used for accessing IPython | |||
|
54 | functionality. 'ip' will mean this api object in all the following | |||
|
55 | code snippets. The same 'ip' that we just acquired is always | |||
|
56 | accessible in interactive IPython sessions by the name _ip - play with | |||
|
57 | it like this:: | |||
|
58 | ||||
|
59 | [~\_ipython]|81> a = 10 | |||
|
60 | [~\_ipython]|82> _ip.e | |||
|
61 | _ip.ev _ip.ex _ip.expose_magic | |||
|
62 | [~\_ipython]|82> _ip.ev('a+13') | |||
|
63 | <82> 23 | |||
|
64 | ||||
|
65 | The _ip object is also used in some examples in this document - it can | |||
|
66 | be substituted by 'ip' in non-interactive use. | |||
|
67 | ||||
|
68 | Changing options | |||
|
69 | ================ | |||
|
70 | ||||
|
71 | The ip object has 'options' attribute that can be used te get/set | |||
|
72 | configuration options (just as in the ipythonrc file):: | |||
|
73 | ||||
|
74 | o = ip.options | |||
|
75 | o.autocall = 2 | |||
|
76 | o.automagic = 1 | |||
|
77 | ||||
|
78 | Executing statements in IPython namespace with 'ex' and 'ev' | |||
|
79 | ============================================================ | |||
|
80 | ||||
|
81 | Often, you want to e.g. import some module or define something that | |||
|
82 | should be visible in IPython namespace. Use ``ip.ev`` to | |||
|
83 | *evaluate* (calculate the value of) expression and ``ip.ex`` to | |||
|
84 | '''execute''' a statement:: | |||
|
85 | ||||
|
86 | # path module will be visible to the interactive session | |||
|
87 | ip.ex("from path import path" ) | |||
|
88 | ||||
|
89 | # define a handy function 'up' that changes the working directory | |||
|
90 | ||||
|
91 | ip.ex('import os') | |||
|
92 | ip.ex("def up(): os.chdir('..')") | |||
|
93 | ||||
|
94 | ||||
|
95 | # _i2 has the input history entry #2, print its value in uppercase. | |||
|
96 | print ip.ev('_i2.upper()') | |||
|
97 | ||||
|
98 | Accessing the IPython namespace | |||
|
99 | =============================== | |||
|
100 | ||||
|
101 | ip.user_ns attribute has a dictionary containing the IPython global | |||
|
102 | namespace (the namespace visible in the interactive session). | |||
|
103 | ||||
|
104 | :: | |||
|
105 | ||||
|
106 | [~\_ipython]|84> tauno = 555 | |||
|
107 | [~\_ipython]|85> _ip.user_ns['tauno'] | |||
|
108 | <85> 555 | |||
|
109 | ||||
|
110 | Defining new magic commands | |||
|
111 | =========================== | |||
|
112 | ||||
|
113 | The following example defines a new magic command, %impall. What the | |||
|
114 | command does should be obvious:: | |||
|
115 | ||||
|
116 | def doimp(self, arg): | |||
|
117 | ip = self.api | |||
|
118 | ip.ex("import %s; reload(%s); from %s import *" % ( | |||
|
119 | arg,arg,arg) | |||
|
120 | ) | |||
|
121 | ||||
|
122 | ip.expose_magic('impall', doimp) | |||
|
123 | ||||
|
124 | Things to observe in this example: | |||
|
125 | ||||
|
126 | * Define a function that implements the magic command using the | |||
|
127 | ipapi methods defined in this document | |||
|
128 | * The first argument of the function is 'self', i.e. the | |||
|
129 | interpreter object. It shouldn't be used directly. however. | |||
|
130 | The interpreter object is probably *not* going to remain stable | |||
|
131 | through IPython versions. | |||
|
132 | * Access the ipapi through 'self.api' instead of the global 'ip' object. | |||
|
133 | * All the text following the magic command on the command line is | |||
|
134 | contained in the second argument | |||
|
135 | * Expose the magic by ip.expose_magic() | |||
|
136 | ||||
|
137 | ||||
|
138 | Calling magic functions and system commands | |||
|
139 | =========================================== | |||
|
140 | ||||
|
141 | Use ip.magic() to execute a magic function, and ip.system() to execute | |||
|
142 | a system command:: | |||
|
143 | ||||
|
144 | # go to a bookmark | |||
|
145 | ip.magic('%cd -b relfiles') | |||
|
146 | ||||
|
147 | # execute 'ls -F' system command. Interchangeable with os.system('ls'), really. | |||
|
148 | ip.system('ls -F') | |||
|
149 | ||||
|
150 | Launching IPython instance from normal python code | |||
|
151 | ================================================== | |||
|
152 | ||||
|
153 | Use ipapi.launch_new_instance() with an argument that specifies the | |||
|
154 | namespace to use. This can be useful for trivially embedding IPython | |||
|
155 | into your program. Here's an example of normal python program test.py | |||
|
156 | ('''without''' an existing IPython session) that launches an IPython | |||
|
157 | interpreter and regains control when the interpreter is exited:: | |||
|
158 | ||||
|
159 | [ipython]|1> cat test.py | |||
|
160 | my_ns = dict( | |||
|
161 | kissa = 15, | |||
|
162 | koira = 16) | |||
|
163 | import IPython.ipapi | |||
|
164 | print "launching IPython instance" | |||
|
165 | IPython.ipapi.launch_new_instance(my_ns) | |||
|
166 | print "Exited IPython instance!" | |||
|
167 | print "New vals:",my_ns['kissa'], my_ns['koira'] | |||
|
168 | ||||
|
169 | And here's what it looks like when run (note how we don't start it | |||
|
170 | from an ipython session):: | |||
|
171 | ||||
|
172 | Q:\ipython>python test.py | |||
|
173 | launching IPython instance | |||
|
174 | Py 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] IPy 0.7.3b3.r1975 | |||
|
175 | [ipython]|1> kissa = 444 | |||
|
176 | [ipython]|2> koira = 555 | |||
|
177 | [ipython]|3> Exit | |||
|
178 | Exited IPython instance! | |||
|
179 | New vals: 444 555 | |||
|
180 | ||||
|
181 | Accessing unexposed functionality | |||
|
182 | ================================= | |||
|
183 | ||||
|
184 | There are still many features that are not exposed via the ipapi. If | |||
|
185 | you can't avoid using them, you can use the functionality in | |||
|
186 | InteractiveShell object (central IPython session class, defined in | |||
|
187 | iplib.py) through ip.IP. | |||
|
188 | ||||
|
189 | For example:: | |||
|
190 | ||||
|
191 | [~]|7> _ip.IP.expand_aliases('np','myfile.py') | |||
|
192 | <7> 'c:/opt/Notepad++/notepad++.exe myfile.py' | |||
|
193 | [~]|8> | |||
|
194 | ||||
|
195 | Still, it's preferable that if you encounter such a feature, contact | |||
|
196 | the IPython team and request that the functionality be exposed in a | |||
|
197 | future version of IPython. Things not in ipapi are more likely to | |||
|
198 | change over time. | |||
|
199 | ||||
|
200 | Provided extensions | |||
|
201 | =================== | |||
|
202 | ||||
|
203 | You can see the list of available extensions (and profiles) by doing | |||
|
204 | ``import ipy_<TAB>``. Some extensions don't have the ``ipy_`` prefix in | |||
|
205 | module name, so you may need to see the contents of IPython/Extensions | |||
|
206 | folder to see what's available. | |||
|
207 | ||||
|
208 | You can see a brief documentation of an extension by looking at the | |||
|
209 | module docstring:: | |||
|
210 | ||||
|
211 | [c:p/ipython_main]|190> import ipy_fsops | |||
|
212 | [c:p/ipython_main]|191> ipy_fsops? | |||
|
213 | ||||
|
214 | ... | |||
|
215 | ||||
|
216 | Docstring: | |||
|
217 | File system operations | |||
|
218 | ||||
|
219 | Contains: Simple variants of normal unix shell commands (icp, imv, irm, | |||
|
220 | imkdir, igrep). | |||
|
221 | ||||
|
222 | You can also install your own extensions - the recommended way is to | |||
|
223 | just copy the module to ~/.ipython. Extensions are typically enabled | |||
|
224 | by just importing them (e.g. in ipy_user_conf.py), but some extensions | |||
|
225 | require additional steps, for example:: | |||
|
226 | ||||
|
227 | [c:p]|192> import ipy_traits_completer | |||
|
228 | [c:p]|193> ipy_traits_completer.activate() | |||
|
229 | ||||
|
230 | Note that extensions, even if provided in the stock IPython | |||
|
231 | installation, are not guaranteed to have the same requirements as the | |||
|
232 | rest of IPython - an extension may require external libraries or a | |||
|
233 | newer version of Python than what IPython officially requires. An | |||
|
234 | extension may also be under a more restrictive license than IPython | |||
|
235 | (e.g. ipy_bzr is under GPL). | |||
|
236 | ||||
|
237 | Just for reference, the list of bundled extensions at the time of | |||
|
238 | writing is below: | |||
|
239 | ||||
|
240 | astyle.py clearcmd.py envpersist.py ext_rescapture.py ibrowse.py | |||
|
241 | igrid.py InterpreterExec.py InterpreterPasteInput.py ipipe.py | |||
|
242 | ipy_app_completers.py ipy_autoreload.py ipy_bzr.py ipy_completers.py | |||
|
243 | ipy_constants.py ipy_defaults.py ipy_editors.py ipy_exportdb.py | |||
|
244 | ipy_extutil.py ipy_fsops.py ipy_gnuglobal.py ipy_kitcfg.py | |||
|
245 | ipy_legacy.py ipy_leo.py ipy_p4.py ipy_profile_doctest.py | |||
|
246 | ipy_profile_none.py ipy_profile_scipy.py ipy_profile_sh.py | |||
|
247 | ipy_profile_zope.py ipy_pydb.py ipy_rehashdir.py ipy_render.py | |||
|
248 | ipy_server.py ipy_signals.py ipy_stock_completers.py | |||
|
249 | ipy_system_conf.py ipy_traits_completer.py ipy_vimserver.py | |||
|
250 | ipy_which.py ipy_workdir.py jobctrl.py ledit.py numeric_formats.py | |||
|
251 | PhysicalQInput.py PhysicalQInteractive.py pickleshare.py | |||
|
252 | pspersistence.py win32clip.py __init__.py No newline at end of file |
@@ -0,0 +1,11 | |||||
|
1 | ================================== | |||
|
2 | Using IPython for interactive work | |||
|
3 | ================================== | |||
|
4 | ||||
|
5 | .. toctree:: | |||
|
6 | :maxdepth: 1 | |||
|
7 | ||||
|
8 | tutorial.txt | |||
|
9 | reference.txt | |||
|
10 | shell.txt | |||
|
11 | extension_api.txt |
1 | NO CONTENT: new file 100644 |
|
NO CONTENT: new file 100644 | ||
The requested commit or file is too big and content was truncated. Show full diff |
1 | NO CONTENT: new file 100644 |
|
NO CONTENT: new file 100644 | ||
The requested commit or file is too big and content was truncated. Show full diff |
1 | NO CONTENT: new file 100644 |
|
NO CONTENT: new file 100644 | ||
The requested commit or file is too big and content was truncated. Show full diff |
1 | NO CONTENT: new file 100644 |
|
NO CONTENT: new file 100644 | ||
The requested commit or file is too big and content was truncated. Show full diff |
1 | NO CONTENT: new file 100644 |
|
NO CONTENT: new file 100644 | ||
The requested commit or file is too big and content was truncated. Show full diff |
1 | NO CONTENT: new file 100644 |
|
NO CONTENT: new file 100644 | ||
The requested commit or file is too big and content was truncated. Show full diff |
1 | NO CONTENT: new file 100644 |
|
NO CONTENT: new file 100644 | ||
The requested commit or file is too big and content was truncated. Show full diff |
1 | NO CONTENT: new file 100644 |
|
NO CONTENT: new file 100644 | ||
The requested commit or file is too big and content was truncated. Show full diff |
1 | NO CONTENT: new file 100644 |
|
NO CONTENT: new file 100644 | ||
The requested commit or file is too big and content was truncated. Show full diff |
1 | NO CONTENT: new file 100644 |
|
NO CONTENT: new file 100644 | ||
The requested commit or file is too big and content was truncated. Show full diff |
@@ -19,6 +19,11 import os | |||||
19 | from IPython.config.cutils import get_home_dir, get_ipython_dir |
|
19 | from IPython.config.cutils import get_home_dir, get_ipython_dir | |
20 | from IPython.external.configobj import ConfigObj |
|
20 | from IPython.external.configobj import ConfigObj | |
21 |
|
21 | |||
|
22 | # Traitlets config imports | |||
|
23 | from IPython.config import traitlets | |||
|
24 | from IPython.config.config import * | |||
|
25 | from traitlets import * | |||
|
26 | ||||
22 | class ConfigObjManager(object): |
|
27 | class ConfigObjManager(object): | |
23 |
|
28 | |||
24 | def __init__(self, configObj, filename): |
|
29 | def __init__(self, configObj, filename): |
@@ -13,20 +13,15 graft IPython/config | |||||
13 | graft IPython/testing |
|
13 | graft IPython/testing | |
14 | graft IPython/tools |
|
14 | graft IPython/tools | |
15 |
|
15 | |||
16 | graft doc |
|
16 | graft docs | |
17 | exclude doc/\#* |
|
17 | exclude docs/\#* | |
18 | exclude doc/*.1 |
|
18 | exclude docs/man/*.1 | |
19 | exclude doc/ChangeLog.* |
|
19 | exclude docs/ChangeLog.* | |
20 | exclude doc/update_version.sh |
|
|||
21 |
|
20 | |||
22 | # There seems to be no way of excluding whole subdirectories, other than |
|
21 | # There seems to be no way of excluding whole subdirectories, other than | |
23 | # manually excluding all their subdirs. distutils really is horrible... |
|
22 | # manually excluding all their subdirs. distutils really is horrible... | |
24 | exclude doc/attic/* |
|
23 | exclude docs/attic/* | |
25 |
exclude doc/build |
|
24 | exclude docs/build/* | |
26 | exclude doc/build/html/_sources/* |
|
|||
27 | exclude doc/build/html/_static/* |
|
|||
28 | exclude doc/build/html/* |
|
|||
29 | exclude doc/build/latex/* |
|
|||
30 |
|
25 | |||
31 | global-exclude *~ |
|
26 | global-exclude *~ | |
32 | global-exclude *.flc |
|
27 | global-exclude *.flc |
1 | NO CONTENT: file renamed from doc/ChangeLog to docs/ChangeLog |
|
NO CONTENT: file renamed from doc/ChangeLog to docs/ChangeLog |
1 | NO CONTENT: file renamed from doc/README.txt to docs/README.txt |
|
NO CONTENT: file renamed from doc/README.txt to docs/README.txt |
1 | NO CONTENT: file renamed from doc/README_Windows.txt to docs/README_Windows.txt |
|
NO CONTENT: file renamed from doc/README_Windows.txt to docs/README_Windows.txt |
1 | NO CONTENT: file renamed from doc/api_changes.txt to docs/api_changes.txt |
|
NO CONTENT: file renamed from doc/api_changes.txt to docs/api_changes.txt |
1 | NO CONTENT: file renamed from doc/COPYING to docs/attic/COPYING |
|
NO CONTENT: file renamed from doc/COPYING to docs/attic/COPYING |
1 | NO CONTENT: file renamed from doc/attic/ipnb_google_soc.lyx to docs/attic/ipnb_google_soc.lyx |
|
NO CONTENT: file renamed from doc/attic/ipnb_google_soc.lyx to docs/attic/ipnb_google_soc.lyx |
1 | NO CONTENT: file renamed from doc/attic/nbexample.py to docs/attic/nbexample.py |
|
NO CONTENT: file renamed from doc/attic/nbexample.py to docs/attic/nbexample.py |
1 | NO CONTENT: file renamed from doc/attic/nbexample_latex.py to docs/attic/nbexample_latex.py |
|
NO CONTENT: file renamed from doc/attic/nbexample_latex.py to docs/attic/nbexample_latex.py |
1 | NO CONTENT: file renamed from doc/attic/nbexample_output.py to docs/attic/nbexample_output.py |
|
NO CONTENT: file renamed from doc/attic/nbexample_output.py to docs/attic/nbexample_output.py |
1 | NO CONTENT: file renamed from doc/attic/new_design.lyx to docs/attic/new_design.lyx |
|
NO CONTENT: file renamed from doc/attic/new_design.lyx to docs/attic/new_design.lyx |
1 | NO CONTENT: file renamed from doc/do_sphinx.py to docs/do_sphinx.py |
|
NO CONTENT: file renamed from doc/do_sphinx.py to docs/do_sphinx.py |
1 | NO CONTENT: file renamed from doc/ipython.el to docs/emacs/ipython.el |
|
NO CONTENT: file renamed from doc/ipython.el to docs/emacs/ipython.el |
1 | NO CONTENT: file renamed from doc/examples/example-demo.py to docs/examples/core/example-demo.py |
|
NO CONTENT: file renamed from doc/examples/example-demo.py to docs/examples/core/example-demo.py |
1 | NO CONTENT: file renamed from doc/examples/example-embed-short.py to docs/examples/core/example-embed-short.py |
|
NO CONTENT: file renamed from doc/examples/example-embed-short.py to docs/examples/core/example-embed-short.py |
1 | NO CONTENT: file renamed from doc/examples/example-embed.py to docs/examples/core/example-embed.py |
|
NO CONTENT: file renamed from doc/examples/example-embed.py to docs/examples/core/example-embed.py |
1 | NO CONTENT: file renamed from doc/examples/example-gnuplot.py to docs/examples/core/example-gnuplot.py |
|
NO CONTENT: file renamed from doc/examples/example-gnuplot.py to docs/examples/core/example-gnuplot.py |
1 | NO CONTENT: file renamed from doc/examples/extension.py to docs/examples/core/extension.py |
|
NO CONTENT: file renamed from doc/examples/extension.py to docs/examples/core/extension.py |
1 | NO CONTENT: file renamed from doc/examples/ipy.vim to docs/examples/core/ipy.vim |
|
NO CONTENT: file renamed from doc/examples/ipy.vim to docs/examples/core/ipy.vim |
1 | NO CONTENT: file renamed from doc/examples/ipython_here_shell_extension.reg to docs/examples/core/ipython_here_shell_extension.reg |
|
NO CONTENT: file renamed from doc/examples/ipython_here_shell_extension.reg to docs/examples/core/ipython_here_shell_extension.reg |
1 | NO CONTENT: file renamed from doc/examples/leo_bridge_demo.leo to docs/examples/core/leo_bridge_demo.leo |
|
NO CONTENT: file renamed from doc/examples/leo_bridge_demo.leo to docs/examples/core/leo_bridge_demo.leo |
1 | NO CONTENT: file renamed from doc/examples/seteditor.py to docs/examples/core/seteditor.py |
|
NO CONTENT: file renamed from doc/examples/seteditor.py to docs/examples/core/seteditor.py |
1 | NO CONTENT: file renamed from doc/ipython.1 to docs/man/ipython.1 |
|
NO CONTENT: file renamed from doc/ipython.1 to docs/man/ipython.1 |
1 | NO CONTENT: file renamed from doc/pycolor.1 to docs/man/pycolor.1 |
|
NO CONTENT: file renamed from doc/pycolor.1 to docs/man/pycolor.1 |
1 | NO CONTENT: file renamed from doc/pycon.ico to docs/pycon.ico |
|
NO CONTENT: file renamed from doc/pycon.ico to docs/pycon.ico |
@@ -1,7 +1,7 | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | # |
|
2 | # | |
3 | # IPython documentation build configuration file, created by |
|
3 | # IPython documentation build configuration file, created by | |
4 |
# sphinx-quickstart |
|
4 | # sphinx-quickstart on Thu May 8 16:45:02 2008. | |
5 | # |
|
5 | # | |
6 | # This file is execfile()d with the current directory set to its containing dir. |
|
6 | # This file is execfile()d with the current directory set to its containing dir. | |
7 | # |
|
7 | # | |
@@ -11,38 +11,40 | |||||
11 | # All configuration values have a default value; values that are commented out |
|
11 | # All configuration values have a default value; values that are commented out | |
12 | # serve to show the default value. |
|
12 | # serve to show the default value. | |
13 |
|
13 | |||
14 | import sys |
|
14 | import sys, os | |
15 |
|
15 | |||
16 | # If your extensions are in another directory, add it here. |
|
16 | # If your extensions are in another directory, add it here. If the directory | |
17 | #sys.path.append('some/directory') |
|
17 | # is relative to the documentation root, use os.path.abspath to make it | |
|
18 | # absolute, like shown here. | |||
|
19 | #sys.path.append(os.path.abspath('some/directory')) | |||
18 |
|
20 | |||
19 | # General configuration |
|
21 | # General configuration | |
20 | # --------------------- |
|
22 | # --------------------- | |
21 |
|
23 | |||
22 | # Add any Sphinx extension module names here, as strings. They can be extensions |
|
24 | # Add any Sphinx extension module names here, as strings. They can be extensions | |
23 |
# coming with Sphinx (named 'sphinx. |
|
25 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. | |
24 | #extensions = [] |
|
26 | #extensions = [] | |
25 |
|
27 | |||
26 | # Add any paths that contain templates here, relative to this directory. |
|
28 | # Add any paths that contain templates here, relative to this directory. | |
27 | templates_path = ['_templates'] |
|
29 | templates_path = ['_templates'] | |
28 |
|
30 | |||
29 | # The suffix of source filenames. |
|
31 | # The suffix of source filenames. | |
30 |
source_suffix = '. |
|
32 | source_suffix = '.txt' | |
31 |
|
33 | |||
32 | # The master toctree document. |
|
34 | # The master toctree document. | |
33 |
master_doc = 'i |
|
35 | master_doc = 'index' | |
34 |
|
36 | |||
35 | # General substitutions. |
|
37 | # General substitutions. | |
36 | project = 'IPython' |
|
38 | project = 'IPython' | |
37 | copyright = '2008, Fernando Perez' |
|
39 | copyright = '2008, The IPython Development Team' | |
38 |
|
40 | |||
39 | # The default replacements for |version| and |release|, also used in various |
|
41 | # The default replacements for |version| and |release|, also used in various | |
40 | # other places throughout the built documents. |
|
42 | # other places throughout the built documents. | |
41 | # |
|
43 | # | |
42 | # The short X.Y version. |
|
44 | # The short X.Y version. | |
43 |
version = '0. |
|
45 | version = '0.9' | |
44 | # The full version, including alpha/beta/rc tags. |
|
46 | # The full version, including alpha/beta/rc tags. | |
45 |
release = '0. |
|
47 | release = '0.9' | |
46 |
|
48 | |||
47 | # There are two options for replacing |today|: either, you set today to some |
|
49 | # There are two options for replacing |today|: either, you set today to some | |
48 | # non-false value, then it is used: |
|
50 | # non-false value, then it is used: | |
@@ -53,6 +55,10 today_fmt = '%B %d, %Y' | |||||
53 | # List of documents that shouldn't be included in the build. |
|
55 | # List of documents that shouldn't be included in the build. | |
54 | #unused_docs = [] |
|
56 | #unused_docs = [] | |
55 |
|
57 | |||
|
58 | # List of directories, relative to source directories, that shouldn't be searched | |||
|
59 | # for source files. | |||
|
60 | #exclude_dirs = [] | |||
|
61 | ||||
56 | # If true, '()' will be appended to :func: etc. cross-reference text. |
|
62 | # If true, '()' will be appended to :func: etc. cross-reference text. | |
57 | #add_function_parentheses = True |
|
63 | #add_function_parentheses = True | |
58 |
|
64 | |||
@@ -76,6 +82,14 pygments_style = 'sphinx' | |||||
76 | # given in html_static_path. |
|
82 | # given in html_static_path. | |
77 | html_style = 'default.css' |
|
83 | html_style = 'default.css' | |
78 |
|
84 | |||
|
85 | # The name for this set of Sphinx documents. If None, it defaults to | |||
|
86 | # "<project> v<release> documentation". | |||
|
87 | #html_title = None | |||
|
88 | ||||
|
89 | # The name of an image file (within the static path) to place at the top of | |||
|
90 | # the sidebar. | |||
|
91 | #html_logo = None | |||
|
92 | ||||
79 | # Add any paths that contain custom static files (such as style sheets) here, |
|
93 | # Add any paths that contain custom static files (such as style sheets) here, | |
80 | # relative to this directory. They are copied after the builtin static files, |
|
94 | # relative to this directory. They are copied after the builtin static files, | |
81 | # so a file named "default.css" will overwrite the builtin "default.css". |
|
95 | # so a file named "default.css" will overwrite the builtin "default.css". | |
@@ -89,9 +103,6 html_last_updated_fmt = '%b %d, %Y' | |||||
89 | # typographically correct entities. |
|
103 | # typographically correct entities. | |
90 | #html_use_smartypants = True |
|
104 | #html_use_smartypants = True | |
91 |
|
105 | |||
92 | # Content template for the index page. |
|
|||
93 | #html_index = '' |
|
|||
94 |
|
||||
95 | # Custom sidebar templates, maps document names to template names. |
|
106 | # Custom sidebar templates, maps document names to template names. | |
96 | #html_sidebars = {} |
|
107 | #html_sidebars = {} | |
97 |
|
108 | |||
@@ -105,6 +116,14 html_last_updated_fmt = '%b %d, %Y' | |||||
105 | # If true, the reST sources are included in the HTML build as _sources/<name>. |
|
116 | # If true, the reST sources are included in the HTML build as _sources/<name>. | |
106 | #html_copy_source = True |
|
117 | #html_copy_source = True | |
107 |
|
118 | |||
|
119 | # If true, an OpenSearch description file will be output, and all pages will | |||
|
120 | # contain a <link> tag referring to it. The value of this option must be the | |||
|
121 | # base URL from which the finished HTML is served. | |||
|
122 | #html_use_opensearch = '' | |||
|
123 | ||||
|
124 | # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). | |||
|
125 | #html_file_suffix = '' | |||
|
126 | ||||
108 | # Output file base name for HTML help builder. |
|
127 | # Output file base name for HTML help builder. | |
109 | htmlhelp_basename = 'IPythondoc' |
|
128 | htmlhelp_basename = 'IPythondoc' | |
110 |
|
129 | |||
@@ -113,14 +132,24 htmlhelp_basename = 'IPythondoc' | |||||
113 | # ------------------------ |
|
132 | # ------------------------ | |
114 |
|
133 | |||
115 | # The paper size ('letter' or 'a4'). |
|
134 | # The paper size ('letter' or 'a4'). | |
116 |
latex_paper_size = ' |
|
135 | latex_paper_size = 'letter' | |
117 |
|
136 | |||
118 | # The font size ('10pt', '11pt' or '12pt'). |
|
137 | # The font size ('10pt', '11pt' or '12pt'). | |
119 | latex_font_size = '10pt' |
|
138 | latex_font_size = '10pt' | |
120 |
|
139 | |||
121 | # Grouping the document tree into LaTeX files. List of tuples |
|
140 | # Grouping the document tree into LaTeX files. List of tuples | |
122 | # (source start file, target name, title, author, document class [howto/manual]). |
|
141 | # (source start file, target name, title, author, document class [howto/manual]). | |
123 | latex_documents = [('ipython','ipython.tex','IPython Documentation','Fernando Perez (and contributors)','manual')] |
|
142 | latex_documents = [ | |
|
143 | ('index', 'IPython.tex', 'IPython Documentation', 'The IPython Development Team', 'manual'), | |||
|
144 | ] | |||
|
145 | ||||
|
146 | # The name of an image file (relative to this directory) to place at the top of | |||
|
147 | # the title page. | |||
|
148 | #latex_logo = None | |||
|
149 | ||||
|
150 | # For "manual" documents, if this is true, then toplevel headings are parts, | |||
|
151 | # not chapters. | |||
|
152 | #latex_use_parts = False | |||
124 |
|
153 | |||
125 | # Additional stuff for the LaTeX preamble. |
|
154 | # Additional stuff for the LaTeX preamble. | |
126 | #latex_preamble = '' |
|
155 | #latex_preamble = '' |
1 | NO CONTENT: file renamed from doc/update_version.sh to docs/update_version.sh |
|
NO CONTENT: file renamed from doc/update_version.sh to docs/update_version.sh |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file | ||
The requested commit or file is too big and content was truncated. Show full diff |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file | ||
The requested commit or file is too big and content was truncated. Show full diff |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed | ||
This diff has been collapsed as it changes many lines, (622 lines changed) Show them Hide them |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now