Skip to content

Commit 2588077

Browse files
authored
Add commit id into dev version setup (#597)
* add commit id into dev version setup * do not update version if can not get commit
1 parent 6b4e24b commit 2588077

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

setup.py

+15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import os
12
import re
3+
import subprocess
24

35
from setuptools import find_namespace_packages, setup
46

@@ -8,6 +10,19 @@
810
filepath = "optimum/intel/version.py"
911
with open(filepath) as version_file:
1012
(__version__,) = re.findall('__version__ = "(.*)"', version_file.read())
13+
if __version__.endswith(".dev0"):
14+
dev_version_id = ""
15+
try:
16+
repo_root = os.path.dirname(os.path.realpath(__file__))
17+
dev_version_id = (
18+
subprocess.check_output(["git", "rev-parse", "--short", "HEAD"], cwd=repo_root) # nosec
19+
.strip()
20+
.decode()
21+
)
22+
dev_version_id = "+" + dev_version_id
23+
except subprocess.CalledProcessError:
24+
pass
25+
__version__ = __version__ + dev_version_id
1126
except Exception as error:
1227
assert False, "Error: Could not open '%s' due %s\n" % (filepath, error)
1328

0 commit comments

Comments
 (0)