Fix version tag (#2790)
Some checks failed
Build and Test / check_lint (push) Has been cancelled
Build and Test / linux_build_and_test (ubuntu-22.04) (push) Has been cancelled
Build and Test / linux_build_and_test (ubuntu-22.04-arm) (push) Has been cancelled
Build and Test / mac_build_and_test (14.0) (push) Has been cancelled
Build and Test / mac_build_and_test (15.0) (push) Has been cancelled
Build and Test / cuda_build_and_test (cuda-12.6) (push) Has been cancelled
Build and Test / cuda_build_and_test (cuda-12.9) (push) Has been cancelled
Build and Test / build_documentation (push) Has been cancelled
Build and Test / Linux Fedora CPP Build (aarch64) (push) Has been cancelled
Build and Test / Linux Fedora CPP Build (x86_64) (push) Has been cancelled

This commit is contained in:
Awni Hannun
2025-11-19 08:55:57 -08:00
committed by GitHub
parent f46877bc08
commit ad16f41a7f

View File

@@ -24,21 +24,22 @@ def get_version():
if "#define MLX_VERSION_PATCH" in l:
patch = l.split()[-1]
version = f"{major}.{minor}.{patch}"
if os.environ.get("PYPI_RELEASE", False):
pypi_release = os.environ.get("PYPI_RELEASE", False)
dev_release = os.environ.get("DEV_RELEASE", False)
if not pypi_release or dev_release:
today = datetime.date.today()
version = f"{version}.dev{today.year}{today.month:02d}{today.day:02d}"
if os.environ.get("DEV_RELEASE", False):
git_hash = (
run(
"git rev-parse --short HEAD".split(),
capture_output=True,
check=True,
)
.stdout.strip()
.decode()
if not pypi_release and not dev_release:
git_hash = (
run(
"git rev-parse --short HEAD".split(),
capture_output=True,
check=True,
)
version = f"{version}+{git_hash}"
.stdout.strip()
.decode()
)
version = f"{version}+{git_hash}"
return version