[Distutils] Switching off optimization for python setup.py config

Michiel Jan Laurens de Hoon mdehoon@ims.u-tokyo.ac.jp
Wed Apr 30 23:35:02 2003


Dear pythoneers,

Recently I ran into a bug in Numerical Python's eigenvalues function, 
causing it to hang on Cygwin. The bug is caused by Numerical Python 
being compiled with optimization, while a number of routines (the dlamc* 
functions in dlapack_lite.c) should be compiled without optimization to 
function properly (as described in the lapack documentation).

In reading the distutils archives, it seems that the issue of changing 
optimization levels and other compiler flags has been raised before. 
 From what I understand, the current version of distutils does not allow 
to change the optimization level. The problem seems to be that some 
compiler arguments are required for an extension module to work with 
Python, and cannot just be changed (for example, my Makefile has 
OPT=-DNDEBUG -g -O3 -Wall -Wstrict-prototypes in it, which is more than 
just optimization flags).

Now what the dlamc* functions are really doing is to find out some 
machine parameters before the actual numerical routines are executed. In 
today's world of autoconf, automake, and python setup.py config, I would 
think that it makes more sense to let distutils' config step figure out 
the machine parameters, and hardwire the results into the source code 
with some #define's.

This can be achieved by letting python setup.py config run the dlamc* 
routines. However, for this we need to switch off optimization for the 
trial compilations and runs done by python setup.py config. Is this 
possible with the current version of distutils? If not, would it be 
worthwhile to add this to distutils? We have more freedom in changing 
compiler switches for trial compilations than for the actual extension 
module, and I would think that this would be useful for cases other than 
Numerical Python.

--Michiel.


-- 
Michiel de Hoon, Assistant Professor
University of Tokyo, Institute of Medical Science
Human Genome Center
4-6-1 Shirokane-dai, Minato-ku
Tokyo 108-8639
Japan
http://bonsai.ims.u-tokyo.ac.jp/~mdehoon