Skip to content

Commit 16961b7

Browse files
Fix version when using source tarballs (#7164)
In tarballs there is not git information and `git` would check every parent folder potentially returning unrelated information. Verify that `setup.py` is run from a git checkout and bail out otherwise. The existence of the `.git` folder should be a good enough indicator for that. # New contributor declaration - [x] I am not making a trivial change, such as fixing a typo in a comment. - [x] I have written a PR description following these [rules](https://cbea.ms/git-commit/#why-not-how). - [x] I have run `pre-commit run --from-ref origin/main --to-ref HEAD`. - Select one of the following. - [x] This PR does not need a test because it changes the setup.py file only - Select one of the following. - [x] I have not added any `lit` tests. --------- Co-authored-by: peterbell10 <[email protected]>
1 parent 05adafe commit 16961b7

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,8 @@ def get_git_branch():
756756

757757

758758
def get_git_version_suffix():
759+
if not (Path(__file__).parent / ".git").is_dir():
760+
return "" # Not a git checkout
759761
branch = get_git_branch()
760762
if branch.startswith("release"):
761763
return ""

0 commit comments

Comments
 (0)