Skip to content

Commit

Permalink
fix: longer timeout on Windows (#974)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
henryiii and pre-commit-ci[bot] authored Jan 17, 2025
1 parent 316ec94 commit 2620467
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/scikit_build_core/program_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import json
import shutil
import subprocess
import sys
from pathlib import Path
from typing import TYPE_CHECKING, NamedTuple

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


# Make sure we don't wait forever for programs to respond
TIMEOUT = 10 if sys.platform.startswith("win") else 4


class Program(NamedTuple):
path: Path
version: Version | None
Expand Down Expand Up @@ -80,7 +85,7 @@ def get_cmake_program(cmake_path: Path) -> Program:
None if it cannot be determined.
"""
try:
result = Run(timeout=2).capture(cmake_path, "-E", "capabilities")
result = Run(timeout=TIMEOUT).capture(cmake_path, "-E", "capabilities")
try:
version = Version(
json.loads(result.stdout)["version"]["string"].split("-")[0]
Expand All @@ -91,7 +96,7 @@ def get_cmake_program(cmake_path: Path) -> Program:
logger.warning("Could not determine CMake version, got {!r}", result.stdout)
except subprocess.CalledProcessError:
try:
result = Run(timeout=2).capture(cmake_path, "--version")
result = Run(timeout=TIMEOUT).capture(cmake_path, "--version")
try:
version = Version(
result.stdout.splitlines()[0].split()[-1].split("-")[0]
Expand Down Expand Up @@ -135,7 +140,7 @@ def get_ninja_programs(*, module: bool = True) -> Generator[Program, None, None]
"""
for ninja_path in _get_ninja_path(module=module):
try:
result = Run(timeout=2).capture(ninja_path, "--version")
result = Run(timeout=TIMEOUT).capture(ninja_path, "--version")
except (
subprocess.CalledProcessError,
PermissionError,
Expand Down

0 comments on commit 2620467

Please sign in to comment.