[Numpy-discussion] Backporting numpy to Python 2.2

Tim Wegener twegener at radlogic.com.au
Tue Apr 18 18:07:02 CDT 2006


I am attempting to backport numpy-0.9.6 to be compatible with python 2.2. (Some of our machines run python 2.2 as part of Red Hat 9 and Red Hat 7.3 and it is hazardous to alter the standard setup.) I was able to change most of the 2.3-isms to be 2.2 compatible (see the attached patch). However I had problems compiling the following c module:

In file included from numpy/core/src/multiarraymodule.c:64:
numpy/core/src/arrayobject.c: In function `arraydescr_dealloc':
numpy/core/src/arrayobject.c:8417: warning: passing arg 1 of pointer to function from incompatible pointer type
numpy/core/src/multiarraymodule.c: In function `PyArray_DescrConverter':
numpy/core/src/multiarraymodule.c:4072: `PyBool_Type' undeclared (first use in this function)
numpy/core/src/multiarraymodule.c: In function `setup_scalartypes':
numpy/core/src/multiarraymodule.c:5736: `PyBool_Type' undeclared (first use in this function)
numpy/core/src/multiarraymodule.c: In function `initmultiarray':
numpy/core/src/multiarraymodule.c:5897: `PyObject_SelfIter' undeclared (first use in this function)
error: Command "gcc -DNDEBUG -O2 -g -pipe -march=i386 -mcpu=i686 -D_GNU_SOURCE -fPIC -fPIC -Ibuild/src/numpy/core/src -Inumpy/core/include -Ibuild/src/numpy/core -Inumpy/core/src -Inumpy/core/include -I/usr/include/python2.2 -c numpy/core/src/multiarraymodule.c -o build/temp.linux-i686-2.2/multiarraymodule.o" failed with exit status 1

Is it possible to modify this module for python 2.2 compatibility or have I reached a dead end?

It would be great if numpy were compatible with 2.2 out of the box, given that 2.3 is only a couple of years old (new), and 2.2 is still quite widely deployed. I am trying to migrate to numpy from Numeric, which worked happily with 2.2. 

FYI, a quick summary of the compatibility amendments to the python code:
- backported os.walk
- backported enumerate
- backported distutils.log
- used slices instead of list.index(item, <start>)
- used 'r' mode instead of 'U' mode (it didn't seem that universal newline support was needed where it was used)
- used the {} way of building a new dict rather than using keyword args to the dict constructor
- from __future__ import generators
- used str.count(substr) rather than substr in str
- used os.sep rather than os.path.sep
- commented out some of the new Configuration keword arguments (download_url and classifiers)

The above don't really affect the functionality, but a couple of more unusual changes were needed as well:
- had to add "self.compiler.exe_extension = ''" to numpy/distutils/command/config.py (see patch)
- had to change the following to and empty dict: "kws = {'depends':ext.depends}" in numpy/distutils/command/build_ext.py (see patch)
These two changes may have unwanted side effects, and a better fix is probably needed there.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: numpy-0.9.6_patched_for_py2.2_diff.txt
Url: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20060418/520b514d/attachment.txt 

More information about the Numpy-discussion mailing list