1919import unittest .mock as mock
2020import warnings
2121from 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,17 +559,34 @@ def link(
557559 else :
558560 log .debug ("skipping %s (up-to-date)" , output_filename )
559561
562+ @overload
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
560571 def spawn (
561572 self ,
562573 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 ,
563582 ):
564583 env = dict (os .environ , PATH = self ._paths )
565- with self ._fallback_spawn (cmd , env ) as fallback :
566- return super ().spawn (cmd , env = env )
584+ with self ._fallback_spawn (cmd , env , ** kwargs ) as fallback :
585+ return super ().spawn (cmd , env = env , ** kwargs )
567586 return fallback .value
568587
569588 @contextlib .contextmanager
570- def _fallback_spawn (self , cmd , env ):
589+ def _fallback_spawn (self , cmd , env , ** kwargs ):
571590 """
572591 Discovered in pypa/distutils#15, some tools monkeypatch the compiler,
573592 so the 'env' kwarg causes a TypeError. Detect this condition and
@@ -583,7 +602,7 @@ def _fallback_spawn(self, cmd, env):
583602 return
584603 warnings .warn ("Fallback spawn triggered. Please update distutils monkeypatch." )
585604 with mock .patch .dict ('os.environ' , env ):
586- bag .value = super ().spawn (cmd )
605+ bag .value = super ().spawn (cmd , ** kwargs )
587606
588607 # -- Miscellaneous methods -----------------------------------------
589608 # These are all used by the 'gen_lib_options() function, in
0 commit comments