@@ -168,7 +168,7 @@ def finalize_options(self, build_ext: my_build_ext) -> None:
168168 self .extra_compile_args = self .extra_compile_args or []
169169
170170 # bugger - add this to python!
171- self .extra_link_args .append (f"/MACHINE:{ build_ext .plat_dir } " )
171+ self .extra_link_args .append (f"/MACHINE:{ build_ext .target_machine } " )
172172
173173 # like Python, always use debug info, even in release builds
174174 # (note the compiler doesn't include debug info, so you only get
@@ -363,7 +363,8 @@ class my_build_ext(build_ext):
363363 def finalize_options (self ):
364364 build_ext .finalize_options (self )
365365
366- self .plat_dir = "x86" if self .plat_name == "win32" else self .plat_name [4 :]
366+ self .target_machine = "x86" if self .plat_name == "win32" else self .plat_name [4 :]
367+ """Valid value for https://learn.microsoft.com/en-us/cpp/build/reference/machine-specify-target-platform"""
367368
368369 # The pywintypes library is created in the build_temp
369370 # directory, so we need to add this to library_dirs
@@ -504,7 +505,7 @@ def _check_vc(self):
504505 # The afxres.h/atls.lib files aren't always included by default,
505506 # so find and add them
506507 if vcbase and not atlmfc_found :
507- atls_lib = glob .glob (vcbase + rf"ATLMFC\lib\{ self .plat_dir } \atls.lib" )
508+ atls_lib = glob .glob (vcbase + rf"ATLMFC\lib\{ self .target_machine } \atls.lib" )
508509 if atls_lib :
509510 self .library_dirs .append (os .path .dirname (atls_lib [0 ]))
510511 self .include_dirs .append (
@@ -602,19 +603,19 @@ def build_extensions(self):
602603 return
603604 if not vcbase :
604605 raise RuntimeError ("Can't find MFC redist DLLs with unkown VC base path" )
605- redist_globs = [vcbase + r "redist\{}\*MFC\mfc140u.dll". format ( self . plat_dir ) ]
606+ redist_globs = [vcbase + rf "redist\{ self . target_machine } \*MFC\mfc140u.dll" ]
606607 m = re .search (r"\\VC\\Tools\\" , vcbase )
607608 if m :
608609 # typical path on newer Visual Studios
609- # prefere corresponding version but accept different version
610+ # prefer corresponding version but accept different version
610611 same_version = vcverdir is not None and os .path .isdir (
611612 vcbase [: m .start ()]
612- + r "\VC\Redist\MSVC\{}{}" . format ( vcverdir , self .plat_dir )
613+ + rf "\VC\Redist\MSVC\{ vcverdir } { self .target_machine } "
613614 )
614615 redist_globs .append (
615616 vcbase [: m .start ()]
616617 + r"\VC\Redist\MSVC\{}{}\*\mfc140u.dll" .format (
617- vcverdir if same_version else "*\\ " , self .plat_dir
618+ vcverdir if same_version else "*\\ " , self .target_machine
618619 )
619620 )
620621 # Only mfcNNNu DLL is required (mfcmNNNX is Windows Forms, rest is ANSI)
0 commit comments