]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-85454: Remove distutils.ccompiler from Tools/c-analyzer (GH-95171)
authorDong-hee Na <donghee.na@python.org>
Mon, 25 Jul 2022 19:10:30 +0000 (04:10 +0900)
committerGitHub <noreply@github.com>
Mon, 25 Jul 2022 19:10:30 +0000 (21:10 +0200)
Tools/c-analyzer/c_parser/preprocessor/__init__.py

index e38176fee31fac7bee0b3c20681f0a24c1943cff..c154137bf42f0d99609193bf0e36a7c5df78162e 100644 (file)
@@ -1,7 +1,9 @@
 import contextlib
-import distutils.ccompiler
 import logging
+import os
 import os.path
+import re
+import sys
 
 from c_common.fsutil import match_glob as _match_glob
 from c_common.tables import parse_table as _parse_table
@@ -168,9 +170,17 @@ _COMPILERS = {
 }
 
 
+def _get_default_compiler():
+    if re.match('cygwin.*', sys.platform) is not None:
+        return 'unix'
+    if os.name == 'nt':
+        return 'msvc'
+    return 'unix'
+
+
 def _get_preprocessor(tool):
     if tool is True:
-        tool = distutils.ccompiler.get_default_compiler()
+        tool = _get_default_compiler()
     preprocess = _COMPILERS.get(tool)
     if preprocess is None:
         raise ValueError(f'unsupported tool {tool}')