1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-02-25 05:57:51 +00:00

utils/version: add get_commit

Add a function to get the commit ID of the devlib repository (if running
from source, e.g. via "setup.py develop").
This commit is contained in:
Sergei Trofimov 2018-06-14 16:25:42 +01:00 committed by setrofim
parent f1c945bb5e
commit 4a862d06bb

15
devlib/utils/version.py Normal file

@ -0,0 +1,15 @@
import os
import sys
from subprocess import Popen, PIPE
def get_commit():
p = Popen(['git', 'rev-parse', 'HEAD'], cwd=os.path.dirname(__file__),
stdout=PIPE, stderr=PIPE)
std, _ = p.communicate()
p.wait()
if p.returncode:
return None
if sys.version_info[0] == 3:
return std[:8].decode(sys.stdout.encoding)
else:
return std[:8]