diff --git a/README.md b/README.md
index 8522468c7..bdcd922ac 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@ AutoRound
Advanced Quantization Algorithm for LLMs
[](https://github.com/intel/auto-round)
-[](https://github.com/intel/auto-round)
+[](https://github.com/intel/auto-round)
[](https://github.com/intel/auto-round/blob/main/LICENSE)
diff --git a/auto_round/version.py b/auto_round/version.py
index c9c2dfb35..159f318f8 100644
--- a/auto_round/version.py
+++ b/auto_round/version.py
@@ -14,4 +14,4 @@
"""IntelĀ® auto-round: An open-source Python library
supporting popular model weight only compression based on signround."""
-__version__ = "0.8.0.dev"
+__version__ = "0.9.0"
diff --git a/setup.py b/setup.py
index 152359b19..119883c8f 100644
--- a/setup.py
+++ b/setup.py
@@ -1,5 +1,6 @@
import os
import re
+import subprocess
import sys
from functools import lru_cache
from io import open
@@ -15,14 +16,35 @@
except Exception as error:
assert False, "Error: Could not open '%s' due %s\n" % (filepath, error)
-version = __version__
-
# All BUILD_* flags are initially set to `False`` and
# will be updated to `True` if the corresponding environment check passes.
PYPI_RELEASE = os.environ.get("PYPI_RELEASE", None)
BUILD_HPU_ONLY = os.environ.get("BUILD_HPU_ONLY", "0") == "1"
+def is_commit_on_tag():
+ try:
+ result = subprocess.run(
+ ["git", "describe", "--exact-match", "--tags"], capture_output=True, text=True, check=True
+ )
+ tag_name = result.stdout.strip()
+ return tag_name
+ except subprocess.CalledProcessError:
+ return False
+
+
+def get_build_version():
+ if is_commit_on_tag():
+ return __version__
+ try:
+ result = subprocess.run(["git", "describe", "--tags"], capture_output=True, text=True, check=True)
+ distance = result.stdout.strip().split("-")[-2]
+ commit = result.stdout.strip().split("-")[-1]
+ return f"{__version__}.dev{distance}+{commit}"
+ except subprocess.CalledProcessError:
+ return __version__
+
+
@lru_cache(None)
def is_habana_framework_installed():
"""Check if Habana framework is installed.
@@ -143,7 +165,7 @@ def fetch_requirements(path):
setup(
name=package_name,
author="Intel AIPT Team",
- version=version,
+ version=get_build_version(),
author_email="wenhua.cheng@intel.com, weiwei1.zhang@intel.com, heng.guo@intel.com",
description="Repository of AutoRound: Advanced Weight-Only Quantization Algorithm for LLMs",
long_description=open("README.md", "r", encoding="utf-8").read(),