Show More
@@ -1,446 +1,461 b'' | |||||
1 | .. _development: |
|
1 | .. _development: | |
2 |
|
2 | |||
3 | ============================== |
|
3 | ============================== | |
4 | IPython development guidelines |
|
4 | IPython development guidelines | |
5 | ============================== |
|
5 | ============================== | |
6 |
|
6 | |||
7 |
|
7 | |||
8 | Overview |
|
8 | Overview | |
9 | ======== |
|
9 | ======== | |
10 |
|
10 | |||
11 | IPython is the next generation of IPython. It is named such for two reasons: |
|
11 | IPython is the next generation of IPython. It is named such for two reasons: | |
12 |
|
12 | |||
13 | - Eventually, IPython will become IPython version 1.0. |
|
13 | - Eventually, IPython will become IPython version 1.0. | |
14 | - This new code base needs to be able to co-exist with the existing IPython until |
|
14 | - This new code base needs to be able to co-exist with the existing IPython until | |
15 | it is a full replacement for it. Thus we needed a different name. We couldn't |
|
15 | it is a full replacement for it. Thus we needed a different name. We couldn't | |
16 | use ``ipython`` (lowercase) as some files systems are case insensitive. |
|
16 | use ``ipython`` (lowercase) as some files systems are case insensitive. | |
17 |
|
17 | |||
18 | There are two, no three, main goals of the IPython effort: |
|
18 | There are two, no three, main goals of the IPython effort: | |
19 |
|
19 | |||
20 | 1. Clean up the existing codebase and write lots of tests. |
|
20 | 1. Clean up the existing codebase and write lots of tests. | |
21 | 2. Separate the core functionality of IPython from the terminal to enable IPython |
|
21 | 2. Separate the core functionality of IPython from the terminal to enable IPython | |
22 | to be used from within a variety of GUI applications. |
|
22 | to be used from within a variety of GUI applications. | |
23 | 3. Implement a system for interactive parallel computing. |
|
23 | 3. Implement a system for interactive parallel computing. | |
24 |
|
24 | |||
25 | While the third goal may seem a bit unrelated to the main focus of IPython, it |
|
25 | While the third goal may seem a bit unrelated to the main focus of IPython, it | |
26 | turns out that the technologies required for this goal are nearly identical |
|
26 | turns out that the technologies required for this goal are nearly identical | |
27 | with those required for goal two. This is the main reason the interactive |
|
27 | with those required for goal two. This is the main reason the interactive | |
28 | parallel computing capabilities are being put into IPython proper. Currently |
|
28 | parallel computing capabilities are being put into IPython proper. Currently | |
29 | the third of these goals is furthest along. |
|
29 | the third of these goals is furthest along. | |
30 |
|
30 | |||
31 | This document describes IPython from the perspective of developers. |
|
31 | This document describes IPython from the perspective of developers. | |
32 |
|
32 | |||
33 |
|
33 | |||
34 | Project organization |
|
34 | Project organization | |
35 | ==================== |
|
35 | ==================== | |
36 |
|
36 | |||
37 | Subpackages |
|
37 | Subpackages | |
38 | ----------- |
|
38 | ----------- | |
39 |
|
39 | |||
40 | IPython is organized into semi self-contained subpackages. Each of the |
|
40 | IPython is organized into semi self-contained subpackages. Each of the | |
41 | subpackages will have its own: |
|
41 | subpackages will have its own: | |
42 |
|
42 | |||
43 | - **Dependencies**. One of the most important things to keep in mind in |
|
43 | - **Dependencies**. One of the most important things to keep in mind in | |
44 | partitioning code amongst subpackages, is that they should be used to cleanly |
|
44 | partitioning code amongst subpackages, is that they should be used to cleanly | |
45 | encapsulate dependencies. |
|
45 | encapsulate dependencies. | |
46 |
|
46 | |||
47 | - **Tests**. Each subpackage shoud have its own ``tests`` subdirectory that |
|
47 | - **Tests**. Each subpackage shoud have its own ``tests`` subdirectory that | |
48 | contains all of the tests for that package. For information about writing |
|
48 | contains all of the tests for that package. For information about writing | |
49 | tests for IPython, see the `Testing System`_ section of this document. |
|
49 | tests for IPython, see the `Testing System`_ section of this document. | |
50 |
|
50 | |||
51 | - **Configuration**. Each subpackage should have its own ``config`` |
|
51 | - **Configuration**. Each subpackage should have its own ``config`` | |
52 | subdirectory that contains the configuration information for the components |
|
52 | subdirectory that contains the configuration information for the components | |
53 | of the subpackage. For information about how the IPython configuration |
|
53 | of the subpackage. For information about how the IPython configuration | |
54 | system works, see the `Configuration System`_ section of this document. |
|
54 | system works, see the `Configuration System`_ section of this document. | |
55 |
|
55 | |||
56 | - **Scripts**. Each subpackage should have its own ``scripts`` subdirectory |
|
56 | - **Scripts**. Each subpackage should have its own ``scripts`` subdirectory | |
57 | that contains all of the command line scripts associated with the subpackage. |
|
57 | that contains all of the command line scripts associated with the subpackage. | |
58 |
|
58 | |||
59 | Installation and dependencies |
|
59 | Installation and dependencies | |
60 | ----------------------------- |
|
60 | ----------------------------- | |
61 |
|
61 | |||
62 | IPython will not use `setuptools`_ for installation. Instead, we will use |
|
62 | IPython will not use `setuptools`_ for installation. Instead, we will use | |
63 | standard ``setup.py`` scripts that use `distutils`_. While there are a number a |
|
63 | standard ``setup.py`` scripts that use `distutils`_. While there are a number a | |
64 | extremely nice features that `setuptools`_ has (like namespace packages), the |
|
64 | extremely nice features that `setuptools`_ has (like namespace packages), the | |
65 | current implementation of `setuptools`_ has performance problems, particularly |
|
65 | current implementation of `setuptools`_ has performance problems, particularly | |
66 | on shared file systems. In particular, when Python packages are installed on |
|
66 | on shared file systems. In particular, when Python packages are installed on | |
67 | NSF file systems, import times become much too long (up towards 10 seconds). |
|
67 | NSF file systems, import times become much too long (up towards 10 seconds). | |
68 |
|
68 | |||
69 | Because IPython is being used extensively in the context of high performance |
|
69 | Because IPython is being used extensively in the context of high performance | |
70 | computing, where performance is critical but shared file systems are common, we |
|
70 | computing, where performance is critical but shared file systems are common, we | |
71 | feel these performance hits are not acceptable. Thus, until the performance |
|
71 | feel these performance hits are not acceptable. Thus, until the performance | |
72 | problems associated with `setuptools`_ are addressed, we will stick with plain |
|
72 | problems associated with `setuptools`_ are addressed, we will stick with plain | |
73 | `distutils`_. We are hopeful that these problems will be addressed and that we |
|
73 | `distutils`_. We are hopeful that these problems will be addressed and that we | |
74 | will eventually begin using `setuptools`_. Because of this, we are trying to |
|
74 | will eventually begin using `setuptools`_. Because of this, we are trying to | |
75 | organize IPython in a way that will make the eventual transition to |
|
75 | organize IPython in a way that will make the eventual transition to | |
76 | `setuptools`_ as painless as possible. |
|
76 | `setuptools`_ as painless as possible. | |
77 |
|
77 | |||
78 | Because we will be using `distutils`_, there will be no method for |
|
78 | Because we will be using `distutils`_, there will be no method for | |
79 | automatically installing dependencies. Instead, we are following the approach |
|
79 | automatically installing dependencies. Instead, we are following the approach | |
80 | of `Matplotlib`_ which can be summarized as follows: |
|
80 | of `Matplotlib`_ which can be summarized as follows: | |
81 |
|
81 | |||
82 | - Distinguish between required and optional dependencies. However, the required |
|
82 | - Distinguish between required and optional dependencies. However, the required | |
83 | dependencies for IPython should be only the Python standard library. |
|
83 | dependencies for IPython should be only the Python standard library. | |
84 |
|
84 | |||
85 | - Upon installation check to see which optional dependencies are present and |
|
85 | - Upon installation check to see which optional dependencies are present and | |
86 | tell the user which parts of IPython need which optional dependencies. |
|
86 | tell the user which parts of IPython need which optional dependencies. | |
87 |
|
87 | |||
88 | It is absolutely critical that each subpackage of IPython has a clearly |
|
88 | It is absolutely critical that each subpackage of IPython has a clearly | |
89 | specified set of dependencies and that dependencies are not carelessly |
|
89 | specified set of dependencies and that dependencies are not carelessly | |
90 | inherited from other IPython subpackages. Furthermore, tests that have certain |
|
90 | inherited from other IPython subpackages. Furthermore, tests that have certain | |
91 | dependencies should not fail if those dependencies are not present. Instead |
|
91 | dependencies should not fail if those dependencies are not present. Instead | |
92 | they should be skipped and print a message. |
|
92 | they should be skipped and print a message. | |
93 |
|
93 | |||
94 | .. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools |
|
94 | .. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools | |
95 | .. _distutils: http://docs.python.org/lib/module-distutils.html |
|
95 | .. _distutils: http://docs.python.org/lib/module-distutils.html | |
96 | .. _Matplotlib: http://matplotlib.sourceforge.net/ |
|
96 | .. _Matplotlib: http://matplotlib.sourceforge.net/ | |
97 |
|
97 | |||
98 | Specific subpackages |
|
98 | Specific subpackages | |
99 | -------------------- |
|
99 | -------------------- | |
100 |
|
100 | |||
101 | ``core`` |
|
101 | ``core`` | |
102 | This is the core functionality of IPython that is independent of the |
|
102 | This is the core functionality of IPython that is independent of the | |
103 | terminal, network and GUIs. Most of the code that is in the current |
|
103 | terminal, network and GUIs. Most of the code that is in the current | |
104 | IPython trunk will be refactored, cleaned up and moved here. |
|
104 | IPython trunk will be refactored, cleaned up and moved here. | |
105 |
|
105 | |||
106 | ``kernel`` |
|
106 | ``kernel`` | |
107 | The enables the IPython core to be expose to a the network. This is |
|
107 | The enables the IPython core to be expose to a the network. This is | |
108 | also where all of the parallel computing capabilities are to be found. |
|
108 | also where all of the parallel computing capabilities are to be found. | |
109 |
|
109 | |||
110 | ``config`` |
|
110 | ``config`` | |
111 | The configuration package used by IPython. |
|
111 | The configuration package used by IPython. | |
112 |
|
112 | |||
113 | ``frontends`` |
|
113 | ``frontends`` | |
114 | The various frontends for IPython. A frontend is the end-user application |
|
114 | The various frontends for IPython. A frontend is the end-user application | |
115 | that exposes the capabilities of IPython to the user. The most basic |
|
115 | that exposes the capabilities of IPython to the user. The most basic | |
116 | frontend will simply be a terminal based application that looks just like |
|
116 | frontend will simply be a terminal based application that looks just like | |
117 | today 's IPython. Other frontends will likely be more powerful and based |
|
117 | today 's IPython. Other frontends will likely be more powerful and based | |
118 | on GUI toolkits. |
|
118 | on GUI toolkits. | |
119 |
|
119 | |||
120 | ``notebook`` |
|
120 | ``notebook`` | |
121 | An application that allows users to work with IPython notebooks. |
|
121 | An application that allows users to work with IPython notebooks. | |
122 |
|
122 | |||
123 | ``tools`` |
|
123 | ``tools`` | |
124 | This is where general utilities go. |
|
124 | This is where general utilities go. | |
125 |
|
125 | |||
126 |
|
126 | |||
127 | Version control |
|
127 | Version control | |
128 | =============== |
|
128 | =============== | |
129 |
|
129 | |||
130 | In the past, IPython development has been done using `Subversion`__. Recently, |
|
130 | In the past, IPython development has been done using `Subversion`__. Recently, | |
131 | we made the transition to using `Bazaar`__ and `Launchpad`__. This makes it |
|
131 | we made the transition to using `Bazaar`__ and `Launchpad`__. This makes it | |
132 | much easier for people to contribute code to IPython. Here is a sketch of how |
|
132 | much easier for people to contribute code to IPython. Here is a sketch of how | |
133 | to use Bazaar for IPython development. First, you should install Bazaar. |
|
133 | to use Bazaar for IPython development. First, you should install Bazaar. | |
134 | After you have done that, make sure that it is working by getting the latest |
|
134 | After you have done that, make sure that it is working by getting the latest | |
135 | main branch of IPython:: |
|
135 | main branch of IPython:: | |
136 |
|
136 | |||
137 | $ bzr branch lp:ipython |
|
137 | $ bzr branch lp:ipython | |
138 |
|
138 | |||
139 | Now you can create a new branch for you to do your work in:: |
|
139 | Now you can create a new branch for you to do your work in:: | |
140 |
|
140 | |||
141 | $ bzr branch ipython ipython-mybranch |
|
141 | $ bzr branch ipython ipython-mybranch | |
142 |
|
142 | |||
143 | The typical work cycle in this branch will be to make changes in |
|
143 | The typical work cycle in this branch will be to make changes in | |
144 | ``ipython-mybranch`` and then commit those changes using the commit command:: |
|
144 | ``ipython-mybranch`` and then commit those changes using the commit command:: | |
145 |
|
145 | |||
146 | $ ...do work in ipython-mybranch... |
|
146 | $ ...do work in ipython-mybranch... | |
147 | $ bzr ci -m "the commit message goes here" |
|
147 | $ bzr ci -m "the commit message goes here" | |
148 |
|
148 | |||
149 | Please note that since we now don't use an old-style linear ChangeLog (that |
|
149 | Please note that since we now don't use an old-style linear ChangeLog (that | |
150 | tends to cause problems with distributed version control systems), you should |
|
150 | tends to cause problems with distributed version control systems), you should | |
151 | ensure that your log messages are reasonably detailed. Use a docstring-like |
|
151 | ensure that your log messages are reasonably detailed. Use a docstring-like | |
152 | approach in the commit messages (including the second line being left |
|
152 | approach in the commit messages (including the second line being left | |
153 | *blank*):: |
|
153 | *blank*):: | |
154 |
|
154 | |||
155 | Single line summary of changes being committed. |
|
155 | Single line summary of changes being committed. | |
156 |
|
156 | |||
157 | - more details when warranted ... |
|
157 | - more details when warranted ... | |
158 | - including crediting outside contributors if they sent the |
|
158 | - including crediting outside contributors if they sent the | |
159 | code/bug/idea! |
|
159 | code/bug/idea! | |
160 |
|
160 | |||
161 | If we couple this with a policy of making single commits for each reasonably |
|
161 | If we couple this with a policy of making single commits for each reasonably | |
162 | atomic change, the bzr log should give an excellent view of the project, and |
|
162 | atomic change, the bzr log should give an excellent view of the project, and | |
163 | the `--short` log option becomes a nice summary. |
|
163 | the `--short` log option becomes a nice summary. | |
164 |
|
164 | |||
165 | While working with this branch, it is a good idea to merge in changes that have |
|
165 | While working with this branch, it is a good idea to merge in changes that have | |
166 | been made upstream in the parent branch. This can be done by doing:: |
|
166 | been made upstream in the parent branch. This can be done by doing:: | |
167 |
|
167 | |||
168 | $ bzr pull |
|
168 | $ bzr pull | |
169 |
|
169 | |||
170 | If this command shows that the branches have diverged, then you should do a |
|
170 | If this command shows that the branches have diverged, then you should do a | |
171 | merge instead:: |
|
171 | merge instead:: | |
172 |
|
172 | |||
173 | $ bzr merge lp:ipython |
|
173 | $ bzr merge lp:ipython | |
174 |
|
174 | |||
175 | If you want others to be able to see your branch, you can create an account |
|
175 | If you want others to be able to see your branch, you can create an account | |
176 | with launchpad and push the branch to your own workspace:: |
|
176 | with launchpad and push the branch to your own workspace:: | |
177 |
|
177 | |||
178 | $ bzr push bzr+ssh://<me>@bazaar.launchpad.net/~<me>/+junk/ipython-mybranch |
|
178 | $ bzr push bzr+ssh://<me>@bazaar.launchpad.net/~<me>/+junk/ipython-mybranch | |
179 |
|
179 | |||
180 | Finally, once the work in your branch is done, you can merge your changes back |
|
180 | Finally, once the work in your branch is done, you can merge your changes back | |
181 | into the `ipython` branch by using merge:: |
|
181 | into the `ipython` branch by using merge:: | |
182 |
|
182 | |||
183 | $ cd ipython |
|
183 | $ cd ipython | |
184 | $ merge ../ipython-mybranch |
|
184 | $ merge ../ipython-mybranch | |
185 | [resolve any conflicts] |
|
185 | [resolve any conflicts] | |
186 | $ bzr ci -m "Fixing that bug" |
|
186 | $ bzr ci -m "Fixing that bug" | |
187 | $ bzr push |
|
187 | $ bzr push | |
188 |
|
188 | |||
189 | But this will require you to have write permissions to the `ipython` branch. |
|
189 | But this will require you to have write permissions to the `ipython` branch. | |
190 | It you don't you can tell one of the IPython devs about your branch and they |
|
190 | It you don't you can tell one of the IPython devs about your branch and they | |
191 | can do the merge for you. |
|
191 | can do the merge for you. | |
192 |
|
192 | |||
193 | More information about Bazaar workflows can be found `here`__. |
|
193 | More information about Bazaar workflows can be found `here`__. | |
194 |
|
194 | |||
195 | .. __: http://subversion.tigris.org/ |
|
195 | .. __: http://subversion.tigris.org/ | |
196 | .. __: http://bazaar-vcs.org/ |
|
196 | .. __: http://bazaar-vcs.org/ | |
197 | .. __: http://www.launchpad.net/ipython |
|
197 | .. __: http://www.launchpad.net/ipython | |
198 | .. __: http://doc.bazaar-vcs.org/bzr.dev/en/user-guide/index.html |
|
198 | .. __: http://doc.bazaar-vcs.org/bzr.dev/en/user-guide/index.html | |
199 |
|
199 | |||
200 | Documentation |
|
200 | Documentation | |
201 | ============= |
|
201 | ============= | |
202 |
|
202 | |||
203 | Standalone documentation |
|
203 | Standalone documentation | |
204 | ------------------------ |
|
204 | ------------------------ | |
205 |
|
205 | |||
206 | All standalone documentation should be written in plain text (``.txt``) files |
|
206 | All standalone documentation should be written in plain text (``.txt``) files | |
207 | using `reStructuredText`_ for markup and formatting. All such documentation |
|
207 | using `reStructuredText`_ for markup and formatting. All such documentation | |
208 | should be placed in the top level directory ``docs`` of the IPython source |
|
208 | should be placed in the top level directory ``docs`` of the IPython source | |
209 | tree. Or, when appropriate, a suitably named subdirectory should be used. The |
|
209 | tree. Or, when appropriate, a suitably named subdirectory should be used. The | |
210 | documentation in this location will serve as the main source for IPython |
|
210 | documentation in this location will serve as the main source for IPython | |
211 | documentation and all existing documentation should be converted to this |
|
211 | documentation and all existing documentation should be converted to this | |
212 | format. |
|
212 | format. | |
213 |
|
213 | |||
214 | In the future, the text files in the ``docs`` directory will be used to |
|
214 | In the future, the text files in the ``docs`` directory will be used to | |
215 | generate all forms of documentation for IPython. This include documentation on |
|
215 | generate all forms of documentation for IPython. This include documentation on | |
216 | the IPython website as well as *pdf* documentation. |
|
216 | the IPython website as well as *pdf* documentation. | |
217 |
|
217 | |||
218 | .. _reStructuredText: http://docutils.sourceforge.net/rst.html |
|
218 | .. _reStructuredText: http://docutils.sourceforge.net/rst.html | |
219 |
|
219 | |||
220 | Docstring format |
|
220 | Docstring format | |
221 | ---------------- |
|
221 | ---------------- | |
222 |
|
222 | |||
223 | Good docstrings are very important. All new code will use `Epydoc`_ for |
|
223 | Good docstrings are very important. All new code will use `Epydoc`_ for | |
224 | generating API docs, so we will follow the `Epydoc`_ conventions. More |
|
224 | generating API docs, so we will follow the `Epydoc`_ conventions. More | |
225 | specifically, we will use `reStructuredText`_ for markup and formatting, since |
|
225 | specifically, we will use `reStructuredText`_ for markup and formatting, since | |
226 | it is understood by a wide variety of tools. This means that if in the future |
|
226 | it is understood by a wide variety of tools. This means that if in the future | |
227 | we have any reason to change from `Epydoc`_ to something else, we'll have fewer |
|
227 | we have any reason to change from `Epydoc`_ to something else, we'll have fewer | |
228 | transition pains. |
|
228 | transition pains. | |
229 |
|
229 | |||
230 | Details about using `reStructuredText`_ for docstrings can be found `here |
|
230 | Details about using `reStructuredText`_ for docstrings can be found `here | |
231 | <http://epydoc.sourceforge.net/manual-othermarkup.html>`_. |
|
231 | <http://epydoc.sourceforge.net/manual-othermarkup.html>`_. | |
232 |
|
232 | |||
233 | .. _Epydoc: http://epydoc.sourceforge.net/ |
|
233 | .. _Epydoc: http://epydoc.sourceforge.net/ | |
234 |
|
234 | |||
235 | Additional PEPs of interest regarding documentation of code: |
|
235 | Additional PEPs of interest regarding documentation of code: | |
236 |
|
236 | |||
237 | - `Docstring Conventions <http://www.python.org/peps/pep-0257.html>`_ |
|
237 | - `Docstring Conventions <http://www.python.org/peps/pep-0257.html>`_ | |
238 | - `Docstring Processing System Framework <http://www.python.org/peps/pep-0256.html>`_ |
|
238 | - `Docstring Processing System Framework <http://www.python.org/peps/pep-0256.html>`_ | |
239 | - `Docutils Design Specification <http://www.python.org/peps/pep-0258.html>`_ |
|
239 | - `Docutils Design Specification <http://www.python.org/peps/pep-0258.html>`_ | |
240 |
|
240 | |||
241 |
|
241 | |||
242 | Coding conventions |
|
242 | Coding conventions | |
243 | ================== |
|
243 | ================== | |
244 |
|
244 | |||
245 | General |
|
245 | General | |
246 | ------- |
|
246 | ------- | |
247 |
|
247 | |||
248 | In general, we'll try to follow the standard Python style conventions as |
|
248 | In general, we'll try to follow the standard Python style conventions as | |
249 | described here: |
|
249 | described here: | |
250 |
|
250 | |||
251 | - `Style Guide for Python Code <http://www.python.org/peps/pep-0008.html>`_ |
|
251 | - `Style Guide for Python Code <http://www.python.org/peps/pep-0008.html>`_ | |
252 |
|
252 | |||
253 |
|
253 | |||
254 | Other comments: |
|
254 | Other comments: | |
255 |
|
255 | |||
256 | - In a large file, top level classes and functions should be |
|
256 | - In a large file, top level classes and functions should be | |
257 | separated by 2-3 lines to make it easier to separate them visually. |
|
257 | separated by 2-3 lines to make it easier to separate them visually. | |
258 | - Use 4 spaces for indentation. |
|
258 | - Use 4 spaces for indentation. | |
259 | - Keep the ordering of methods the same in classes that have the same |
|
259 | - Keep the ordering of methods the same in classes that have the same | |
260 | methods. This is particularly true for classes that implement |
|
260 | methods. This is particularly true for classes that implement | |
261 | similar interfaces and for interfaces that are similar. |
|
261 | similar interfaces and for interfaces that are similar. | |
262 |
|
262 | |||
263 | Naming conventions |
|
263 | Naming conventions | |
264 | ------------------ |
|
264 | ------------------ | |
265 |
|
265 | |||
266 | In terms of naming conventions, we'll follow the guidelines from the `Style |
|
266 | In terms of naming conventions, we'll follow the guidelines from the `Style | |
267 | Guide for Python Code`_. |
|
267 | Guide for Python Code`_. | |
268 |
|
268 | |||
269 | For all new IPython code (and much existing code is being refactored), we'll use: |
|
269 | For all new IPython code (and much existing code is being refactored), we'll use: | |
270 |
|
270 | |||
271 | - All ``lowercase`` module names. |
|
271 | - All ``lowercase`` module names. | |
272 |
|
272 | |||
273 | - ``CamelCase`` for class names. |
|
273 | - ``CamelCase`` for class names. | |
274 |
|
274 | |||
275 | - ``lowercase_with_underscores`` for methods, functions, variables and |
|
275 | - ``lowercase_with_underscores`` for methods, functions, variables and | |
276 | attributes. |
|
276 | attributes. | |
277 |
|
277 | |||
278 | This may be confusing as most of the existing IPython codebase uses a different |
|
278 | This may be confusing as most of the existing IPython codebase uses a different | |
279 | convention (``lowerCamelCase`` for methods and attributes). Slowly, we will |
|
279 | convention (``lowerCamelCase`` for methods and attributes). Slowly, we will | |
280 | move IPython over to the new convention, providing shadow names for backward |
|
280 | move IPython over to the new convention, providing shadow names for backward | |
281 | compatibility in public interfaces. |
|
281 | compatibility in public interfaces. | |
282 |
|
282 | |||
283 | There are, however, some important exceptions to these rules. In some cases, |
|
283 | There are, however, some important exceptions to these rules. In some cases, | |
284 | IPython code will interface with packages (Twisted, Wx, Qt) that use other |
|
284 | IPython code will interface with packages (Twisted, Wx, Qt) that use other | |
285 | conventions. At some level this makes it impossible to adhere to our own |
|
285 | conventions. At some level this makes it impossible to adhere to our own | |
286 | standards at all times. In particular, when subclassing classes that use other |
|
286 | standards at all times. In particular, when subclassing classes that use other | |
287 | naming conventions, you must follow their naming conventions. To deal with |
|
287 | naming conventions, you must follow their naming conventions. To deal with | |
288 | cases like this, we propose the following policy: |
|
288 | cases like this, we propose the following policy: | |
289 |
|
289 | |||
290 | - If you are subclassing a class that uses different conventions, use its |
|
290 | - If you are subclassing a class that uses different conventions, use its | |
291 | naming conventions throughout your subclass. Thus, if you are creating a |
|
291 | naming conventions throughout your subclass. Thus, if you are creating a | |
292 | Twisted Protocol class, used Twisted's |
|
292 | Twisted Protocol class, used Twisted's | |
293 | ``namingSchemeForMethodsAndAttributes.`` |
|
293 | ``namingSchemeForMethodsAndAttributes.`` | |
294 |
|
294 | |||
295 | - All IPython's official interfaces should use our conventions. In some cases |
|
295 | - All IPython's official interfaces should use our conventions. In some cases | |
296 | this will mean that you need to provide shadow names (first implement |
|
296 | this will mean that you need to provide shadow names (first implement | |
297 | ``fooBar`` and then ``foo_bar = fooBar``). We want to avoid this at all |
|
297 | ``fooBar`` and then ``foo_bar = fooBar``). We want to avoid this at all | |
298 | costs, but it will probably be necessary at times. But, please use this |
|
298 | costs, but it will probably be necessary at times. But, please use this | |
299 | sparingly! |
|
299 | sparingly! | |
300 |
|
300 | |||
301 | Implementation-specific *private* methods will use |
|
301 | Implementation-specific *private* methods will use | |
302 | ``_single_underscore_prefix``. Names with a leading double underscore will |
|
302 | ``_single_underscore_prefix``. Names with a leading double underscore will | |
303 | *only* be used in special cases, as they makes subclassing difficult (such |
|
303 | *only* be used in special cases, as they makes subclassing difficult (such | |
304 | names are not easily seen by child classes). |
|
304 | names are not easily seen by child classes). | |
305 |
|
305 | |||
306 | Occasionally some run-in lowercase names are used, but mostly for very short |
|
306 | Occasionally some run-in lowercase names are used, but mostly for very short | |
307 | names or where we are implementing methods very similar to existing ones in a |
|
307 | names or where we are implementing methods very similar to existing ones in a | |
308 | base class (like ``runlines()`` where ``runsource()`` and ``runcode()`` had |
|
308 | base class (like ``runlines()`` where ``runsource()`` and ``runcode()`` had | |
309 | established precedent). |
|
309 | established precedent). | |
310 |
|
310 | |||
311 | The old IPython codebase has a big mix of classes and modules prefixed with an |
|
311 | The old IPython codebase has a big mix of classes and modules prefixed with an | |
312 | explicit ``IP``. In Python this is mostly unnecessary, redundant and frowned |
|
312 | explicit ``IP``. In Python this is mostly unnecessary, redundant and frowned | |
313 | upon, as namespaces offer cleaner prefixing. The only case where this approach |
|
313 | upon, as namespaces offer cleaner prefixing. The only case where this approach | |
314 | is justified is for classes which are expected to be imported into external |
|
314 | is justified is for classes which are expected to be imported into external | |
315 | namespaces and a very generic name (like Shell) is too likely to clash with |
|
315 | namespaces and a very generic name (like Shell) is too likely to clash with | |
316 | something else. We'll need to revisit this issue as we clean up and refactor |
|
316 | something else. We'll need to revisit this issue as we clean up and refactor | |
317 | the code, but in general we should remove as many unnecessary ``IP``/``ip`` |
|
317 | the code, but in general we should remove as many unnecessary ``IP``/``ip`` | |
318 | prefixes as possible. However, if a prefix seems absolutely necessary the more |
|
318 | prefixes as possible. However, if a prefix seems absolutely necessary the more | |
319 | specific ``IPY`` or ``ipy`` are preferred. |
|
319 | specific ``IPY`` or ``ipy`` are preferred. | |
320 |
|
320 | |||
321 | .. _devel_testing: |
|
321 | .. _devel_testing: | |
322 |
|
322 | |||
323 | Testing system |
|
323 | Testing system | |
324 | ============== |
|
324 | ============== | |
325 |
|
325 | |||
326 | It is extremely important that all code contributed to IPython has tests. Tests |
|
326 | It is extremely important that all code contributed to IPython has tests. Tests | |
327 | should be written as unittests, doctests or as entities that the `Nose`_ |
|
327 | should be written as unittests, doctests or as entities that the `Nose`_ | |
328 | testing package will find. Regardless of how the tests are written, we will use |
|
328 | testing package will find. Regardless of how the tests are written, we will use | |
329 | `Nose`_ for discovering and running the tests. `Nose`_ will be required to run |
|
329 | `Nose`_ for discovering and running the tests. `Nose`_ will be required to run | |
330 | the IPython test suite, but will not be required to simply use IPython. |
|
330 | the IPython test suite, but will not be required to simply use IPython. | |
331 |
|
331 | |||
332 | .. _Nose: http://code.google.com/p/python-nose/ |
|
332 | .. _Nose: http://code.google.com/p/python-nose/ | |
333 |
|
333 | |||
334 | Tests of `Twisted`__ using code should be written by subclassing the |
|
334 | Tests of `Twisted`__ using code should be written by subclassing the | |
335 | ``TestCase`` class that comes with ``twisted.trial.unittest``. When this is |
|
335 | ``TestCase`` class that comes with ``twisted.trial.unittest``. When this is | |
336 | done, `Nose`_ will be able to run the tests and the twisted reactor will be |
|
336 | done, `Nose`_ will be able to run the tests and the twisted reactor will be | |
337 | handled correctly. |
|
337 | handled correctly. | |
338 |
|
338 | |||
339 | .. __: http://www.twistedmatrix.com |
|
339 | .. __: http://www.twistedmatrix.com | |
340 |
|
340 | |||
341 | Each subpackage in IPython should have its own ``tests`` directory that |
|
341 | Each subpackage in IPython should have its own ``tests`` directory that | |
342 | contains all of the tests for that subpackage. This allows each subpackage to |
|
342 | contains all of the tests for that subpackage. This allows each subpackage to | |
343 | be self-contained. If a subpackage has any dependencies beyond the Python |
|
343 | be self-contained. If a subpackage has any dependencies beyond the Python | |
344 | standard library, the tests for that subpackage should be skipped if the |
|
344 | standard library, the tests for that subpackage should be skipped if the | |
345 | dependencies are not found. This is very important so users don't get tests |
|
345 | dependencies are not found. This is very important so users don't get tests | |
346 | failing simply because they don't have dependencies. |
|
346 | failing simply because they don't have dependencies. | |
347 |
|
347 | |||
348 | We also need to look into use Noses ability to tag tests to allow a more |
|
348 | We also need to look into use Noses ability to tag tests to allow a more | |
349 | modular approach of running tests. |
|
349 | modular approach of running tests. | |
350 |
|
350 | |||
351 | .. _devel_config: |
|
351 | .. _devel_config: | |
352 |
|
352 | |||
353 | Configuration system |
|
353 | Configuration system | |
354 | ==================== |
|
354 | ==================== | |
355 |
|
355 | |||
356 | IPython uses `.ini`_ files for configuration purposes. This represents a huge |
|
356 | IPython uses `.ini`_ files for configuration purposes. This represents a huge | |
357 | improvement over the configuration system used in IPython. IPython works with |
|
357 | improvement over the configuration system used in IPython. IPython works with | |
358 | these files using the `ConfigObj`_ package, which IPython includes as |
|
358 | these files using the `ConfigObj`_ package, which IPython includes as | |
359 | ``ipython1/external/configobj.py``. |
|
359 | ``ipython1/external/configobj.py``. | |
360 |
|
360 | |||
361 | Currently, we are using raw `ConfigObj`_ objects themselves. Each subpackage of |
|
361 | Currently, we are using raw `ConfigObj`_ objects themselves. Each subpackage of | |
362 | IPython should contain a ``config`` subdirectory that contains all of the |
|
362 | IPython should contain a ``config`` subdirectory that contains all of the | |
363 | configuration information for the subpackage. To see how configuration |
|
363 | configuration information for the subpackage. To see how configuration | |
364 | information is defined (along with defaults) see at the examples in |
|
364 | information is defined (along with defaults) see at the examples in | |
365 | ``ipython1/kernel/config`` and ``ipython1/core/config``. Likewise, to see how |
|
365 | ``ipython1/kernel/config`` and ``ipython1/core/config``. Likewise, to see how | |
366 | the configuration information is used, see examples in |
|
366 | the configuration information is used, see examples in | |
367 | ``ipython1/kernel/scripts/ipengine.py``. |
|
367 | ``ipython1/kernel/scripts/ipengine.py``. | |
368 |
|
368 | |||
369 | Eventually, we will add a new layer on top of the raw `ConfigObj`_ objects. We |
|
369 | Eventually, we will add a new layer on top of the raw `ConfigObj`_ objects. We | |
370 | are calling this new layer, ``tconfig``, as it will use a `Traits`_-like |
|
370 | are calling this new layer, ``tconfig``, as it will use a `Traits`_-like | |
371 | validation model. We won't actually use `Traits`_, but will implement |
|
371 | validation model. We won't actually use `Traits`_, but will implement | |
372 | something similar in pure Python. But, even in this new system, we will still |
|
372 | something similar in pure Python. But, even in this new system, we will still | |
373 | use `ConfigObj`_ and `.ini`_ files underneath the hood. Talk to Fernando if you |
|
373 | use `ConfigObj`_ and `.ini`_ files underneath the hood. Talk to Fernando if you | |
374 | are interested in working on this part of IPython. The current prototype of |
|
374 | are interested in working on this part of IPython. The current prototype of | |
375 | ``tconfig`` is located in the IPython sandbox. |
|
375 | ``tconfig`` is located in the IPython sandbox. | |
376 |
|
376 | |||
377 | .. _.ini: http://docs.python.org/lib/module-ConfigParser.html |
|
377 | .. _.ini: http://docs.python.org/lib/module-ConfigParser.html | |
378 | .. _ConfigObj: http://www.voidspace.org.uk/python/configobj.html |
|
378 | .. _ConfigObj: http://www.voidspace.org.uk/python/configobj.html | |
379 | .. _Traits: http://code.enthought.com/traits/ |
|
379 | .. _Traits: http://code.enthought.com/traits/ | |
380 |
|
380 | |||
381 |
|
381 | |||
382 | Installation and testing scenarios |
|
382 | Installation and testing scenarios | |
383 | ================================== |
|
383 | ================================== | |
384 |
|
384 | |||
385 | This section outlines the various scenarios that we need to test before we |
|
385 | This section outlines the various scenarios that we need to test before we | |
386 | release an IPython version. These scenarios represent different ways of |
|
386 | release an IPython version. These scenarios represent different ways of | |
387 | installing IPython and its dependencies. |
|
387 | installing IPython and its dependencies. | |
388 |
|
388 | |||
389 | Installation scenarios under Linux and OS X |
|
389 | Installation scenarios under Linux and OS X | |
390 | ------------------------------------------- |
|
390 | ------------------------------------------- | |
391 |
|
391 | |||
392 | 1. Install from tarball using ``python setup.py install``. |
|
392 | 1. Install from tarball using ``python setup.py install``. | |
393 | a. With only readline+nose dependencies installed. |
|
393 | a. With only readline+nose dependencies installed. | |
394 | b. With all dependencies installed (readline, zope.interface, Twisted, |
|
394 | b. With all dependencies installed (readline, zope.interface, Twisted, | |
395 | foolscap, Sphinx, nose, pyOpenSSL). |
|
395 | foolscap, Sphinx, nose, pyOpenSSL). | |
396 |
|
396 | |||
397 | 2. Install using easy_install. |
|
397 | 2. Install using easy_install. | |
398 |
|
398 | |||
399 | a. With only readline+nose dependencies installed. |
|
399 | a. With only readline+nose dependencies installed. | |
400 | i. Default dependencies: ``easy_install ipython-0.9.beta3-py2.5.egg`` |
|
400 | i. Default dependencies: ``easy_install ipython-0.9.beta3-py2.5.egg`` | |
401 | ii. Optional dependency sets: ``easy_install -f ipython-0.9.beta3-py2.5.egg IPython[kernel,doc,test,security]`` |
|
401 | ii. Optional dependency sets: ``easy_install -f ipython-0.9.beta3-py2.5.egg IPython[kernel,doc,test,security]`` | |
402 |
|
402 | |||
403 | b. With all dependencies already installed. |
|
403 | b. With all dependencies already installed. | |
404 |
|
404 | |||
405 |
|
405 | |||
406 | Installation scenarios under Win32 |
|
406 | Installation scenarios under Win32 | |
407 | ---------------------------------- |
|
407 | ---------------------------------- | |
408 |
|
408 | |||
409 | 1. Install everything from .exe installers |
|
409 | 1. Install everything from .exe installers | |
410 | 2. easy_install? |
|
410 | 2. easy_install? | |
411 |
|
411 | |||
412 |
|
412 | |||
413 | Tests to run for these scenarios |
|
413 | Tests to run for these scenarios | |
414 | -------------------------------- |
|
414 | -------------------------------- | |
415 |
|
415 | |||
416 | 1. Run the full test suite. |
|
416 | 1. Run the full test suite. | |
417 | 2. Start a controller and engines and try a few things by hand. |
|
417 | 2. Start a controller and engines and try a few things by hand. | |
418 | a. Using ipcluster. |
|
418 | a. Using ipcluster. | |
419 | b. Using ipcontroller/ipengine by hand. |
|
419 | b. Using ipcontroller/ipengine by hand. | |
420 |
|
420 | |||
421 | 3. Run a few of the parallel examples. |
|
421 | 3. Run a few of the parallel examples. | |
422 | 4. Try the kernel with and without security with and without PyOpenSSL |
|
422 | 4. Try the kernel with and without security with and without PyOpenSSL | |
423 | installed. |
|
423 | installed. | |
424 | 5. Beat on the IPython terminal a bunch. |
|
424 | 5. Beat on the IPython terminal a bunch. | |
425 | 6. Make sure that furl files are being put in proper locations. |
|
425 | 6. Make sure that furl files are being put in proper locations. | |
426 |
|
426 | |||
427 |
|
427 | |||
428 | Release checklist |
|
428 | Release checklist | |
429 | ================= |
|
429 | ================= | |
430 |
|
430 | |||
431 | Most of the release process is automated by the :file:`release` script in the |
|
431 | Most of the release process is automated by the :file:`release` script in the | |
432 | :file:`tools` directory. This is just a handy reminder for the release manager. |
|
432 | :file:`tools` directory. This is just a handy reminder for the release manager. | |
433 |
|
433 | |||
434 | #. Run the release script, which makes the tar.gz, eggs and Win32 .exe |
|
434 | #. Run the release script, which makes the tar.gz, eggs and Win32 .exe | |
435 | installer. It posts them to the site and registers the release with PyPI. |
|
435 | installer. It posts them to the site and registers the release with PyPI. | |
436 |
|
436 | |||
437 | #. Updating the website with announcements and links to the updated changes.txt |
|
437 | #. Updating the website with announcements and links to the updated changes.txt | |
438 | in html form. Remember to put a short note both on the news page of the site |
|
438 | in html form. Remember to put a short note both on the news page of the site | |
439 | and on launcphad. |
|
439 | and on launcphad. | |
440 |
|
440 | |||
441 | #. Drafting a short release announcement with i) highlights and ii) a link to |
|
441 | #. Drafting a short release announcement with i) highlights and ii) a link to | |
442 | the html changes.txt. |
|
442 | the html changes.txt. | |
443 |
|
443 | |||
444 | #. Make sure that the released version of the docs is live on the site. |
|
444 | #. Make sure that the released version of the docs is live on the site. | |
445 |
|
445 | |||
446 | #. Celebrate! |
|
446 | #. Celebrate! | |
|
447 | ||||
|
448 | ||||
|
449 | Porting to 3.0 | |||
|
450 | ============== | |||
|
451 | There are no definite plans for porting of IPython to python 3. The major | |||
|
452 | issue is the dependency on twisted framework for the networking/threading | |||
|
453 | stuff. It is possible that it the traditional IPython interactive console | |||
|
454 | could be ported more easily since it has no such dependency. Here are a few | |||
|
455 | things that will need to be considered when doing such a port especially | |||
|
456 | if we want to have a codebase that works directly on both 2.x and 3.x. | |||
|
457 | ||||
|
458 | 1. The syntax for exceptions changed (PEP 3110). The old | |||
|
459 | `except exc, var` changed to `except exc as var`. At last | |||
|
460 | count there was 78 occurences of this usage in the codebase | |||
|
461 |
General Comments 0
You need to be logged in to leave comments.
Login now