summaryrefslogtreecommitdiff
path: root/src/setuptools_scm/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/setuptools_scm/utils.py')
-rw-r--r--src/setuptools_scm/utils.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/setuptools_scm/utils.py b/src/setuptools_scm/utils.py
index 09d8af7..6788f23 100644
--- a/src/setuptools_scm/utils.py
+++ b/src/setuptools_scm/utils.py
@@ -3,6 +3,8 @@ utils
"""
from __future__ import annotations
+import logging
+import subprocess
import sys
import warnings
from types import CodeType
@@ -16,6 +18,8 @@ from . import _trace
if TYPE_CHECKING:
from . import _types as _t
+log = logging.getLogger(__name__)
+
class _CmdResult(NamedTuple):
out: str
@@ -54,10 +58,15 @@ def function_has_arg(fn: object | FunctionType, argname: str) -> bool:
def has_command(name: str, args: list[str] | None = None, warn: bool = True) -> bool:
try:
cmd = [name, "help"] if args is None else [name, *args]
- p = _run_cmd.run(cmd, ".")
+ p = _run_cmd.run(cmd, cwd=".", timeout=5)
except OSError:
_trace.trace(*sys.exc_info())
res = False
+ except subprocess.TimeoutExpired as e:
+ log.info(e)
+ _trace.trace(e)
+ res = False
+
else:
res = not p.returncode
if not res and warn: