[Distutils] Update bdist_rpm patch

Greg Ward gward@ase.com
Sat, 6 May 2000 09:17:20 -0400


On 05 May 2000, Harry Henry Gebel said:
> I wasn't looking at --arch and CFLAGS to support cross-compiling, rather
> it is to support different versions of the same processor family. If I
> compile 'module-1.0-1.src.rpm' on an i386 or with '--target=i386' it will
> generate 'module-1.0-1.i386.rpm' but if I compile the same source RPM on a
> Pentium II or with '--target=i686' it will generate
> 'module-1.0-1.i686.rpm' even though it is really an i386 binary because
> ./setup.py does not pass any '--mcpu' or '--march' options to gcc. RPM
> sets a variable containing the appropriate '--mcpu' and '--march' (and
> other) options, but in does not appear that there is any way to use this
> variable in ./setup.py at this time. 

Aahhh!  I get it now, thanks.

Anyways, I've just checked in a change that should enable this.  It was
already possible to sneak extra arguments into the link command line;
now it can be done with the compile command line to boot.  Start in the
'build_extensions()' method of distutils/command/build_ext.py; you'll
note that it now looks for an 'extra_compile_args' element in the
'build_info' dictionary.

FYI: 'build_info' is the dictionary of info that's included with each
extension and contains all the information required to build the
extension on "any" platform.  For example, here's a snippet from the
NumPy setup script:

       ext_modules = [('_numpy',
                       { 'sources' : ['Src/_numpymodule.c',
                                      'Src/arrayobject.c',
                                      'Src/ufuncobject.c'],
                       }
                      ),

If I want to sneak, say, "-m486", onto the compiler command line for
each of the three source files in *this* extensions, I would change the
build_info dict shown here to:

                       { 'sources' : ['Src/_numpymodule.c',
                                      'Src/arrayobject.c',
                                      'Src/ufuncobject.c'],
                         'extra_compile_afgs' : ['-m486']
                       }

Of course, you'll be invoking "build_ext" programmatically, rather than
through the command line and setup script, so it'll be slightly
different for you.  This should give you the idea, though; just read
through the 'build_extensions()' method and you should see what's going
on.

        Greg
-- 
Greg Ward - Unix geek                                   gward@python.net
http://starship.python.net/~gward/
Speak softly and carry a +6 two-handed sword.