summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorDong-hee Na <donghee.na@python.org>2022-07-25 19:10:30 (GMT)
committerGitHub <noreply@github.com>2022-07-25 19:10:30 (GMT)
commita15ae19ffba33282d21440a8fb7c39af26b7d25e (patch)
tree36e40da97361f0bc10c886e22bf747efb7eae75a /Tools
parent4a1dd734311891662a6fc3394f93db98c93e7219 (diff)
downloadcpython-a15ae19ffba33282d21440a8fb7c39af26b7d25e.zip
cpython-a15ae19ffba33282d21440a8fb7c39af26b7d25e.tar.gz
cpython-a15ae19ffba33282d21440a8fb7c39af26b7d25e.tar.bz2
gh-85454: Remove distutils.ccompiler from Tools/c-analyzer (GH-95171)
Diffstat (limited to 'Tools')
-rw-r--r--Tools/c-analyzer/c_parser/preprocessor/__init__.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/Tools/c-analyzer/c_parser/preprocessor/__init__.py b/Tools/c-analyzer/c_parser/preprocessor/__init__.py
index e38176f..c154137 100644
--- a/Tools/c-analyzer/c_parser/preprocessor/__init__.py
+++ b/Tools/c-analyzer/c_parser/preprocessor/__init__.py
@@ -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}')