From 4ecf617a4b4482186570b295acd0db593fa24e10 Mon Sep 17 00:00:00 2001 From: Naveen M K Date: Thu, 11 Jul 2024 20:43:06 +0530 Subject: [PATCH] cygwinccompiler: Get the compilers from sysconfig On the CLANG64 environment of MSYS2, we should use clang instead of gcc. This patch gets the compiler from sysconfig which would be set when Python was built. Without this patch, the build fails when it's trying to check if the compiler is cygwin's one. --- distutils/cygwinccompiler.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/distutils/cygwinccompiler.py b/distutils/cygwinccompiler.py index 18b1b3557b..3c67524e6d 100644 --- a/distutils/cygwinccompiler.py +++ b/distutils/cygwinccompiler.py @@ -21,6 +21,7 @@ DistutilsPlatformError, ) from .file_util import write_file +from .sysconfig import get_config_vars from .unixccompiler import UnixCCompiler from .version import LooseVersion, suppress_known_deprecation @@ -61,8 +62,12 @@ def __init__(self, verbose=False, dry_run=False, force=False): "Compiling may fail because of undefined preprocessor macros." ) - self.cc = os.environ.get('CC', 'gcc') - self.cxx = os.environ.get('CXX', 'g++') + self.cc, self.cxx = get_config_vars('CC', 'CXX') + + # Override 'CC' and 'CXX' environment variables for + # building using MINGW compiler for MSVC python. + self.cc = os.environ.get('CC', self.cc or 'gcc') + self.cxx = os.environ.get('CXX', self.cxx or 'g++') self.linker_dll = self.cc self.linker_dll_cxx = self.cxx