|
13 | 13 |
|
14 | 14 | For a debug (_d) version, you need a local debug build of Python, but must use |
15 | 15 | the release version executable for the build. eg: |
16 | | - pip install . -v --config-setting=--build-option="build --debug" |
| 16 | + pip install . -v --config-setting=--build-option=build --config-setting=--build-option=--debug |
17 | 17 |
|
18 | 18 | Cross-compilation from x86 to ARM is well supported (assuming installed vs tools etc) - eg: |
19 | | - python -m build --wheel --config-setting=--build-option="build_ext --plat-name=win-arm64 build --plat-name=win-arm64 bdist_wheel --plat-name=win-arm64" |
| 19 | + python -m build --wheel --config-setting=--build-option=build_ext --config-setting=--build-option=--plat-name=win-arm64 --config-setting=--build-option=build --config-setting=--build-option=--plat-name=win-arm64 --config-setting=--build-option=bdist_wheel --config-setting=--build-option=--plat-name=win-arm64 |
20 | 20 |
|
21 | 21 | Some modules require special SDKs or toolkits to build (eg, mapi/exchange), |
22 | 22 | which often aren't available in CI. The build process treats them as optional - |
@@ -160,15 +160,18 @@ def __init__( |
160 | 160 | ) |
161 | 161 | self.depends = depends or [] # stash it here, as py22 doesn't have it. |
162 | 162 |
|
163 | | - def finalize_options(self, build_ext: my_build_ext) -> None: |
| 163 | + def finalize_options(self, build_ext): |
164 | 164 | # distutils doesn't define this function for an Extension - it is |
165 | 165 | # our own invention, and called just before the extension is built. |
166 | 166 | if not build_ext.mingw32: |
167 | 167 | if self.pch_header: |
168 | 168 | self.extra_compile_args = self.extra_compile_args or [] |
169 | 169 |
|
170 | 170 | # bugger - add this to python! |
171 | | - self.extra_link_args.append(f"/MACHINE:{build_ext.target_machine}") |
| 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:]) |
172 | 175 |
|
173 | 176 | # like Python, always use debug info, even in release builds |
174 | 177 | # (note the compiler doesn't include debug info, so you only get |
@@ -363,8 +366,10 @@ class my_build_ext(build_ext): |
363 | 366 | def finalize_options(self): |
364 | 367 | build_ext.finalize_options(self) |
365 | 368 |
|
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""" |
| 369 | + self.plat_dir = { |
| 370 | + "win-amd64": "x64", |
| 371 | + "win-arm64": "arm64", |
| 372 | + }.get(self.plat_name, "x86") |
368 | 373 |
|
369 | 374 | # The pywintypes library is created in the build_temp |
370 | 375 | # directory, so we need to add this to library_dirs |
@@ -505,7 +510,7 @@ def _check_vc(self): |
505 | 510 | # The afxres.h/atls.lib files aren't always included by default, |
506 | 511 | # so find and add them |
507 | 512 | if vcbase and not atlmfc_found: |
508 | | - atls_lib = glob.glob(vcbase + rf"ATLMFC\lib\{self.target_machine}\atls.lib") |
| 513 | + atls_lib = glob.glob(vcbase + rf"ATLMFC\lib\{self.plat_dir}\atls.lib") |
509 | 514 | if atls_lib: |
510 | 515 | self.library_dirs.append(os.path.dirname(atls_lib[0])) |
511 | 516 | self.include_dirs.append( |
@@ -603,19 +608,19 @@ def build_extensions(self): |
603 | 608 | return |
604 | 609 | if not vcbase: |
605 | 610 | raise RuntimeError("Can't find MFC redist DLLs with unkown VC base path") |
606 | | - redist_globs = [vcbase + rf"redist\{self.target_machine}\*MFC\mfc140u.dll"] |
| 611 | + redist_globs = [vcbase + r"redist\%s\*MFC\mfc140u.dll" % self.plat_dir] |
607 | 612 | m = re.search(r"\\VC\\Tools\\", vcbase) |
608 | 613 | if m: |
609 | 614 | # typical path on newer Visual Studios |
610 | | - # prefer corresponding version but accept different version |
| 615 | + # prefere corresponding version but accept different version |
611 | 616 | same_version = vcverdir is not None and os.path.isdir( |
612 | 617 | vcbase[: m.start()] |
613 | | - + rf"\VC\Redist\MSVC\{vcverdir}{self.target_machine}" |
| 618 | + + r"\VC\Redist\MSVC\{}{}".format(vcverdir, self.plat_dir) |
614 | 619 | ) |
615 | 620 | redist_globs.append( |
616 | 621 | vcbase[: m.start()] |
617 | 622 | + r"\VC\Redist\MSVC\{}{}\*\mfc140u.dll".format( |
618 | | - vcverdir if same_version else "*\\", self.target_machine |
| 623 | + vcverdir if same_version else "*\\", self.plat_dir |
619 | 624 | ) |
620 | 625 | ) |
621 | 626 | # Only mfcNNNu DLL is required (mfcmNNNX is Windows Forms, rest is ANSI) |
|
0 commit comments