diff --git a/distutils/command/build_ext.py b/distutils/command/build_ext.py index df623d7e..6937f31e 100644 --- a/distutils/command/build_ext.py +++ b/distutils/command/build_ext.py @@ -329,10 +329,14 @@ def run(self) -> None: # noqa: C901 force=self.force, ) customize_compiler(self.compiler) - # If we are cross-compiling, init the compiler now (if we are not - # cross-compiling, init would not hurt, but people may rely on - # late initialization of compiler even if they shouldn't...) - if os.name == 'nt' and self.plat_name != get_platform(): + if ( + # If we are cross-compiling, init the compiler now (if we are not + # cross-compiling, init would not hurt, but people may rely on + # late initialization of compiler even if they shouldn't...) + self.plat_name != get_platform() + # Initialization is a MSVCCompiler specific concept + and hasattr(self.compiler, "initialize") + ): self.compiler.initialize(self.plat_name) # The official Windows free threaded Python installer doesn't set