Re: distutils compiler flags for extension modules

Discussion in 'Python' started by Floris Bruynooghe, Mar 20, 2009.

  1. On Mar 20, 9:48 am, Christian Meesters <> wrote:
    > as I got no answers with the previous question (subject: disabling
    > compiler flags in distutils), I thought I should ask the question in a
    > different way: Is there an option to set the compiler flags for a C/C++
    > extension in distutils? There is the extra_compile_args-option in the
    > Extension class, yet this offers only to give additional flags, but I'd
    > like to have 'total' control about the compile args. Any hint?


    You can subclass the build_ext class and overwrite .finalize_options()
    to do something like:

    for ext in self.extensions:
    build_ext.finalize_options()
    # fiddle with ext.extra_compile_args

    And if that isn't enough you can modify the compiler (with some flags)
    by overwriting .build_extension() and modify self.compiler using
    it's .set_executables() method (file:///usr/share/doc/python2.5/html/
    dist/module-distutils.ccompiler.html#l2h-37) before calling
    build_ext.build_extension().


    Regards
    Floris
    Floris Bruynooghe, Mar 20, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anand
    Replies:
    3
    Views:
    885
    Tim Daneliuk
    Nov 8, 2003
  2. spasmous

    Compiler flags

    spasmous, Sep 10, 2006, in forum: C Programming
    Replies:
    20
    Views:
    748
    Stephen Sprunk
    Sep 11, 2006
  3. Replies:
    1
    Views:
    827
    Martin v. Löwis
    Dec 9, 2008
  4. Steve Holden
    Replies:
    0
    Views:
    772
    Steve Holden
    Feb 8, 2009
  5. Alex Hunsley
    Replies:
    1
    Views:
    273
    Alex Hunsley
    Apr 7, 2005
Loading...

Share This Page