Skip to content

Commit 0016300

Browse files
authored
Merge pull request #3198 from Flamefire/fix_git_version_check
Don't crash when GitPython is not installed in Python3
2 parents 1ad8919 + 9039e6a commit 0016300

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

easybuild/tools/version.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,18 @@ def get_git_revision():
5555
relies on GitPython (see http://gitorious.org/git-python)
5656
"""
5757
try:
58-
import git
58+
from git import Git, GitCommandError
5959
except ImportError:
6060
return UNKNOWN
6161
try:
6262
path = os.path.dirname(__file__)
63-
gitrepo = git.Git(path)
63+
gitrepo = Git(path)
6464
res = gitrepo.rev_list('HEAD').splitlines()[0]
6565
# 'encode' may be required to make sure a regular string is returned rather than a unicode string
6666
# (only needed in Python 2; in Python 3, regular strings are already unicode)
6767
if not isinstance(res, str):
6868
res = res.encode('ascii')
69-
except git.GitCommandError:
69+
except GitCommandError:
7070
res = UNKNOWN
7171

7272
return res

0 commit comments

Comments
 (0)