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
26 changes: 9 additions & 17 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import os
import platform
import re
import shutil
import sys
import winreg
from collections.abc import MutableSequence
Expand Down Expand Up @@ -903,31 +902,24 @@ def key_reverse_mc(a):
return MSVCCompiler.compile(self, sources, **kwargs)

def spawn(self, cmd: MutableSequence[str]) -> None: # type: ignore[override] # More restrictive than supertype
is_link = cmd[0].endswith("link.exe") or cmd[0].endswith('"link.exe"')
is_mt = cmd[0].endswith("mt.exe") or cmd[0].endswith('"mt.exe"')
if is_mt:
# We don't want mt.exe run...
return
assert not is_mt, (
"We don't want mt.exe run. We used to special case it,"
+ " now just sanity check that this is unreachable"
)
is_link = cmd[0].endswith("link.exe") or cmd[0].endswith('"link.exe"')
if is_link:
# remove /MANIFESTFILE:... and add MANIFEST:NO
for i in range(len(cmd)):
if cmd[i].startswith(("/MANIFESTFILE:", "/MANIFEST:EMBED")):
cmd[i] = "/MANIFEST:NO"
break
if is_mt:
# We want mt.exe run with the original manifest
for i in range(len(cmd)):
if cmd[i] == "-manifest":
cmd[i + 1] += ".orig"
break
super().spawn(cmd) # type: ignore[arg-type] # mypy variance issue, but pyright ok
if is_link:
# We want a copy of the original manifest so we can use it later.
for i in range(len(cmd)):
if cmd[i].startswith("/MANIFESTFILE:"):
mfname = cmd[i][14:]
shutil.copyfile(mfname, mfname + ".orig")
break
assert not any(arg.startswith("/MANIFESTFILE:") for arg in cmd), (
"We used to copy the original manifest so we can use it later,"
+ " now just sanity check that this is unreachable"
)

# CCompiler's implementations of these methods completely replace the values
# determined by the build environment. This seems like a design that must
Expand Down