Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tilelang/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def _load_tile_lang_lib():
from .utils import (
TensorSupplyType, # noqa: F401
deprecated, # noqa: F401
build_date, # noqa: F401
)
from .layout import (
Layout, # noqa: F401
Expand Down
1 change: 1 addition & 0 deletions tilelang/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@
side_effect, # noqa: F401
)
from .deprecated import deprecated # noqa: F401
from .version import build_date # noqa: F401
31 changes: 31 additions & 0 deletions tilelang/utils/version.py
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
Comment on lines +28 to +31
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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
-    match = re.search(r"\.d(\d{8})\.", version_str)
+    match = re.search(r"\.d(\d{8})(?:\.|$)", version_str)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
match = re.search(r"\.d(\d{8})\.", version_str)
if match:
return int(match.group(1))
return None
match = re.search(r"\.d(\d{8})(?:\.|$)", version_str)
if match:
return int(match.group(1))
return None
🤖 Prompt for AI Agents
In `@tilelang/utils/version.py` around lines 28 - 31, The regex in
tilelang/utils/version.py that searches version_str currently requires a
trailing dot after the date (r"\.d(\d{8})\."), so it fails for strings where the
date is the final segment; update the pattern used in the re.search call to
accept either a trailing dot or the end of the string (i.e., allow ".dYYYYMMDD"
followed by a dot OR end-of-string), leaving the rest of the logic (using
match.group(1) and returning int or None) unchanged.

5 changes: 5 additions & 0 deletions version_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import platform
import subprocess
import time
from pathlib import Path
from functools import lru_cache

Expand Down Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Potential regex mismatch when date is the last extension.

The build_date() function in tilelang/utils/version.py uses the regex \.d(\d{8})\. which requires a trailing dot after the date. However, if NO_GIT_VERSION is set (or git hash is unavailable), the date becomes the last extension and the version string would be like 0.1.7+cuda.d20260127 — no trailing dot, so build_date() returns None.

Consider updating the regex in version.py to make the trailing dot optional, or ensure the date is never the last segment.

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
In `@version_provider.py` around lines 75 - 78, The build_date() regex in
tilelang/utils/version.py fails when the date is the last extension (e.g.,
0.1.7+cuda.d20260127) because it requires a trailing dot; update the pattern
used in build_date() to allow either a dot or end-of-string (make the trailing
dot optional) so it matches `\.d(\d{8})(?:\.|$)` (or equivalent), ensuring the
function correctly returns the date when NO_GIT_VERSION or similar makes the
date the final segment.

if _read_cmake_bool(os.environ.get("NO_GIT_VERSION")):
pass
elif git_hash := get_git_commit_id():
Expand Down
Loading