Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/scikit_build_core/_shutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __dir__() -> list[str]:
class Run:
env: dict[str, str] | None = None
cwd: os.PathLike[str] | None = None
timeout: None | float = None

# Stores last printout, for cleaner debug logging
_prev_env: ClassVar[dict[str, str]] = {}
Expand Down Expand Up @@ -75,6 +76,7 @@ def _run(
capture_output=capture,
env=self.env,
cwd=self.cwd,
timeout=self.timeout,
)

def _key_diff(self, k: str) -> str:
Expand Down
14 changes: 10 additions & 4 deletions src/scikit_build_core/program_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
None if it cannot be determined.
"""
try:
result = Run().capture(cmake_path, "-E", "capabilities")
result = Run(timeout=2).capture(cmake_path, "-E", "capabilities")
try:
version = Version(
json.loads(result.stdout)["version"]["string"].split("-")[0]
Expand All @@ -91,7 +91,7 @@
logger.warning("Could not determine CMake version, got {!r}", result.stdout)
except subprocess.CalledProcessError:
try:
result = Run().capture(cmake_path, "--version")
result = Run(timeout=2).capture(cmake_path, "--version")

Check warning on line 94 in src/scikit_build_core/program_search.py

View check run for this annotation

Codecov / codecov/patch

src/scikit_build_core/program_search.py#L94

Added line #L94 was not covered by tests
try:
version = Version(
result.stdout.splitlines()[0].split()[-1].split("-")[0]
Expand All @@ -111,6 +111,8 @@
)
except PermissionError:
logger.warning("Permissions Error getting CMake's version")
except subprocess.TimeoutExpired:
logger.warning("Accessing CMake timed out, ignoring")

Check warning on line 115 in src/scikit_build_core/program_search.py

View check run for this annotation

Codecov / codecov/patch

src/scikit_build_core/program_search.py#L114-L115

Added lines #L114 - L115 were not covered by tests

return Program(cmake_path, None)

Expand All @@ -133,8 +135,12 @@
"""
for ninja_path in _get_ninja_path(module=module):
try:
result = Run().capture(ninja_path, "--version")
except (subprocess.CalledProcessError, PermissionError):
result = Run(timeout=2).capture(ninja_path, "--version")
except (

Check warning on line 139 in src/scikit_build_core/program_search.py

View check run for this annotation

Codecov / codecov/patch

src/scikit_build_core/program_search.py#L139

Added line #L139 was not covered by tests
subprocess.CalledProcessError,
PermissionError,
subprocess.TimeoutExpired,
):
yield Program(ninja_path, None)
continue

Expand Down
Loading