Skip to content

Do not fail metadata generation when git is unavailable#94

Open
plusky wants to merge 1 commit into
thuml:masterfrom
plusky:dont-fail-metadata-without-git
Open

Do not fail metadata generation when git is unavailable#94
plusky wants to merge 1 commit into
thuml:masterfrom
plusky:dont-fail-metadata-without-git

Conversation

@plusky

@plusky plusky commented Jul 13, 2026

Copy link
Copy Markdown

When building depyf from a released source tarball (e.g. downstream Linux distribution packaging), there is no git binary or repository available. get_git_commit_id() runs git rev-parse HEAD via subprocess.check_output, which raises FileNotFoundError when git is not installed. The except clause only catches subprocess.CalledProcessError, so the uncaught FileNotFoundError propagates and aborts metadata generation, breaking the whole build.

This adds FileNotFoundError to the caught exceptions so get_git_commit_id() returns None and get_version() falls back to the clean release version from depyf/VERSION.txt, exactly as it already does when git exits non-zero.

No behavior change when git is present.

get_git_commit_id() shells out to `git rev-parse HEAD` to append a commit
id to the version. When building from a released source tarball there is no
git binary and no repository, so subprocess raises FileNotFoundError, which
the handler does not catch -- aborting metadata generation (and thus the
whole build). Catch FileNotFoundError alongside CalledProcessError so the
clean release version from depyf/VERSION.txt is used instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant