Skip to content

Commit 7060026

Browse files
Alexpuxlazka
authored andcommitted
distutils: use Mingw32CCompiler as default compiler for m
Co-authored-by: Алексей <[email protected]>
1 parent 7476962 commit 7060026

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

Lib/distutils/ccompiler.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from distutils.file_util import move_file
1010
from distutils.dir_util import mkpath
1111
from distutils.dep_util import newer_group
12-
from distutils.util import split_quoted, execute
12+
from distutils.util import split_quoted, execute, get_platform
1313
from distutils import log
1414

1515
class CCompiler:
@@ -948,6 +948,8 @@ def get_default_compiler(osname=None, platform=None):
948948
osname = os.name
949949
if platform is None:
950950
platform = sys.platform
951+
if get_platform().startswith('mingw'):
952+
return 'mingw32'
951953
for pattern, compiler in _default_compilers:
952954
if re.match(pattern, platform) is not None or \
953955
re.match(pattern, osname) is not None:

Lib/distutils/cygwinccompiler.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,16 @@ def object_filenames(self, source_filenames, strip_dir=0, output_dir=''):
253253
output_dir = ''
254254
obj_names = []
255255
for src_name in source_filenames:
256-
# use normcase to make sure '.rc' is really '.rc' and not '.RC'
257-
base, ext = os.path.splitext(os.path.normcase(src_name))
256+
base, ext = os.path.splitext(src_name)
257+
# use 'normcase' only for resource suffixes
258+
ext_normcase = os.path.normcase(ext)
259+
if ext_normcase in ['.rc','.res']:
260+
ext = ext_normcase
258261
if ext not in (self.src_extensions + ['.rc','.res']):
259262
raise UnknownFileError("unknown file type '%s' (from '%s')" % \
260263
(ext, src_name))
264+
base = os.path.splitdrive(base)[1] # Chop off the drive
265+
base = base[os.path.isabs(base):] # If abs, chop off leading /
261266
if strip_dir:
262267
base = os.path.basename (base)
263268
if ext in ('.res', '.rc'):
@@ -313,7 +318,7 @@ def __init__(self, verbose=0, dry_run=0, force=0):
313318

314319
# Include the appropriate MSVC runtime library if Python was built
315320
# with MSVC 7.0 or later.
316-
self.dll_libraries = get_msvcr()
321+
self.dll_libraries = get_msvcr() or []
317322

318323
# Because these compilers aren't configured in Python's pyconfig.h file by
319324
# default, we should at least warn the user if he is using an unmodified

0 commit comments

Comments
 (0)