Correctly detect a git checkout. Refs #8090. Fixes #8266.

The problem is that when we `exec()` the version code from `setup.py`, the `__file__` paths changed and we were "missing" the `.git` directory.
Merge pull request #8268 from s0undt3ch/develop

Correctly detect a git checkout. Refs #8090. Fixes #8266.