diff options
author | Ronny Pfannschmidt <opensource@ronnypfannschmidt.de> | 2023-03-14 10:30:01 +0100 |
---|---|---|
committer | Ronny Pfannschmidt <opensource@ronnypfannschmidt.de> | 2023-03-14 17:37:40 +0100 |
commit | 3bee5b998ce990f26ed6a5ff97a10c2e9b087e5b (patch) | |
tree | 0f512b494fb451c484c5b9d5c7103169a7687770 /src/setuptools_scm | |
parent | 2f22818fcbbcc7aa68f0111d5b3eb0f40a628891 (diff) | |
download | setuptools-scm-3bee5b998ce990f26ed6a5ff97a10c2e9b087e5b.tar.gz |
pre-commit autoupdate + has_command fix
Diffstat (limited to 'src/setuptools_scm')
-rw-r--r-- | src/setuptools_scm/utils.py | 11 |
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: |