From b20198d815ae004c311d1b596d619757765af7c6 Mon Sep 17 00:00:00 2001 From: Jeff Wang Date: Thu, 15 Jan 2026 16:52:12 -0800 Subject: [PATCH] handle FileNotFoundError and OSError in _exec --- setuptools_git_versioning/git.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/setuptools_git_versioning/git.py b/setuptools_git_versioning/git.py index 622a680..288e522 100644 --- a/setuptools_git_versioning/git.py +++ b/setuptools_git_versioning/git.py @@ -19,6 +19,11 @@ def _exec(*cmd: str, root: str | os.PathLike | None = None) -> list[str]: stdout = subprocess.check_output(cmd, text=True, cwd=root) # noqa: S603 except subprocess.CalledProcessError as e: stdout = e.output + except (FileNotFoundError, OSError) as e: + # Handle case where git executable is not found + # FileNotFoundError on Unix, OSError on some other systems + log.log(DEBUG, "Command not found: %r", e) + stdout = "" lines = stdout.splitlines() return [line.rstrip() for line in lines if line.rstrip()]