[Distutils] Changing Compiler Arguments

M.-A. Lemburg mal at lemburg.com
Thu Jun 5 15:35:22 EDT 2003


Enrico Ng wrote:
> Is there a way to change the compiler arguments that are added by 
> distutils.
> NDEBUG is causing problems.
> The distutils documentation suggests undef_macros, but this does not do 
> anything to help.

There isn't: you have to edit msvccompiler.py (.compile_options) or use
a hack like the following:

#
# mx MSVC Compiler extension
#
# We want some extra options for the MSVCCompiler, so we add them
# here. This is an awful hack, but there seems to be no other way to
# subclass a standard distutils C compiler class...

from distutils.msvccompiler import MSVCCompiler

# remember old __init__
old_MSVCCompiler__init__ = MSVCCompiler.__init__

def mx_msvccompiler__init__(self, *args, **kws):

     apply(old_MSVCCompiler__init__, (self,) + args, kws)
     self.compile_options.extend(['/O2','/Gf','/GB','/GD', '/Ob2'])

# "Install" new __init__
MSVCCompiler.__init__ = mx_msvccompiler__init__

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Software directly from the Source  (#1, Jun 05 2003)
 >>> Python/Zope Products & Consulting ...         http://www.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________
EuroPython 2003, Charleroi, Belgium:                        19 days left




More information about the Distutils-SIG mailing list