Skip to content

Commit d3c74a4

Browse files
committed
fix: preserve exact release version during wheel builds
Signed-off-by: AlpinDale <alpindale@gmail.com>
1 parent ae4d41d commit d3c74a4

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

setup.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ def load_module_from_path(module_name, path):
3030
ROOT_DIR = Path(os.path.dirname(__file__))
3131
logger = logging.getLogger(__name__)
3232

33+
# Capture the SCM-derived version before setup-time generated files dirty an
34+
# exact-tag checkout. Otherwise release Docker builds can become
35+
# `<next>.dev0+g<sha>.d<date>` after `embed_commit_hash()` writes commit_id.py.
36+
_SCM_VERSION = None if os.getenv("APHRODITE_VERSION_OVERRIDE") else get_version(write_to="aphrodite/_version.py")
37+
3338

3439
def embed_commit_hash():
3540
try:
@@ -535,7 +540,8 @@ def get_aphrodite_version() -> str:
535540
if env_version := os.getenv("APHRODITE_VERSION_OVERRIDE"):
536541
return env_version
537542

538-
version = get_version(write_to="aphrodite/_version.py")
543+
assert _SCM_VERSION is not None
544+
version = _SCM_VERSION
539545
sep = "+" if "+" not in version else "." # dev versions might contain +
540546

541547
if _no_device():

0 commit comments

Comments
 (0)