[Numpy-discussion] RPMs out of date, have problems

eric eric at enthought.com
Sun Jan 6 20:29:03 CST 2002


> > (1) Extension( ..., extra_compile_args = [ "-O17" ], ...)
> > This will append the optimization level 17 to the compiler flag
> > (the last -O option counts).
>
> But that will add the argument for all platforms. I need to specify
> compilation flags separately for each platform/compiler. I might even
> want to compile some modules with the new Intel compiler for Linux.
>
> > (2) export CFLAGS=-O3; python setup.py build
> > This will append -O3
>
> For all extension modules - I need to specify different flags for each
> extension module, in one case even for a single source code file.

This seems to be one of the big complaints about distutils for scientist
(and maybe others).  I think it is also one of Paul Dubois' major reasons
for not liking distutils for Fortran files.  I've run into this occasionally
too and wished for a dictionary argument, maybe file_special_instructions,
that had file names as keys and a dictionary of options for that file as the
value.  I think this might go some distance to solving the problem.

file_special_instructions = {
                                           'really_fast.c': { compiler =
'icc',

override_compiler_flags = ['O2', 'tpp7']
                                                                   }
                                           'sorta_fast.c':  {
extra_compile_args = ['-O2']}
                                           }

So an extension module that used this and had 'slow.c', 'really_fast.c', and
'kinda_fast.c' would use the standard compile tools for 'slow.c', use the
specified compiler with the specified flags for 'really_fast.c', and add the
specified compiler flags to the standard flags for 'sorta_fast.c'.  This
approach would provide quite a bit of flexiblity.  To handle platform
specific versions of file_special_instructions, I think you'd have to use
if/thens within the setup.py file to build a separate set of instructions
for each platform.

There is one other major issue I've run into with distutils that I haven't
found a way around.  Sometimes you need compiler/linker flags inter-mingled
with source or library files in a certain way.  This can occur on SunOS when
you want to link statically to some libraries and dynamically to others.
distutils just doesn't provide a way of doing this that I have found.

SciPy now has a package of extensions/changes to distutils called
scipy_distutils helpful for building fortran based extension modules and
other things needed by SciPy.  We could experiment with adding something
like the file_special_instructions flag if others thought it useful.  Later,
it could be folded back into distutils if the rest of the community wanted
it.

Thoughts?

eric







More information about the Numpy-discussion mailing list