Skip to content

Commit 7a1748e

Browse files
committed
Manual test fixes
1 parent 08ca7ba commit 7a1748e

File tree

4 files changed

+28
-7
lines changed

4 files changed

+28
-7
lines changed

distutils/compilers/C/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class Compiler:
7272
# dictionary (see below -- used by the 'new_compiler()' factory
7373
# function) -- authors of new compiler interface classes are
7474
# responsible for updating 'compiler_class'!
75-
compiler_type: ClassVar[str] = None # type: ignore[assignment]
75+
compiler_type: ClassVar[str] = None
7676

7777
# XXX things not handled by this compiler abstraction model:
7878
# * client can't provide additional options for a compiler,

distutils/compilers/C/msvc.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import unittest.mock as mock
2020
import warnings
2121
from collections.abc import Iterable, Sequence
22+
from typing import Literal, overload
2223

2324
with 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

distutils/compilers/C/tests/test_base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ def c_file(tmp_path):
1818
all_headers = gen_headers + plat_headers
1919
headers = '\n'.join(f'#include <{header}>\n' for header in all_headers)
2020
payload = (
21-
textwrap.dedent(
21+
textwrap
22+
.dedent(
2223
"""
2324
#headers
2425
void PyInit_foo(void) {}

distutils/spawn.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def _resolve(env: _MappingT) -> _MappingT: ...
5151
def _resolve(env: _MappingT | None) -> _MappingT | os._Environ[str]:
5252
return os.environ if env is None else env
5353

54+
5455
@overload
5556
def spawn(
5657
cmd: Sequence[bytes | os.PathLike[bytes] | str | os.PathLike[str]],

0 commit comments

Comments
 (0)