[Distutils] define_macros ignored?

Jeremy Hylton jeremy@beopen.com
Tue Sep 12 22:41:14 2000


I am working on a setup script for Tkinter, which requires a
-DWITH_APPINIT flag at compile time.  The docs suggest that I should
add the following definition to my Extension constructor call:
    define_macros=[('WITH_APPINIT', None),],

I did this, but it had no effect.  It looks like there is no where
that the define_macros attribute of the Extension object is actually
used.  

I assumed this is a bug and tried to figure out where the macros
definitions ought to be processed.  I'm not familiar with the code, so
I may have put it in the wrong place.  A patch is included below,
which allows _tkinter to build.

Jeremy

*** build_ext.py	Tue Sep 12 20:58:48 2000
--- /home/jeremy/src/python/dist/src/Lib/distutils/command/build_ext.py	Thu Sep  7 11:09:18 2000
***************
*** 401,407 ****
              # any sensible compiler will give precedence to later
              # command line args.  Hence we combine them in order:
              extra_args = ext.extra_compile_args or []
-             macros = ext.define_macros or []
  
              # XXX and if we support CFLAGS, why not CC (compiler
              # executable), CPPFLAGS (pre-processor options), and LDFLAGS
--- 401,406 ----
***************
*** 410,419 ****
  
              if os.environ.has_key('CFLAGS'):
                  extra_args.extend(string.split(os.environ['CFLAGS']))
! 
              objects = self.compiler.compile (sources,
                                               output_dir=self.build_temp,
!                                              macros=macros,
                                               include_dirs=ext.include_dirs,
                                               debug=self.debug,
                                               extra_postargs=extra_args)
--- 409,418 ----
  
              if os.environ.has_key('CFLAGS'):
                  extra_args.extend(string.split(os.environ['CFLAGS']))
!                 
              objects = self.compiler.compile (sources,
                                               output_dir=self.build_temp,
!                                              #macros=macros,
                                               include_dirs=ext.include_dirs,
                                               debug=self.debug,
                                               extra_postargs=extra_args)