Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions distutils/command/build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would've done

Suggested change
and hasattr(self.compiler, "initialize")
and isinstance(MSVCCompiler, self.compiler)

But who knows if someone downstream added a custom non-MSVCCompiler with .initialize that relies on being called.

Or it could be considered so internal that it's fine to do the more "proper" check that also helps static checkers.

):
self.compiler.initialize(self.plat_name)

# The official Windows free threaded Python installer doesn't set
Expand Down
Loading