Skip to content

Commit 2620467

Browse files
fix: longer timeout on Windows (#974)
Make sure this doesn't trigger unless it's locked up. Windows can take more than 2 seconds to respond in our CI. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 316ec94 commit 2620467

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/scikit_build_core/program_search.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import json
55
import shutil
66
import subprocess
7+
import sys
78
from pathlib import Path
89
from typing import TYPE_CHECKING, NamedTuple
910

@@ -32,6 +33,10 @@ def __dir__() -> list[str]:
3233
return __all__
3334

3435

36+
# Make sure we don't wait forever for programs to respond
37+
TIMEOUT = 10 if sys.platform.startswith("win") else 4
38+
39+
3540
class Program(NamedTuple):
3641
path: Path
3742
version: Version | None
@@ -80,7 +85,7 @@ def get_cmake_program(cmake_path: Path) -> Program:
8085
None if it cannot be determined.
8186
"""
8287
try:
83-
result = Run(timeout=2).capture(cmake_path, "-E", "capabilities")
88+
result = Run(timeout=TIMEOUT).capture(cmake_path, "-E", "capabilities")
8489
try:
8590
version = Version(
8691
json.loads(result.stdout)["version"]["string"].split("-")[0]
@@ -91,7 +96,7 @@ def get_cmake_program(cmake_path: Path) -> Program:
9196
logger.warning("Could not determine CMake version, got {!r}", result.stdout)
9297
except subprocess.CalledProcessError:
9398
try:
94-
result = Run(timeout=2).capture(cmake_path, "--version")
99+
result = Run(timeout=TIMEOUT).capture(cmake_path, "--version")
95100
try:
96101
version = Version(
97102
result.stdout.splitlines()[0].split()[-1].split("-")[0]
@@ -135,7 +140,7 @@ def get_ninja_programs(*, module: bool = True) -> Generator[Program, None, None]
135140
"""
136141
for ninja_path in _get_ninja_path(module=module):
137142
try:
138-
result = Run(timeout=2).capture(ninja_path, "--version")
143+
result = Run(timeout=TIMEOUT).capture(ninja_path, "--version")
139144
except (
140145
subprocess.CalledProcessError,
141146
PermissionError,

0 commit comments

Comments
 (0)