[Distutils] Switching off optimization for python setup.py config
M.-A. Lemburg
mal@lemburg.com
Thu May 1 09:05:02 2003
Michiel Jan Laurens de Hoon wrote:
> 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.
You can use the distutils.command.config command class to write
configuration and test compilation methods. These have complete
control over the compiler being used, so switching off optimization
for the purpose of configuration should be possible.
The config command is still way from being complete and not
all that useful by itself, but it provides a nice hook to
integrate and add your own configuration tools.
For an example on what can be done, see mxSetup.py in the
eGenix mx Extensions tar-balls.
--
Marc-Andre Lemburg
eGenix.com
Professional Python Software directly from the Source (#1, May 01 2003)
>>> Python/Zope Products & Consulting ... http://www.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
EuroPython 2003, Charleroi, Belgium: 54 days left