Skip to content

Commit

Permalink
Add commit id into dev version setup (#597)
Browse files Browse the repository at this point in the history
* add commit id into dev version setup

* do not update version if can not get commit
  • Loading branch information
eaidova authored Mar 13, 2024
1 parent 6b4e24b commit 2588077
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 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,19 @@
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 = ""
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()
)
dev_version_id = "+" + dev_version_id
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 2588077

Please sign in to comment.