88import os
99import subprocess
1010import sys
11- from collections . abc import Iterable
11+ import platform
1212from distutils import ccompiler , sysconfig
1313from typing import Any
1414
4040 },
4141}
4242
43- __spawn = ccompiler .CCompiler .spawn
43+ ccompiler . CCompiler . __spawn = ccompiler .CCompiler .spawn # type: ignore[attr-defined]
4444
45+ X86_64 = platform .machine () in ("x86_64" , "AMD64" , "amd64" )
4546
46- def spawn (self : ccompiler . CCompiler , cmd : Iterable [ str ] , ** kwargs : Any ) -> None :
47- compiler_type : str = self .compiler_type # type: ignore[attr-defined]
47+ def spawn (self , cmd , ** kwargs ) -> None : # type: ignore[no-untyped-def]
48+ compiler_type : str = self .compiler_type
4849 extra_options = EXTRA_FLAGS_PER_COMPILER_TYPE_PER_PATH_COMPONENT [compiler_type ]
4950 new_cmd = list (cmd )
50- if extra_options is not None :
51+ if X86_64 and extra_options is not None :
5152 # filenames are closer to the end of command line
5253 for argument in reversed (new_cmd ):
5354 # Check if argument contains a filename. We must check for all
5455 # possible extensions; checking for target extension is faster.
55- if self .obj_extension and not str (argument ).endswith (self .obj_extension ): # type: ignore[attr-defined]
56+ if self .obj_extension and not str (argument ).endswith (self .obj_extension ):
5657 continue
5758
5859 for path in extra_options .keys ():
@@ -66,12 +67,10 @@ def spawn(self: ccompiler.CCompiler, cmd: Iterable[str], **kwargs: Any) -> None:
6667
6768 # path component is found, no need to search any further
6869 break
69- __spawn (self , new_cmd , ** kwargs )
70+ self . __spawn (new_cmd , ** kwargs )
7071
7172
7273ccompiler .CCompiler .spawn = spawn # type: ignore[method-assign]
73-
74-
7574class BuildExtGtest (build_ext ):
7675 def get_library_names (self ) -> list [str ]:
7776 return ["gtest" ]
0 commit comments