Skip to content

Commit 4d4b784

Browse files
committed
Redundant checks in my_compiler.spawn
1 parent d764900 commit 4d4b784

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

setup.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import os
3131
import platform
3232
import re
33-
import shutil
3433
import sys
3534
import winreg
3635
from collections.abc import MutableSequence
@@ -925,31 +924,24 @@ def key_reverse_mc(a):
925924
return MSVCCompiler.compile(self, sources, **kwargs)
926925

927926
def spawn(self, cmd: MutableSequence[str]) -> None: # type: ignore[override] # More restrictive than supertype
928-
is_link = cmd[0].endswith("link.exe") or cmd[0].endswith('"link.exe"')
929927
is_mt = cmd[0].endswith("mt.exe") or cmd[0].endswith('"mt.exe"')
930-
if is_mt:
931-
# We don't want mt.exe run...
932-
return
928+
assert not is_mt, (
929+
"We don't want mt.exe run. We used to special case it,"
930+
+ " now just sanity check that this is unreachable"
931+
)
932+
is_link = cmd[0].endswith("link.exe") or cmd[0].endswith('"link.exe"')
933933
if is_link:
934934
# remove /MANIFESTFILE:... and add MANIFEST:NO
935935
for i in range(len(cmd)):
936936
if cmd[i].startswith(("/MANIFESTFILE:", "/MANIFEST:EMBED")):
937937
cmd[i] = "/MANIFEST:NO"
938938
break
939-
if is_mt:
940-
# We want mt.exe run with the original manifest
941-
for i in range(len(cmd)):
942-
if cmd[i] == "-manifest":
943-
cmd[i + 1] += ".orig"
944-
break
945939
super().spawn(cmd) # type: ignore[arg-type] # mypy variance issue, but pyright ok
946940
if is_link:
947-
# We want a copy of the original manifest so we can use it later.
948-
for i in range(len(cmd)):
949-
if cmd[i].startswith("/MANIFESTFILE:"):
950-
mfname = cmd[i][14:]
951-
shutil.copyfile(mfname, mfname + ".orig")
952-
break
941+
assert not any(arg.startswith("/MANIFESTFILE:") for arg in cmd), (
942+
"We used to copy the original manifest so we can use it later,"
943+
+ " now just sanity check that this is unreachable"
944+
)
953945

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

0 commit comments

Comments
 (0)