chore: import upstream snapshot with attribution
PR Test (NPU) / check-changes (push) Has been cancelled
PR Test (NPU) / pr-gate (push) Has been cancelled
PR Test (NPU) / set-image-config (push) Has been cancelled
PR Test (NPU) / stage-b-test-1-npu-a2 (0) (push) Has been cancelled
PR Test (NPU) / stage-b-test-1-npu-a2 (1) (push) Has been cancelled
PR Test (NPU) / stage-b-test-2-npu-a2 (0) (push) Has been cancelled
PR Test (NPU) / stage-b-test-2-npu-a2 (1) (push) Has been cancelled
PR Test (NPU) / stage-b-test-4-npu-a3 (push) Has been cancelled
PR Test (NPU) / stage-b-test-16-npu-a3 (push) Has been cancelled
PR Test (NPU) / multimodal-gen-test-1-npu-a3 (push) Has been cancelled
PR Test (NPU) / multimodal-gen-test-2-npu-a3 (push) Has been cancelled
PR Test (Arm64) / pr-gate (push) Has been cancelled
PR Test (Arm64) / check-changes (push) Has been cancelled
PR Test (Arm64) / build-test (push) Has been cancelled
PR Test (sgl-router) / gate (push) Has been cancelled
PR Test (sgl-router) / tier-1 — lint (push) Has been cancelled
PR Test (sgl-router) / tier-2 — build + test (push) Has been cancelled
PR Test (sgl-router) / tier-3 — docker (placeholder) (push) Has been cancelled
PR Test (sgl-router) / tier-3 — k8s integration (push) Has been cancelled
PR Test (sgl-router) / tier-3 — e2e (push) Has been cancelled
PR Test (sgl-router) / finish (push) Has been cancelled
PR Test (NPU) / single-node-poc (map[name:qwen3_6_27b_w8a8_1p_in64k_out1k_50ms runner:linux-aarch64-a3-2 test_case:test/registered/ascend/performance/qwen3_6_27b/test_npu_qwen3_6_27b_w8a8_1p_in64k_out1k_50ms.py test_type:perf]) (push) Has been cancelled
PR Test (NPU) / pr-test-npu-finish (push) Has been cancelled
PR Test (Xeon) / pr-gate (push) Has been cancelled
PR Test (Xeon) / check-changes (push) Has been cancelled
PR Test (Xeon) / build-test (, xeon-gnr, base-b-test-cpu) (push) Has been cancelled
PR Test (XPU) / check-changes (push) Has been cancelled
PR Test (XPU) / pr-gate (push) Has been cancelled
PR Test (XPU) / stage-a-test-1-gpu-xpu (push) Has been cancelled
PR Test (XPU) / wait-for-stage-a (push) Has been cancelled
PR Test (XPU) / stage-b-test-1-gpu-xpu (push) Has been cancelled
PR Test (XPU) / finish (push) Has been cancelled
CI Model Inventory / build-inventory (push) Has been cancelled
Lint / lint (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark Compilation Check (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark - Manual Policy (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark - Request Processing (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark Summary (push) Has been cancelled
PR Test (SMG) / build-wheel (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on windows (x86_64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on macos (x86_64 - auto) (push) Has been cancelled
PR Test (SMG) / python-unit-tests (push) Has been cancelled
PR Test (SMG) / unit-tests (push) Has been cancelled
PR Test (SMG) / benchmarks (push) Has been cancelled
PR Test (SMG) / chat-completions (push) Has been cancelled
PR Test (SMG) / chat-completions-4gpu (push) Has been cancelled
PR Test (SMG) / e2e (push) Has been cancelled
PR Test (SMG) / docker-build-test (push) Has been cancelled
PR Test (SMG) / k8s-integration (push) Has been cancelled
PR Test (SMG) / finish (push) Has been cancelled
PR Test (SMG) / summarize-benchmarks (push) Has been cancelled
Release SGLang Model Gateway Docker Image / publish (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on macos (aarch64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (aarch64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (x86_64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (aarch64 - musllinux_1_1) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (x86_64 - musllinux_1_1) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / Build SDist (push) Has been cancelled
Release SGLang Model Gateway to PyPI / Upload to PyPI (push) Has been cancelled
Release SGLang Kernels / build-cu129-matrix (aarch64, 12.9, 3.10, arm-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / build-cu129-matrix (x86_64, 12.9, 3.10, x64-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / release-cu129 (push) Has been cancelled
Release SGLang Kernels / build-cu130-matrix (aarch64, 13.0, 3.10, arm-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / build-cu130-matrix (x86_64, 13.0, 3.10, x64-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / release-cu130 (push) Has been cancelled
Release SGLang Kernels / build-rocm-matrix (3.10, 700) (push) Has been cancelled
Release SGLang Kernels / build-rocm-matrix (3.10, 720) (push) Has been cancelled
Release SGLang Kernels / release-rocm700 (push) Has been cancelled
Release SGLang Kernels / release-rocm720 (push) Has been cancelled
Release SGLang Kernels / build-musa43 (43, 3.10) (push) Has been cancelled
Release SGLang Kernels / release-musa43 (push) Has been cancelled
PR Test (NPU) / check-changes (push) Has been cancelled
PR Test (NPU) / pr-gate (push) Has been cancelled
PR Test (NPU) / set-image-config (push) Has been cancelled
PR Test (NPU) / stage-b-test-1-npu-a2 (0) (push) Has been cancelled
PR Test (NPU) / stage-b-test-1-npu-a2 (1) (push) Has been cancelled
PR Test (NPU) / stage-b-test-2-npu-a2 (0) (push) Has been cancelled
PR Test (NPU) / stage-b-test-2-npu-a2 (1) (push) Has been cancelled
PR Test (NPU) / stage-b-test-4-npu-a3 (push) Has been cancelled
PR Test (NPU) / stage-b-test-16-npu-a3 (push) Has been cancelled
PR Test (NPU) / multimodal-gen-test-1-npu-a3 (push) Has been cancelled
PR Test (NPU) / multimodal-gen-test-2-npu-a3 (push) Has been cancelled
PR Test (Arm64) / pr-gate (push) Has been cancelled
PR Test (Arm64) / check-changes (push) Has been cancelled
PR Test (Arm64) / build-test (push) Has been cancelled
PR Test (sgl-router) / gate (push) Has been cancelled
PR Test (sgl-router) / tier-1 — lint (push) Has been cancelled
PR Test (sgl-router) / tier-2 — build + test (push) Has been cancelled
PR Test (sgl-router) / tier-3 — docker (placeholder) (push) Has been cancelled
PR Test (sgl-router) / tier-3 — k8s integration (push) Has been cancelled
PR Test (sgl-router) / tier-3 — e2e (push) Has been cancelled
PR Test (sgl-router) / finish (push) Has been cancelled
PR Test (NPU) / single-node-poc (map[name:qwen3_6_27b_w8a8_1p_in64k_out1k_50ms runner:linux-aarch64-a3-2 test_case:test/registered/ascend/performance/qwen3_6_27b/test_npu_qwen3_6_27b_w8a8_1p_in64k_out1k_50ms.py test_type:perf]) (push) Has been cancelled
PR Test (NPU) / pr-test-npu-finish (push) Has been cancelled
PR Test (Xeon) / pr-gate (push) Has been cancelled
PR Test (Xeon) / check-changes (push) Has been cancelled
PR Test (Xeon) / build-test (, xeon-gnr, base-b-test-cpu) (push) Has been cancelled
PR Test (XPU) / check-changes (push) Has been cancelled
PR Test (XPU) / pr-gate (push) Has been cancelled
PR Test (XPU) / stage-a-test-1-gpu-xpu (push) Has been cancelled
PR Test (XPU) / wait-for-stage-a (push) Has been cancelled
PR Test (XPU) / stage-b-test-1-gpu-xpu (push) Has been cancelled
PR Test (XPU) / finish (push) Has been cancelled
CI Model Inventory / build-inventory (push) Has been cancelled
Lint / lint (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark Compilation Check (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark - Manual Policy (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark - Request Processing (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark Summary (push) Has been cancelled
PR Test (SMG) / build-wheel (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on windows (x86_64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on macos (x86_64 - auto) (push) Has been cancelled
PR Test (SMG) / python-unit-tests (push) Has been cancelled
PR Test (SMG) / unit-tests (push) Has been cancelled
PR Test (SMG) / benchmarks (push) Has been cancelled
PR Test (SMG) / chat-completions (push) Has been cancelled
PR Test (SMG) / chat-completions-4gpu (push) Has been cancelled
PR Test (SMG) / e2e (push) Has been cancelled
PR Test (SMG) / docker-build-test (push) Has been cancelled
PR Test (SMG) / k8s-integration (push) Has been cancelled
PR Test (SMG) / finish (push) Has been cancelled
PR Test (SMG) / summarize-benchmarks (push) Has been cancelled
Release SGLang Model Gateway Docker Image / publish (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on macos (aarch64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (aarch64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (x86_64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (aarch64 - musllinux_1_1) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (x86_64 - musllinux_1_1) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / Build SDist (push) Has been cancelled
Release SGLang Model Gateway to PyPI / Upload to PyPI (push) Has been cancelled
Release SGLang Kernels / build-cu129-matrix (aarch64, 12.9, 3.10, arm-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / build-cu129-matrix (x86_64, 12.9, 3.10, x64-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / release-cu129 (push) Has been cancelled
Release SGLang Kernels / build-cu130-matrix (aarch64, 13.0, 3.10, arm-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / build-cu130-matrix (x86_64, 13.0, 3.10, x64-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / release-cu130 (push) Has been cancelled
Release SGLang Kernels / build-rocm-matrix (3.10, 700) (push) Has been cancelled
Release SGLang Kernels / build-rocm-matrix (3.10, 720) (push) Has been cancelled
Release SGLang Kernels / release-rocm700 (push) Has been cancelled
Release SGLang Kernels / release-rocm720 (push) Has been cancelled
Release SGLang Kernels / build-musa43 (43, 3.10) (push) Has been cancelled
Release SGLang Kernels / release-musa43 (push) Has been cancelled
This commit is contained in:
Executable
+171
@@ -0,0 +1,171 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Resolve the correct version tag for setuptools-scm.
|
||||
|
||||
Called by setuptools-scm via git_describe_command in pyproject.toml.
|
||||
Outputs either a bare tag (e.g., "v0.5.10") for exact-match commits,
|
||||
or a `git describe --long` string (e.g., "v0.5.10-2-gabcdef0") for
|
||||
untagged commits. Both formats are accepted by setuptools-scm.
|
||||
|
||||
This two-step approach avoids a strverscmp bug where
|
||||
`git tag --sort=-version:refname` sorts v0.5.10rc0 above v0.5.10,
|
||||
which would cause CI to build the wrong version.
|
||||
|
||||
Strategy:
|
||||
1. If the current commit has an exact version tag, use it directly.
|
||||
This handles CI release builds (both stable and rc).
|
||||
2. Otherwise, find the highest version tag across all branches
|
||||
and describe relative to it. This handles local dev installs
|
||||
from main where release tags only exist on release branches.
|
||||
"""
|
||||
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def parse_version_tuple(tag: str) -> tuple:
|
||||
"""Parse a version tag into a sortable tuple using PEP 440 ordering.
|
||||
|
||||
Returns a tuple where:
|
||||
- Base version parts are integers: (major, minor, patch)
|
||||
- Pre-release suffix gets a lower sort key than bare version:
|
||||
v0.5.10rc0 -> (0, 5, 10, 0, 0) # pre-release
|
||||
v0.5.10 -> (0, 5, 10, 1, 0) # stable (sorts higher)
|
||||
v0.5.10.post1 -> (0, 5, 10, 2, 1) # post-release (sorts highest)
|
||||
"""
|
||||
v = tag.lstrip("v")
|
||||
# Split base version from suffix
|
||||
m = re.match(r"^(\d+)\.(\d+)\.(\d+)(?:\.?(rc|post)(\d+))?$", v)
|
||||
if not m:
|
||||
return (0, 0, 0, 0, 0)
|
||||
major, minor, patch = int(m.group(1)), int(m.group(2)), int(m.group(3))
|
||||
suffix_type = m.group(4)
|
||||
suffix_num = int(m.group(5)) if m.group(5) else 0
|
||||
if suffix_type == "rc":
|
||||
return (major, minor, patch, 0, suffix_num)
|
||||
elif suffix_type == "post":
|
||||
return (major, minor, patch, 2, suffix_num)
|
||||
else:
|
||||
return (major, minor, patch, 1, 0)
|
||||
|
||||
|
||||
def run_git(*args: str, allow_failure: bool = False) -> str:
|
||||
"""Run a git command and return stripped stdout.
|
||||
|
||||
Args:
|
||||
allow_failure: If True, return "" on non-zero exit (expected for
|
||||
commands like --exact-match that legitimately fail).
|
||||
If False, log stderr on failure before returning "".
|
||||
"""
|
||||
try:
|
||||
result = subprocess.run(
|
||||
["git", *args],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
except OSError as exc:
|
||||
print(f"ERROR: Failed to run 'git {' '.join(args)}': {exc}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
if result.returncode != 0:
|
||||
if not allow_failure:
|
||||
stderr_msg = result.stderr.strip()
|
||||
print(
|
||||
f"WARNING: git {' '.join(args)} failed "
|
||||
f"(exit {result.returncode}): {stderr_msg}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return ""
|
||||
|
||||
return result.stdout.strip()
|
||||
|
||||
|
||||
def get_exact_version_tag() -> str:
|
||||
"""Return the version tag name if HEAD has an exact version tag, or empty string."""
|
||||
return run_git(
|
||||
"describe", "--tags", "--exact-match", "--match", "v*", allow_failure=True
|
||||
)
|
||||
|
||||
|
||||
def get_latest_version_tag_describe() -> str:
|
||||
"""Find the highest version tag and build a describe string relative to it.
|
||||
|
||||
Uses PEP 440 version ordering so that stable releases sort above
|
||||
pre-release tags (e.g., v0.5.10 > v0.5.10rc0).
|
||||
|
||||
The highest tag may live on a release branch and not be a direct
|
||||
ancestor of HEAD (e.g., main diverged before the release tag was
|
||||
created). In that case, we compute the commit distance from the
|
||||
merge-base and build the describe string manually.
|
||||
"""
|
||||
tag = get_latest_version_tag()
|
||||
if not tag:
|
||||
print("WARNING: No version tags (v*.*.*) found in repo", file=sys.stderr)
|
||||
return ""
|
||||
|
||||
# Fast path: tag is an ancestor of HEAD, git describe works directly
|
||||
result = run_git(
|
||||
"describe", "--tags", "--long", "--match", tag, "HEAD", allow_failure=True
|
||||
)
|
||||
if result:
|
||||
return result
|
||||
|
||||
# Tag is not an ancestor (e.g., release branch diverged from main).
|
||||
# Build describe string manually: {tag}-{distance}-g{hash}
|
||||
merge_base = run_git("merge-base", tag, "HEAD", allow_failure=True)
|
||||
if not merge_base:
|
||||
print(
|
||||
f"WARNING: No common ancestor between {tag} and HEAD. "
|
||||
f"Is this a shallow clone? Try: git fetch --unshallow --tags",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return ""
|
||||
distance = run_git("rev-list", "--count", f"{merge_base}..HEAD")
|
||||
short_hash = run_git("rev-parse", "--short", "HEAD")
|
||||
return f"{tag}-{distance}-g{short_hash}"
|
||||
|
||||
|
||||
def get_version_describe() -> str:
|
||||
"""Main entry point: resolve the version describe string."""
|
||||
# Prefer exact match — correct for both stable and pre-release tags
|
||||
exact = get_exact_version_tag()
|
||||
if exact:
|
||||
return exact
|
||||
|
||||
# Fallback for untagged commits (e.g., dev install from main)
|
||||
return get_latest_version_tag_describe()
|
||||
|
||||
|
||||
def get_latest_version_tag() -> str:
|
||||
"""Return just the highest version tag (PEP 440 ordered), or empty string."""
|
||||
tags_raw = run_git("tag", "--list", "v*.*.*")
|
||||
if not tags_raw:
|
||||
return ""
|
||||
tag_list = sorted(tags_raw.splitlines(), key=parse_version_tuple, reverse=True)
|
||||
return tag_list[0] if tag_list else ""
|
||||
|
||||
|
||||
def main() -> None:
|
||||
# --tag-only: print just the latest version tag (for CI scripts)
|
||||
tag_only = "--tag-only" in sys.argv
|
||||
if tag_only:
|
||||
result = get_latest_version_tag()
|
||||
else:
|
||||
result = get_version_describe()
|
||||
if not result:
|
||||
print(
|
||||
"ERROR: Could not determine version from git tags.\n"
|
||||
"Possible causes:\n"
|
||||
" - No version tags (v*.*.*) exist: run 'git fetch --tags'\n"
|
||||
" - Shallow clone without tags: run 'git fetch --unshallow --tags'\n"
|
||||
" - Git safe.directory issue: run 'git config --global --add safe.directory <repo>'\n"
|
||||
" - Not inside a git repository\n"
|
||||
"setuptools-scm will fall back to version 0.0.0.dev0",
|
||||
file=sys.stderr,
|
||||
)
|
||||
sys.exit(1)
|
||||
print(result)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user