1010import sysconfig
1111import time
1212
13+
14+ MS_WINDOWS = (sys .platform == 'win32' )
1315SRC_DIR = os .path .abspath (os .path .join (os .path .dirname (__file__ ), '..' , '..' ))
1416SCRIPT_NAME = os .path .basename (__file__ )
1517SCRIPT_FULLNAME = f'Tools/build/{ SCRIPT_NAME } '
@@ -125,6 +127,7 @@ def parse_args():
125127 parser .add_argument ('--git-version' , type = str )
126128 parser .add_argument ('--git-tag' , type = str )
127129 parser .add_argument ('--git-branch' , type = str )
130+ parser .add_argument ('--getcompiler-program' , type = str )
128131 parser .add_argument ('--compiler' , type = str )
129132 parser .add_argument ('--free-threading' , type = int )
130133 return parser .parse_args ()
@@ -155,10 +158,14 @@ def run_command(cmd, *, check=True):
155158 return proc .stdout .rstrip ()
156159
157160
158- def _get_compiler ():
161+ def _get_compiler (getcompiler ):
159162 # Run _getcompiler program
160- getcompiler = os .path .join ('Programs' , '_getcompiler' )
161- HOSTRUNNER = get_hostrunner ()
163+ if not getcompiler :
164+ getcompiler = os .path .join ('Programs' , '_getcompiler' )
165+ if not MS_WINDOWS :
166+ HOSTRUNNER = get_hostrunner ()
167+ else :
168+ HOSTRUNNER = None
162169 if HOSTRUNNER :
163170 # Cross-compilation
164171 runner = shlex .split (HOSTRUNNER )[0 ]
@@ -168,6 +175,9 @@ def _get_compiler():
168175 if compiler :
169176 return compiler
170177
178+ if MS_WINDOWS :
179+ return None
180+
171181 # Running _getcompiler failed, run the compiler with --version
172182 CC = get_makefile_cc ()
173183 if not CC :
@@ -206,9 +216,9 @@ def compact_compiler(compiler):
206216 return compiler
207217
208218
209- def get_compiler (compiler ):
219+ def get_compiler (compiler , getcompiler_program ):
210220 if not compiler :
211- compiler = _get_compiler ()
221+ compiler = _get_compiler (getcompiler_program )
212222 if not compiler :
213223 # Default compiler name when everything else failed
214224 # (see Programs/_getcompiler.c)
@@ -254,7 +264,7 @@ def main():
254264 if not platform :
255265 platform = "unknown"
256266
257- compiler = get_compiler (args .compiler )
267+ compiler = get_compiler (args .compiler , args . getcompiler_program )
258268
259269 build_info , git_id = get_build_info (git_tag , git_branch , git_version )
260270
0 commit comments