In practice, it&#x27;s very hard to make Python&#x27;s distutils do this. I tried to figure it out years ago, see <a href="http:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;15527611&#x2F;how-do-i-specify-different-compiler-flags-in-distutils-for-just-one-python-c-ext" rel="nofollow">http:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;15527611&#x2F;how-do-i-specify...</a> . I also asked on the distutils list. No one had a clean solution.<p>The best solution I have is to interpose my own &quot;CC&quot;, which looks at what is being compile and adds the correct compiler options for the right files before calling the real compiler. This is hacky and inflexible.