-
Notifications
You must be signed in to change notification settings - Fork 418
[Feature] Add build date to version metadata #1742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| """Version utilities for tilelang.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import re | ||
|
|
||
|
|
||
| def build_date(version_str: str | None = None) -> int | None: | ||
| """Extract build date (YYYYMMDD) from version string. | ||
| Args: | ||
| version_str: Version string like "0.1.7.post3+cuda.d20260127.gita17230e4". | ||
| If None, uses tilelang.__version__. | ||
| Returns: | ||
| Build date as integer (e.g., 20260127), or None if not found. | ||
| Example: | ||
| >>> import tilelang | ||
| >>> if tilelang.build_date() >= 20260127: | ||
| ... print("Version meets requirement") | ||
| """ | ||
| if version_str is None: | ||
| import tilelang | ||
|
|
||
| version_str = tilelang.__version__ | ||
|
|
||
| match = re.search(r"\.d(\d{8})\.", version_str) | ||
| if match: | ||
| return int(match.group(1)) | ||
| return None | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| import os | ||
| import platform | ||
| import subprocess | ||
| import time | ||
| from pathlib import Path | ||
| from functools import lru_cache | ||
|
|
||
|
|
@@ -71,6 +72,10 @@ def dynamic_metadata(field: str, settings: dict[str, object] | None = None) -> s | |
| if backend: | ||
| exts.append(backend) | ||
|
|
||
| # Add build date if TILELANG_BUILD_WHEEL_WITH_DATE is set | ||
| if _read_cmake_bool(os.environ.get("TILELANG_BUILD_WHEEL_WITH_DATE")): | ||
| exts.append(f"d{time.strftime('%Y%m%d')}") | ||
|
|
||
|
Comment on lines
+75
to
+78
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential regex mismatch when date is the last extension. The Consider updating the regex in Suggested fix in tilelang/utils/version.py- match = re.search(r"\.d(\d{8})\.", version_str)
+ match = re.search(r"\.d(\d{8})(?:\.|$)", version_str)This allows matching when the date is followed by either a dot or end-of-string. 🤖 Prompt for AI Agents |
||
| if _read_cmake_bool(os.environ.get("NO_GIT_VERSION")): | ||
| pass | ||
| elif git_hash := get_git_commit_id(): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regex pattern requires trailing dot — see related comment in
version_provider.py.As noted in the version_provider.py review, this pattern won't match version strings where the date is the final segment (e.g.,
0.1.7+cuda.d20260127).Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents