387
387
so, please reply and say so.)
393
We write some extensions in C using pyrex. We design these to work in
395
* User with no C compiler
396
* User with C compiler
399
The recommended way to install bzr is to have a C compiler so that the
400
extensions can be built, but if no C compiler is present, the pure python
401
versions we supply will work, though more slowly.
403
For developers we recommend that pyrex be installed, so that the C
404
extensions can be changed if needed.
406
For the C extensions, the extension module should always match the
407
original python one in all respects (modulo speed). This should be
408
maintained over time.
410
To create an extension, add rules to setup.py for building it with pyrex,
411
and with distutils. Now start with an empty .pyx file. At the top add
412
"include 'yourmodule.py'". This will import the contents of foo.py into this
413
file at build time - remember that only one module will be loaded at
414
runtime. Now you can subclass classes, or replace functions, and only your
415
changes need to be present in the .pyx file.
417
Note that pyrex does not support all 2.4 programming idioms, so some
418
syntax changes may be required. I.e.
419
- 'from foo import (bar, gam)' needs to change to not use the brackets.
420
- 'import foo.bar as bar' needs to be 'import foo.bar; bar = foo.bar'
421
If the changes are too dramatic, consider
422
maintaining the python code twice - once in the .pyx, and once in the .py,
423
and no longer including the .py file.