[Distutils] Access to Python config info

Greg Ward gward@cnri.reston.va.us
Wed, 16 Dec 1998 11:11:50 -0500


Quoth John Skaller, on 17 December 1998 [on whether the config module
should be builtin or a separate .py file]:
>         I don't see any real choice: it has to be separate AND editable.
> Because if I download a binary Windows version, the information will be wrong
> for my system. The Unix version might be wrong too: perhaps I built
> Python with gcc, but I want to build extensions with ecgs, or with edg.

There are a number of reasons why you don't want to do this, and it all
boils down to the fact that in the C world you cannot reliably link two
object files if one was compiled with compiler X and the other with
compiler Y.  A concrete example that has burned me in the past: the
'assert' macro supplied with certain versions of GCC uses a function
that is only available when you use GCC to drive the link, ie. when you
the GCC runtime library is linked in.  

I have been bitten by this in two widely separated areas: distributing a
C library that was used by ImageMagick and GIMP; people had problems if
they compiled ImageMagick or GIMP with the system compiler and my
library with gcc.  Likewise, I have seen problems with a C library/Perl
extension that I wrote; if someone manages to build the library and
extension with gcc and link against a Perl built with cc, they stumble
across this problem.  (Less likely, because the SOP in Perl-world is to
build extensions the same way Perl itself was built -- for this very
reason, no doubt!)

Similarly, different C++ compilers might use different name-mangling
algorithms, again causing symbol mismatches.

Anyways, these all constitute reasons for *strong recommendations*
against fiddling with the compiler or flags.  I'll concede that someone
who *really* knows what they're doing should be allowed to do this (but
they should also have to sign a disclaimer first ;-).  And if they want
to edit a machine-generated Python library to make this change
permanent, well, again the responsibility rests on their shoulders.
Extension builders should certainly have the option to override defaults 
from the config module, eg. 
   ./setup.py build --cc=gcc --optimize=-g
or
   ./setup.py install --prefix=/home/greg
or something like that.  (Fodder for another thread, perhaps.)

However, I can definitely buy Andrew's and Robin's arguments in favour
of [config-module-name].py rather than building it into Python.  

        Greg
-- 
Greg Ward - software developer                    gward@cnri.reston.va.us
Corporation for National Research Initiatives    
1895 Preston White Drive                      voice: +1-703-620-8990 x287
Reston, Virginia, USA  20191-5434               fax: +1-703-620-0913