[issue23970] Update distutils.msvccompiler for VC14
Marc-Andre Lemburg
report at bugs.python.org
Thu Apr 16 15:46:34 CEST 2015
Marc-Andre Lemburg added the comment:
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
registry.
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']
else:
# 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
self.compile_options.extend(MSVC_COMPILER_FLAGS)
# "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.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23970>
_______________________________________
More information about the Python-bugs-list
mailing list