Skip to content

Commit

Permalink
add commit id into dev version setup
Browse files Browse the repository at this point in the history
  • Loading branch information
eaidova committed Mar 11, 2024
1 parent 72b0630 commit 955eac6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import os
import re
import subprocess

from setuptools import find_namespace_packages, setup

Expand All @@ -8,6 +10,18 @@
filepath = "optimum/intel/version.py"
with open(filepath) as version_file:
(__version__,) = re.findall('__version__ = "(.*)"', version_file.read())
if __version__.endswith(".dev0"):
dev_version_id = "unknown_version"
try:
repo_root = os.path.dirname(os.path.realpath(__file__))
dev_version_id = (
subprocess.check_output(["git", "rev-parse", "--short", "HEAD"], cwd=repo_root) # nosec
.strip()
.decode()
)
except subprocess.CalledProcessError:
pass
__version__ = __version__ + "+" + dev_version_id
except Exception as error:
assert False, "Error: Could not open '%s' due %s\n" % (filepath, error)

Expand Down

0 comments on commit 955eac6

Please sign in to comment.