42
IPython is organized into semi self-contained subpackages. Each of the subpackages will have its own:
42
IPython is organized into semi self-contained subpackages. Each of the
43
subpackages will have its own:
44
45
- **Dependencies**. One of the most important things to keep in mind in
45
46
partitioning code amongst subpackages, is that they should be used to cleanly
46
encapsulate dependencies.
47
encapsulate dependencies.
47
49
- **Tests**. Each subpackage shoud have its own ``tests`` subdirectory that
48
contains all of the tests for that package. For information about writing tests
49
for IPython, see the `Testing System`_ section of this document.
50
- **Configuration**. Each subpackage should have its own ``config`` subdirectory
51
that contains the configuration information for the components of the
52
subpackage. For information about how the IPython configuration system
53
works, see the `Configuration System`_ section of this document.
54
- **Scripts**. Each subpackage should have its own ``scripts`` subdirectory that
55
contains all of the command line scripts associated with the subpackage.
50
contains all of the tests for that package. For information about writing
51
tests for IPython, see the `Testing System`_ section of this document.
53
- **Configuration**. Each subpackage should have its own ``config``
54
subdirectory that contains the configuration information for the components
55
of the subpackage. For information about how the IPython configuration
56
system works, see the `Configuration System`_ section of this document.
58
- **Scripts**. Each subpackage should have its own ``scripts`` subdirectory
59
that contains all of the command line scripts associated with the subpackage.
57
61
Installation and dependencies
58
62
-----------------------------
60
IPython will not use `setuptools`_ for installation. Instead, we will use standard
61
``setup.py`` scripts that use `distutils`_. While there are a number a extremely nice
62
features that `setuptools`_ has (like namespace packages), the current implementation
63
of `setuptools`_ has performance problems, particularly on shared file systems. In
64
particular, when Python packages are installed on NSF file systems, import times
65
become much too long (up towards 10 seconds).
64
IPython will not use `setuptools`_ for installation. Instead, we will use
65
standard ``setup.py`` scripts that use `distutils`_. While there are a number a
66
extremely nice features that `setuptools`_ has (like namespace packages), the
67
current implementation of `setuptools`_ has performance problems, particularly
68
on shared file systems. In particular, when Python packages are installed on
69
NSF file systems, import times become much too long (up towards 10 seconds).
67
71
Because IPython is being used extensively in the context of high performance
68
computing, where performance is critical but shared file systems are common, we feel
69
these performance hits are not acceptable. Thus, until the performance problems
70
associated with `setuptools`_ are addressed, we will stick with plain `distutils`_. We
71
are hopeful that these problems will be addressed and that we will eventually begin
72
using `setuptools`_. Because of this, we are trying to organize IPython in a way that
73
will make the eventual transition to `setuptools`_ as painless as possible.
72
computing, where performance is critical but shared file systems are common, we
73
feel these performance hits are not acceptable. Thus, until the performance
74
problems associated with `setuptools`_ are addressed, we will stick with plain
75
`distutils`_. We are hopeful that these problems will be addressed and that we
76
will eventually begin using `setuptools`_. Because of this, we are trying to
77
organize IPython in a way that will make the eventual transition to
78
`setuptools`_ as painless as possible.
75
Because we will be using `distutils`_, there will be no method for automatically installing dependencies. Instead, we are following the approach of `Matplotlib`_ which can be summarized as follows:
80
Because we will be using `distutils`_, there will be no method for
81
automatically installing dependencies. Instead, we are following the approach
82
of `Matplotlib`_ which can be summarized as follows:
77
84
- Distinguish between required and optional dependencies. However, the required
78
85
dependencies for IPython should be only the Python standard library.
79
- Upon installation check to see which optional dependencies are present and tell
80
the user which parts of IPython need which optional dependencies.
87
- Upon installation check to see which optional dependencies are present and
88
tell the user which parts of IPython need which optional dependencies.
82
It is absolutely critical that each subpackage of IPython has a clearly specified set
83
of dependencies and that dependencies are not carelessly inherited from other IPython
84
subpackages. Furthermore, tests that have certain dependencies should not fail if
85
those dependencies are not present. Instead they should be skipped and print a
90
It is absolutely critical that each subpackage of IPython has a clearly
91
specified set of dependencies and that dependencies are not carelessly
92
inherited from other IPython subpackages. Furthermore, tests that have certain
93
dependencies should not fail if those dependencies are not present. Instead
94
they should be skipped and print a message.
88
96
.. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools
89
97
.. _distutils: http://docs.python.org/lib/module-distutils.html
149
160
- including crediting outside contributors if they sent the
152
If we couple this with a policy of making single commits for each
153
reasonably atomic change, the bzr log should give an excellent view of
154
the project, and the `--short` log option becomes a nice summary.
163
If we couple this with a policy of making single commits for each reasonably
164
atomic change, the bzr log should give an excellent view of the project, and
165
the `--short` log option becomes a nice summary.
156
While working with this branch, it is a good idea to merge in changes that have been
157
made upstream in the parent branch. This can be done by doing::
167
While working with this branch, it is a good idea to merge in changes that have
168
been made upstream in the parent branch. This can be done by doing::
161
If this command shows that the branches have diverged, then you should do a merge
172
If this command shows that the branches have diverged, then you should do a
164
175
$ bzr merge lp:ipython
166
If you want others to be able to see your branch, you can create an account with
167
launchpad and push the branch to your own workspace::
177
If you want others to be able to see your branch, you can create an account
178
with launchpad and push the branch to your own workspace::
169
180
$ bzr push bzr+ssh://<me>@bazaar.launchpad.net/~<me>/+junk/ipython-mybranch
171
Finally, once the work in your branch is done, you can merge your changes back into
172
the `ipython` branch by using merge::
182
Finally, once the work in your branch is done, you can merge your changes back
183
into the `ipython` branch by using merge::
175
186
$ merge ../ipython-mybranch
193
205
Standalone documentation
194
206
------------------------
196
All standalone documentation should be written in plain text (``.txt``) files using
197
`reStructuredText`_ for markup and formatting. All such documentation should be placed
198
in the top level directory ``docs`` of the IPython source tree. Or, when appropriate,
199
a suitably named subdirectory should be used. The documentation in this location will
200
serve as the main source for IPython documentation and all existing documentation
201
should be converted to this format.
208
All standalone documentation should be written in plain text (``.txt``) files
209
using `reStructuredText`_ for markup and formatting. All such documentation
210
should be placed in the top level directory ``docs`` of the IPython source
211
tree. Or, when appropriate, a suitably named subdirectory should be used. The
212
documentation in this location will serve as the main source for IPython
213
documentation and all existing documentation should be converted to this
203
In the future, the text files in the ``docs`` directory will be used to generate all
204
forms of documentation for IPython. This include documentation on the IPython website
205
as well as *pdf* documentation.
216
In the future, the text files in the ``docs`` directory will be used to
217
generate all forms of documentation for IPython. This include documentation on
218
the IPython website as well as *pdf* documentation.
207
220
.. _reStructuredText: http://docutils.sourceforge.net/rst.html
212
Good docstrings are very important. All new code will use `Epydoc`_ for generating API
213
docs, so we will follow the `Epydoc`_ conventions. More specifically, we will use
214
`reStructuredText`_ for markup and formatting, since it is understood by a wide
215
variety of tools. This means that if in the future we have any reason to change from
216
`Epydoc`_ to something else, we'll have fewer transition pains.
225
Good docstrings are very important. All new code will use `Epydoc`_ for
226
generating API docs, so we will follow the `Epydoc`_ conventions. More
227
specifically, we will use `reStructuredText`_ for markup and formatting, since
228
it is understood by a wide variety of tools. This means that if in the future
229
we have any reason to change from `Epydoc`_ to something else, we'll have fewer
218
232
Details about using `reStructuredText`_ for docstrings can be found `here
219
233
<http://epydoc.sourceforge.net/manual-othermarkup.html>`_.
260
275
- ``CamelCase`` for class names.
262
- ``lowercase_with_underscores`` for methods, functions, variables and attributes.
264
This may be confusing as most of the existing IPython codebase uses a different convention (``lowerCamelCase`` for methods and attributes). Slowly, we will move IPython over to the new
265
convention, providing shadow names for backward compatibility in public interfaces.
267
There are, however, some important exceptions to these rules. In some cases, IPython
268
code will interface with packages (Twisted, Wx, Qt) that use other conventions. At some level this makes it impossible to adhere to our own standards at all times. In particular, when subclassing classes that use other naming conventions, you must follow their naming conventions. To deal with cases like this, we propose the following policy:
277
- ``lowercase_with_underscores`` for methods, functions, variables and
280
This may be confusing as most of the existing IPython codebase uses a different
281
convention (``lowerCamelCase`` for methods and attributes). Slowly, we will
282
move IPython over to the new convention, providing shadow names for backward
283
compatibility in public interfaces.
285
There are, however, some important exceptions to these rules. In some cases,
286
IPython code will interface with packages (Twisted, Wx, Qt) that use other
287
conventions. At some level this makes it impossible to adhere to our own
288
standards at all times. In particular, when subclassing classes that use other
289
naming conventions, you must follow their naming conventions. To deal with
290
cases like this, we propose the following policy:
270
292
- If you are subclassing a class that uses different conventions, use its
271
naming conventions throughout your subclass. Thus, if you are creating a
272
Twisted Protocol class, used Twisted's ``namingSchemeForMethodsAndAttributes.``
274
- All IPython's official interfaces should use our conventions. In some cases
275
this will mean that you need to provide shadow names (first implement ``fooBar``
276
and then ``foo_bar = fooBar``). We want to avoid this at all costs, but it
277
will probably be necessary at times. But, please use this sparingly!
279
Implementation-specific *private* methods will use ``_single_underscore_prefix``.
280
Names with a leading double underscore will *only* be used in special cases, as they
281
makes subclassing difficult (such names are not easily seen by child classes).
283
Occasionally some run-in lowercase names are used, but mostly for very short names or
284
where we are implementing methods very similar to existing ones in a base class (like
285
``runlines()`` where ``runsource()`` and ``runcode()`` had established precedent).
293
naming conventions throughout your subclass. Thus, if you are creating a
294
Twisted Protocol class, used Twisted's
295
``namingSchemeForMethodsAndAttributes.``
297
- All IPython's official interfaces should use our conventions. In some cases
298
this will mean that you need to provide shadow names (first implement
299
``fooBar`` and then ``foo_bar = fooBar``). We want to avoid this at all
300
costs, but it will probably be necessary at times. But, please use this
303
Implementation-specific *private* methods will use
304
``_single_underscore_prefix``. Names with a leading double underscore will
305
*only* be used in special cases, as they makes subclassing difficult (such
306
names are not easily seen by child classes).
308
Occasionally some run-in lowercase names are used, but mostly for very short
309
names or where we are implementing methods very similar to existing ones in a
310
base class (like ``runlines()`` where ``runsource()`` and ``runcode()`` had
311
established precedent).
287
313
The old IPython codebase has a big mix of classes and modules prefixed with an
288
explicit ``IP``. In Python this is mostly unnecessary, redundant and frowned upon, as
289
namespaces offer cleaner prefixing. The only case where this approach is justified is
290
for classes which are expected to be imported into external namespaces and a very
291
generic name (like Shell) is too likely to clash with something else. We'll need to
292
revisit this issue as we clean up and refactor the code, but in general we should
293
remove as many unnecessary ``IP``/``ip`` prefixes as possible. However, if a prefix
294
seems absolutely necessary the more specific ``IPY`` or ``ipy`` are preferred.
314
explicit ``IP``. In Python this is mostly unnecessary, redundant and frowned
315
upon, as namespaces offer cleaner prefixing. The only case where this approach
316
is justified is for classes which are expected to be imported into external
317
namespaces and a very generic name (like Shell) is too likely to clash with
318
something else. We'll need to revisit this issue as we clean up and refactor
319
the code, but in general we should remove as many unnecessary ``IP``/``ip``
320
prefixes as possible. However, if a prefix seems absolutely necessary the more
321
specific ``IPY`` or ``ipy`` are preferred.
296
323
.. _devel_testing:
301
It is extremely important that all code contributed to IPython has tests. Tests should
302
be written as unittests, doctests or as entities that the `Nose`_ testing package will
303
find. Regardless of how the tests are written, we will use `Nose`_ for discovering and
304
running the tests. `Nose`_ will be required to run the IPython test suite, but will
305
not be required to simply use IPython.
328
It is extremely important that all code contributed to IPython has tests. Tests
329
should be written as unittests, doctests or as entities that the `Nose`_
330
testing package will find. Regardless of how the tests are written, we will use
331
`Nose`_ for discovering and running the tests. `Nose`_ will be required to run
332
the IPython test suite, but will not be required to simply use IPython.
307
334
.. _Nose: http://code.google.com/p/python-nose/
309
Tests of `Twisted`__ using code should be written by subclassing the ``TestCase`` class
310
that comes with ``twisted.trial.unittest``. When this is done, `Nose`_ will be able to
311
run the tests and the twisted reactor will be handled correctly.
336
Tests of `Twisted`__ using code should be written by subclassing the
337
``TestCase`` class that comes with ``twisted.trial.unittest``. When this is
338
done, `Nose`_ will be able to run the tests and the twisted reactor will be
313
341
.. __: http://www.twistedmatrix.com
315
Each subpackage in IPython should have its own ``tests`` directory that contains all
316
of the tests for that subpackage. This allows each subpackage to be self-contained. If
317
a subpackage has any dependencies beyond the Python standard library, the tests for
318
that subpackage should be skipped if the dependencies are not found. This is very
319
important so users don't get tests failing simply because they don't have dependencies.
343
Each subpackage in IPython should have its own ``tests`` directory that
344
contains all of the tests for that subpackage. This allows each subpackage to
345
be self-contained. If a subpackage has any dependencies beyond the Python
346
standard library, the tests for that subpackage should be skipped if the
347
dependencies are not found. This is very important so users don't get tests
348
failing simply because they don't have dependencies.
321
We also need to look into use Noses ability to tag tests to allow a more modular
322
approach of running tests.
350
We also need to look into use Noses ability to tag tests to allow a more
351
modular approach of running tests.
324
353
.. _devel_config:
327
356
====================
329
358
IPython uses `.ini`_ files for configuration purposes. This represents a huge
330
improvement over the configuration system used in IPython. IPython works with these
331
files using the `ConfigObj`_ package, which IPython includes as
359
improvement over the configuration system used in IPython. IPython works with
360
these files using the `ConfigObj`_ package, which IPython includes as
332
361
``ipython1/external/configobj.py``.
334
Currently, we are using raw `ConfigObj`_ objects themselves. Each subpackage of IPython
335
should contain a ``config`` subdirectory that contains all of the configuration
336
information for the subpackage. To see how configuration information is defined (along
337
with defaults) see at the examples in ``ipython1/kernel/config`` and
338
``ipython1/core/config``. Likewise, to see how the configuration information is used,
339
see examples in ``ipython1/kernel/scripts/ipengine.py``.
363
Currently, we are using raw `ConfigObj`_ objects themselves. Each subpackage of
364
IPython should contain a ``config`` subdirectory that contains all of the
365
configuration information for the subpackage. To see how configuration
366
information is defined (along with defaults) see at the examples in
367
``ipython1/kernel/config`` and ``ipython1/core/config``. Likewise, to see how
368
the configuration information is used, see examples in
369
``ipython1/kernel/scripts/ipengine.py``.
341
Eventually, we will add a new layer on top of the raw `ConfigObj`_ objects. We are
342
calling this new layer, ``tconfig``, as it will use a `Traits`_-like validation model.
343
We won't actually use `Traits`_, but will implement something similar in pure Python.
344
But, even in this new system, we will still use `ConfigObj`_ and `.ini`_ files
345
underneath the hood. Talk to Fernando if you are interested in working on this part of
346
IPython. The current prototype of ``tconfig`` is located in the IPython sandbox.
371
Eventually, we will add a new layer on top of the raw `ConfigObj`_ objects. We
372
are calling this new layer, ``tconfig``, as it will use a `Traits`_-like
373
validation model. We won't actually use `Traits`_, but will implement
374
something similar in pure Python. But, even in this new system, we will still
375
use `ConfigObj`_ and `.ini`_ files underneath the hood. Talk to Fernando if you
376
are interested in working on this part of IPython. The current prototype of
377
``tconfig`` is located in the IPython sandbox.
348
379
.. _.ini: http://docs.python.org/lib/module-ConfigParser.html
349
380
.. _ConfigObj: http://www.voidspace.org.uk/python/configobj.html
352
383
Installation and testing scenarios
353
384
==================================
355
This section outlines the various scenarios that we need to test before we release an IPython version. These scenarios represent different ways of installing IPython and its dependencies.
386
This section outlines the various scenarios that we need to test before we
387
release an IPython version. These scenarios represent different ways of
388
installing IPython and its dependencies.
357
390
Installation scenarios under Linux and OS X
358
391
-------------------------------------------
360
1. Install from tarball using `python setup.py install`.
393
1. Install from tarball using ``python setup.py install``.
361
394
a. With only readline+nose dependencies installed.
362
b. With all dependencies installed (readline, zope.interface,
363
Twisted, foolscap, Sphinx, nose, pyOpenSSL).
395
b. With all dependencies installed (readline, zope.interface, Twisted,
396
foolscap, Sphinx, nose, pyOpenSSL).
364
398
2. Install using easy_install.
365
400
a. With only readline+nose dependencies installed.
366
i. Default dependencies: `easy_install ipython-0.9.beta3-py2.5.egg`
367
ii. Optional dependency sets: `easy_install -f ipython-0.9.beta3-py2.5.egg IPython[kernel,doc,test,security]`
401
i. Default dependencies: ``easy_install ipython-0.9.beta3-py2.5.egg``
402
ii. Optional dependency sets: ``easy_install -f ipython-0.9.beta3-py2.5.egg IPython[kernel,doc,test,security]``
368
404
b. With all dependencies already installed.
370
407
Installation scenarios under Win32
371
408
----------------------------------