This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author lemburg
Recipients lemburg, paul.moore, steve.dower, tim.golden, zach.ware
Date 2015-04-16.13:46:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
In-reply-to <>
On 16.04.2015 15:18, Steve Dower wrote:
> Is there a way for those users to specify the version that they want?

Indirectly, yes. There's the build_ext --compiler argument which then
interfaces to ccompiler.new_compiler. In essence, you can specify
the compiler type.

The compiler is then looked up in the ccompiler.compiler_class

Adding new compiler classes is possible through monkey patching
(since the modules implementing them must be in the distutils package).

Not a nice design... exposing a proper registry API for the compiler
classes would be better, even if it's just via something like a
compilerclass dictionary in the setup() call.

On Unix, it is possible to specify the compiler using the CC env var.

> I can flow that through from somewhere, and honestly the compiler arguments have not changed in a long time. The problem is detecting an installation.

We completely gave up on the automatic detection of the installation
and only rely on the vcvars style batch files to set up things
correctly for each MS compiler version and then have distutils find it.

> I have formalized the DISTUTILS_USE_SDK variable, so setting up the env with that will be more reliable than previously.
> Also, I'm interested in what other patches you might apply. This is the last time I really want to touch this, so it's the time to get things like that added.

Something we've needed is a standard way to extract the
lib and include paths used by the compiler:

def get_msvc_paths():

    """ Return a tuple (libpath, inclpath) defining the search
        paths for library files and include files that the MS VC++
        compiler uses per default.

        Both entries are lists of directories.

        Only available on Windows platforms with installed compiler.


and the only monkey-patching we do is to be able to modify
the default compiler switches used:

if python_version < '2.4':
    # VC6
    MSVC_COMPILER_FLAGS = ['/O2', '/Gf', '/GB', '/GD', '/Ob2']
elif python_version < '2.6':
    # VC7.1
    MSVC_COMPILER_FLAGS = ['/O2', '/GF', '/GB', '/Ob2']
    # VC9
    MSVC_COMPILER_FLAGS = ['/O2', '/GF', '/Ob2']

if hasattr(MSVCCompiler, 'initialize'):
    # distutils 2.5.0 separates the initialization of the
    # .compile_options out into a new method .initialize()

    # remember old _initialize
    old_MSVCCompiler_initialize = MSVCCompiler.initialize

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

        apply(old_MSVCCompiler_initialize, (self,) + args, kws)

        # Add our extra options

    # "Install" new initialize
    MSVCCompiler.initialize = mx_msvccompiler_initialize

Would be great to a standard way to do this in the MSVCCompiler
class or associated module.
Date User Action Args
2015-04-16 13:46:34lemburgsetrecipients: + lemburg, paul.moore, tim.golden, zach.ware, steve.dower
2015-04-16 13:46:34lemburglinkissue23970 messages
2015-04-16 13:46:33lemburgcreate