From 59bf7a432559d2983fb813d94a4c9b052000a7b8 Mon Sep 17 00:00:00 2001 From: Roumen Petrov Date: Sun, 3 Mar 2013 20:29:01 +0200 Subject: [PATCH 16/24] MINGW: use Mingw32CCompiler as default compiler for mingw* build --- Lib/distutils/ccompiler.py | 4 +++- Lib/distutils/cygwinccompiler.py | 11 ++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Lib/distutils/ccompiler.py b/Lib/distutils/ccompiler.py index 911e84d..766f991 100644 --- a/Lib/distutils/ccompiler.py +++ b/Lib/distutils/ccompiler.py @@ -9,7 +9,7 @@ from distutils.spawn import spawn from distutils.file_util import move_file from distutils.dir_util import mkpath from distutils.dep_util import newer_pairwise, newer_group -from distutils.util import split_quoted, execute +from distutils.util import split_quoted, execute, get_platform from distutils import log class CCompiler: @@ -947,6 +947,8 @@ def get_default_compiler(osname=None, platform=None): osname = os.name if platform is None: platform = sys.platform + if get_platform().startswith('mingw'): + return 'mingw32' for pattern, compiler in _default_compilers: if re.match(pattern, platform) is not None or \ re.match(pattern, osname) is not None: diff --git a/Lib/distutils/cygwinccompiler.py b/Lib/distutils/cygwinccompiler.py index 6797089..08c0b87 100644 --- a/Lib/distutils/cygwinccompiler.py +++ b/Lib/distutils/cygwinccompiler.py @@ -148,11 +148,16 @@ class CygwinCCompiler(UnixCCompiler): output_dir = '' obj_names = [] for src_name in source_filenames: - # use normcase to make sure '.rc' is really '.rc' and not '.RC' - base, ext = os.path.splitext(os.path.normcase(src_name)) + base, ext = os.path.splitext(src_name) + # use 'normcase' only for resource suffixes + ext_normcase = os.path.normcase(ext) + if ext_normcase in ['.rc','.res']: + ext = ext_normcase if ext not in (self.src_extensions + ['.rc','.res']): raise UnknownFileError("unknown file type '%s' (from '%s')" % \ (ext, src_name)) + base = os.path.splitdrive(base)[1] # Chop off the drive + base = base[os.path.isabs(base):] # If abs, chop off leading / if strip_dir: base = os.path.basename (base) if ext in ('.res', '.rc'): @@ -176,7 +181,7 @@ class Mingw32CCompiler(CygwinCCompiler): # Include the appropriate MSVC runtime library if Python was built # with MSVC 7.0 or later. - self.dll_libraries = get_msvcr() + self.dll_libraries = get_msvcr() or [] ## ## TODO: obsolete methods - to remove from distutils tests first -- 1.7.12.1