Skip to content

Commit 7ea9d73

Browse files
committed
Redundant checks in my_compiler.spawn
1 parent d764900 commit 7ea9d73

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

setup.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -925,31 +925,24 @@ def key_reverse_mc(a):
925925
return MSVCCompiler.compile(self, sources, **kwargs)
926926

927927
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"')
929928
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
929+
assert not is_mt, (
930+
"We don't want mt.exe run. We used to special case it,"
931+
+ " now just sanity check that this is unreachable"
932+
)
933+
is_link = cmd[0].endswith("link.exe") or cmd[0].endswith('"link.exe"')
933934
if is_link:
934935
# remove /MANIFESTFILE:... and add MANIFEST:NO
935936
for i in range(len(cmd)):
936937
if cmd[i].startswith(("/MANIFESTFILE:", "/MANIFEST:EMBED")):
937938
cmd[i] = "/MANIFEST:NO"
938939
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
945940
super().spawn(cmd) # type: ignore[arg-type] # mypy variance issue, but pyright ok
946941
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
942+
assert not any(arg.startswith("/MANIFESTFILE:") for arg in cmd), (
943+
"We used to copy the original manifest so we can use it later,"
944+
+ " now just sanity check that this is unreachable"
945+
)
953946

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

0 commit comments

Comments
 (0)