Skip to content

Commit b80db64

Browse files
authored
Discard changes to setup.py
1 parent 46f931f commit b80db64

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

setup.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
1414
For a debug (_d) version, you need a local debug build of Python, but must use
1515
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
1717
1818
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
2020
2121
Some modules require special SDKs or toolkits to build (eg, mapi/exchange),
2222
which often aren't available in CI. The build process treats them as optional -
@@ -160,15 +160,18 @@ def __init__(
160160
)
161161
self.depends = depends or [] # stash it here, as py22 doesn't have it.
162162

163-
def finalize_options(self, build_ext: my_build_ext) -> None:
163+
def finalize_options(self, build_ext):
164164
# distutils doesn't define this function for an Extension - it is
165165
# our own invention, and called just before the extension is built.
166166
if not build_ext.mingw32:
167167
if self.pch_header:
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.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:])
172175

173176
# like Python, always use debug info, even in release builds
174177
# (note the compiler doesn't include debug info, so you only get
@@ -363,8 +366,10 @@ class my_build_ext(build_ext):
363366
def finalize_options(self):
364367
build_ext.finalize_options(self)
365368

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")
368373

369374
# The pywintypes library is created in the build_temp
370375
# directory, so we need to add this to library_dirs
@@ -505,7 +510,7 @@ def _check_vc(self):
505510
# The afxres.h/atls.lib files aren't always included by default,
506511
# so find and add them
507512
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")
509514
if atls_lib:
510515
self.library_dirs.append(os.path.dirname(atls_lib[0]))
511516
self.include_dirs.append(
@@ -603,19 +608,19 @@ def build_extensions(self):
603608
return
604609
if not vcbase:
605610
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]
607612
m = re.search(r"\\VC\\Tools\\", vcbase)
608613
if m:
609614
# typical path on newer Visual Studios
610-
# prefer corresponding version but accept different version
615+
# prefere corresponding version but accept different version
611616
same_version = vcverdir is not None and os.path.isdir(
612617
vcbase[: m.start()]
613-
+ rf"\VC\Redist\MSVC\{vcverdir}{self.target_machine}"
618+
+ r"\VC\Redist\MSVC\{}{}".format(vcverdir, self.plat_dir)
614619
)
615620
redist_globs.append(
616621
vcbase[: m.start()]
617622
+ 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
619624
)
620625
)
621626
# Only mfcNNNu DLL is required (mfcmNNNX is Windows Forms, rest is ANSI)

0 commit comments

Comments
 (0)