Skip to content

Commit 9052e31

Browse files
authored
Add commit hash to version (#941)
Signed-off-by: Sun, Xuehao <xuehao.sun@intel.com>
1 parent 045a27d commit 9052e31

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ AutoRound
66
<h3> Advanced Quantization Algorithm for LLMs</h3>
77

88
[![python](https://img.shields.io/badge/python-3.10%2B-blue)](https://github.com/intel/auto-round)
9-
[![version](https://img.shields.io/badge/release-0.7.1-green)](https://github.com/intel/auto-round)
9+
[![version](https://img.shields.io/badge/release-0.8.0-green)](https://github.com/intel/auto-round)
1010
[![license](https://img.shields.io/badge/license-Apache%202-9C27B0)](https://github.com/intel/auto-round/blob/main/LICENSE)
1111
<a href="https://huggingface.co/Intel">
1212
<img alt="Model Checkpoints" src="https://img.shields.io/badge/%F0%9F%A4%97%20HF-Models-F57C00">

auto_round/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
"""Intel® auto-round: An open-source Python library
1515
supporting popular model weight only compression based on signround."""
1616

17-
__version__ = "0.8.0.dev"
17+
__version__ = "0.9.0"

setup.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import re
3+
import subprocess
34
import sys
45
from functools import lru_cache
56
from io import open
@@ -15,14 +16,35 @@
1516
except Exception as error:
1617
assert False, "Error: Could not open '%s' due %s\n" % (filepath, error)
1718

18-
version = __version__
19-
2019
# All BUILD_* flags are initially set to `False`` and
2120
# will be updated to `True` if the corresponding environment check passes.
2221
PYPI_RELEASE = os.environ.get("PYPI_RELEASE", None)
2322
BUILD_HPU_ONLY = os.environ.get("BUILD_HPU_ONLY", "0") == "1"
2423

2524

25+
def is_commit_on_tag():
26+
try:
27+
result = subprocess.run(
28+
["git", "describe", "--exact-match", "--tags"], capture_output=True, text=True, check=True
29+
)
30+
tag_name = result.stdout.strip()
31+
return tag_name
32+
except subprocess.CalledProcessError:
33+
return False
34+
35+
36+
def get_build_version():
37+
if is_commit_on_tag():
38+
return __version__
39+
try:
40+
result = subprocess.run(["git", "describe", "--tags"], capture_output=True, text=True, check=True)
41+
distance = result.stdout.strip().split("-")[-2]
42+
commit = result.stdout.strip().split("-")[-1]
43+
return f"{__version__}.dev{distance}+{commit}"
44+
except subprocess.CalledProcessError:
45+
return __version__
46+
47+
2648
@lru_cache(None)
2749
def is_habana_framework_installed():
2850
"""Check if Habana framework is installed.
@@ -143,7 +165,7 @@ def fetch_requirements(path):
143165
setup(
144166
name=package_name,
145167
author="Intel AIPT Team",
146-
version=version,
168+
version=get_build_version(),
147169
author_email="wenhua.cheng@intel.com, weiwei1.zhang@intel.com, heng.guo@intel.com",
148170
description="Repository of AutoRound: Advanced Weight-Only Quantization Algorithm for LLMs",
149171
long_description=open("README.md", "r", encoding="utf-8").read(),

0 commit comments

Comments
 (0)