1818import subprocess
1919import unittest .mock as mock
2020import warnings
21- from collections .abc import Iterable
21+ from collections .abc import Iterable , Sequence
22+ from typing import Literal , overload
2223
2324with contextlib .suppress (ImportError ):
2425 import winreg
@@ -95,7 +96,8 @@ def _find_vc2017():
9596 subprocess .CalledProcessError , OSError , UnicodeDecodeError
9697 ):
9798 path = (
98- subprocess .check_output ([
99+ subprocess
100+ .check_output ([
99101 os .path .join (
100102 root , "Microsoft Visual Studio" , "Installer" , "vswhere.exe"
101103 ),
@@ -557,14 +559,34 @@ def link(
557559 else :
558560 log .debug ("skipping %s (up-to-date)" , output_filename )
559561
560- def spawn (self , cmd ):
562+ @overload # type: ignore[override] # env param not available
563+ def spawn (
564+ self ,
565+ cmd : Sequence [bytes | os .PathLike [bytes ] | str | os .PathLike [str ]],
566+ * ,
567+ search_path : Literal [False ],
568+ verbose : bool = False ,
569+ ) -> None : ...
570+ @overload
571+ def spawn (
572+ self ,
573+ cmd : Sequence [bytes | str | os .PathLike [str ]],
574+ * ,
575+ search_path : Literal [True ] = True ,
576+ verbose : bool = False ,
577+ ) -> None : ...
578+ def spawn (
579+ self ,
580+ cmd : Sequence [bytes | os .PathLike [bytes ] | str | os .PathLike [str ]],
581+ ** kwargs ,
582+ ):
561583 env = dict (os .environ , PATH = self ._paths )
562- with self ._fallback_spawn (cmd , env ) as fallback :
563- return super ().spawn (cmd , env = env )
584+ with self ._fallback_spawn (cmd , env , ** kwargs ) as fallback :
585+ return super ().spawn (cmd , env = env , ** kwargs )
564586 return fallback .value
565587
566588 @contextlib .contextmanager
567- def _fallback_spawn (self , cmd , env ):
589+ def _fallback_spawn (self , cmd , env , ** kwargs ):
568590 """
569591 Discovered in pypa/distutils#15, some tools monkeypatch the compiler,
570592 so the 'env' kwarg causes a TypeError. Detect this condition and
@@ -580,7 +602,7 @@ def _fallback_spawn(self, cmd, env):
580602 return
581603 warnings .warn ("Fallback spawn triggered. Please update distutils monkeypatch." )
582604 with mock .patch .dict ('os.environ' , env ):
583- bag .value = super ().spawn (cmd )
605+ bag .value = super ().spawn (cmd , ** kwargs )
584606
585607 # -- Miscellaneous methods -----------------------------------------
586608 # These are all used by the 'gen_lib_options() function, in
0 commit comments