|
78 | 78 | # dll_base_address later in this file... |
79 | 79 | dll_base_address = 0x1E200000 |
80 | 80 |
|
| 81 | +# Same as setuptools._distutils.compilers.C.msvc._vcvars_names |
| 82 | +_vcvars_names = { |
| 83 | + "win32": "x86", |
| 84 | + "win-amd64": "amd64", |
| 85 | + "win-arm32": "arm", |
| 86 | + "win-arm64": "arm64", |
| 87 | +} |
| 88 | + |
81 | 89 |
|
82 | 90 | class WinExt(Extension): |
83 | 91 | # Base class for all win32 extensions, with some predefined |
@@ -160,18 +168,15 @@ def __init__( |
160 | 168 | ) |
161 | 169 | self.depends = depends or [] # stash it here, as py22 doesn't have it. |
162 | 170 |
|
163 | | - def finalize_options(self, build_ext): |
| 171 | + def finalize_options(self, build_ext: my_build_ext) -> None: |
164 | 172 | # distutils doesn't define this function for an Extension - it is |
165 | 173 | # our own invention, and called just before the extension is built. |
166 | 174 | if not build_ext.mingw32: |
167 | 175 | if self.pch_header: |
168 | 176 | self.extra_compile_args = self.extra_compile_args or [] |
169 | 177 |
|
170 | 178 | # bugger - add this to python! |
171 | | - if build_ext.plat_name == "win32": |
172 | | - self.extra_link_args.append("/MACHINE:x86") |
173 | | - else: |
174 | | - self.extra_link_args.append("/MACHINE:%s" % build_ext.plat_name[4:]) |
| 179 | + self.extra_link_args.append(f"/MACHINE:{build_ext.plat_dir}") |
175 | 180 |
|
176 | 181 | # like Python, always use debug info, even in release builds |
177 | 182 | # (note the compiler doesn't include debug info, so you only get |
@@ -366,10 +371,7 @@ class my_build_ext(build_ext): |
366 | 371 | def finalize_options(self): |
367 | 372 | build_ext.finalize_options(self) |
368 | 373 |
|
369 | | - self.plat_dir = { |
370 | | - "win-amd64": "x64", |
371 | | - "win-arm64": "arm64", |
372 | | - }.get(self.plat_name, "x86") |
| 374 | + self.plat_dir = _vcvars_names.get(self.plat_name, "x86") |
373 | 375 |
|
374 | 376 | # The pywintypes library is created in the build_temp |
375 | 377 | # directory, so we need to add this to library_dirs |
@@ -608,7 +610,7 @@ def build_extensions(self): |
608 | 610 | return |
609 | 611 | if not vcbase: |
610 | 612 | raise RuntimeError("Can't find MFC redist DLLs with unkown VC base path") |
611 | | - redist_globs = [vcbase + r"redist\%s\*MFC\mfc140u.dll" % self.plat_dir] |
| 613 | + redist_globs = [vcbase + r"redist\{}\*MFC\mfc140u.dll".format(self.plat_dir)] |
612 | 614 | m = re.search(r"\\VC\\Tools\\", vcbase) |
613 | 615 | if m: |
614 | 616 | # typical path on newer Visual Studios |
|
0 commit comments