This is an automated email from the ASF dual-hosted git repository.

tqchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm-tirx.git


The following commit(s) were added to refs/heads/main by this push:
     new ba2310de3 [BUILD] Derive the version from git tags with setuptools-scm 
(#233)
ba2310de3 is described below

commit ba2310de3ca9607db77b369b0857f0f8d293d34b
Author: Tianqi Chen <[email protected]>
AuthorDate: Mon Nov 9 10:59:47 2026 -0500

    [BUILD] Derive the version from git tags with setuptools-scm (#233)
    
    The version was hand-edited in `pyproject.toml`, `CMakeLists.txt` and
    `libinfo.py`. It now comes from the git tag through setuptools-scm, as
    in tvm-ffi.
    
    - `pyproject.toml`: dynamic version from setuptools-scm through
    scikit-build-core; the generated `python/tvm_tirx/_version.py` is
    gitignored and shipped in the sdist.
    - `libinfo.py`: `__version__` reads `_version.py`, with a `0.0.0.dev0`
    fallback.
    - `CMakeLists.txt`: `TVM_TIRX_VERSION` comes from scikit-build-core,
    else `git describe`, else `0.1.0.dev0`; `base.h` uses the same fallback.
    - `publish_crate.yml`: the crate version is the release tag without its
    leading `v` (`vX.Y.Z`, `vX.Y.Z-rcN` or `vX.Y.Z-postN`), written into
    `Cargo.toml` after the Python metadata step.
    - `publish_wheel.yml`: PyPI publication requires `tag` to name an
    existing tag.
    - `release_process.rst`: the tag sets the version; the source tarball
    carries a `PKG-INFO` with the final version, since it has no `.git`; the
    final tag replaces the candidate tag before wheels and the crate are
    published; no post-release version bump.
---
 .github/workflows/publish_crate.yml  |  8 ++++---
 .github/workflows/publish_wheel.yml  | 19 ++++++++++++++++-
 .gitignore                           |  1 +
 CMakeLists.txt                       | 19 ++++++++++++++++-
 ci/wheel/prepare_release_metadata.py | 20 ++++++++++++++++--
 docs/dev/release_process.rst         | 41 ++++++++++++++----------------------
 include/tvm/runtime/base.h           |  7 +++---
 pyproject.toml                       |  8 ++++++-
 python/tvm_tirx/libinfo.py           |  6 +++++-
 9 files changed, 91 insertions(+), 38 deletions(-)

diff --git a/.github/workflows/publish_crate.yml 
b/.github/workflows/publish_crate.yml
index a04e0bdfe..55f469a3b 100644
--- a/.github/workflows/publish_crate.yml
+++ b/.github/workflows/publish_crate.yml
@@ -21,7 +21,7 @@ on:
   workflow_dispatch:
     inputs:
       tag:
-        description: "Tag, branch, or SHA to build"
+        description: "Release tag to build: vX.Y.Z, vX.Y.Z-rcN or vX.Y.Z-postN"
         required: true
         type: string
       wheel_run_id:
@@ -49,10 +49,11 @@ env:
   CARGO_TERM_COLOR: always
   PIP_NO_CACHE_DIR: "1"
   WHEEL_RUN_ID: ${{ inputs.wheel_run_id }}
+  RELEASE_TAG: ${{ inputs.tag }}
 
 jobs:
   # Resolve the source once, so that the commit the build jobs verify is the 
one published even
-  # when the input names a branch.
+  # if the tag moves during the run.
   check_release:
     name: Check release metadata
     runs-on: ubuntu-latest
@@ -89,7 +90,8 @@ jobs:
           TVM_FFI_VERSION: ${{ steps.ffi.outputs.version }}
         run: &prepare_release_metadata |
           uv pip install tomlkit setuptools-scm
-          python ci/wheel/prepare_release_metadata.py
+          python ci/wheel/prepare_release_metadata.py --crate-version-from-tag 
"$RELEASE_TAG"
+          echo "CRATE_VERSION=${RELEASE_TAG#v}" >> "$GITHUB_ENV"
           python ci/wheel/detect_tvm_ffi_version.py rewrite --version 
"$TVM_FFI_VERSION"
 
   build_crate:
diff --git a/.github/workflows/publish_wheel.yml 
b/.github/workflows/publish_wheel.yml
index cea3130b4..878ad9905 100644
--- a/.github/workflows/publish_wheel.yml
+++ b/.github/workflows/publish_wheel.yml
@@ -43,6 +43,22 @@ env:
   PIP_NO_CACHE_DIR: "1"
 
 jobs:
+  # The version comes from the git tag, so PyPI releases must build a tag.
+  check_release:
+    name: Check release tag
+    runs-on: ubuntu-latest
+    steps:
+      - name: Require a tag for PyPI
+        if: ${{ inputs.publish_repository == 'pypi' }}
+        shell: bash
+        env:
+          TAG: ${{ inputs.tag }}
+        run: |
+          if ! git ls-remote --exit-code --tags "https://github.com/${{ 
github.repository }}" "refs/tags/$TAG" > /dev/null; then
+            echo "::error::PyPI publishing needs a tag, got '$TAG'"
+            exit 1
+          fi
+
   # Build the CUDA runtime sidecar once per arch and upload it as an artifact 
that
   # build_wheels bundles. The Linux legs build inside the official 
manylinux_2_28
   # CUDA image (CUDA toolkit preinstalled, see pypa/manylinux) -- the same 
glibc
@@ -50,6 +66,7 @@ jobs:
   # ABI-compatible with the wheel's libtvm_runtime.so regardless of the exact 
tag.
   build_cuda_runtime:
     name: ${{ matrix.name }}
+    needs: [check_release]
     runs-on: ${{ matrix.os }}
     container: ${{ matrix.container }}
     strategy:
@@ -125,7 +142,7 @@ jobs:
     name: ${{ matrix.name }}
     # All-or-nothing: a failed sidecar leg blocks the whole wheel matrix (a 
publish
     # needs both complete wheel sets anyway).
-    needs: [build_cuda_runtime]
+    needs: [check_release, build_cuda_runtime]
     runs-on: ${{ matrix.os }}
     strategy:
       fail-fast: false
diff --git a/.gitignore b/.gitignore
index b3c8bf941..6bcd54ca8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -286,6 +286,7 @@ STATUS.md
 python/tvm_ffi/
 # Generated by setuptools_scm at build time
 python/tvm/_version.py
+python/tvm_tirx/_version.py
 python/bin/
 python/typing_extensions.py
 python/*.dist-info/
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d1b0bf195..d29305402 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -32,7 +32,24 @@ endfunction()
 
 # ######### Common options ##########
 
-set(TVM_TIRX_VERSION "0.1.0b1")
+# The version comes from the git tag: setuptools-scm under scikit-build-core, 
otherwise
+# `git describe`, otherwise a development default.
+if(DEFINED SKBUILD_PROJECT_VERSION_FULL)
+  set(TVM_TIRX_VERSION "${SKBUILD_PROJECT_VERSION_FULL}")
+else()
+  set(TVM_TIRX_VERSION "0.1.0.dev0")
+  find_package(Git QUIET)
+  if(GIT_FOUND)
+    execute_process(
+      COMMAND "${GIT_EXECUTABLE}" describe --tags --match "v[0-9]*"
+      WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+      OUTPUT_VARIABLE _tvm_tirx_git_tag OUTPUT_STRIP_TRAILING_WHITESPACE
+      RESULT_VARIABLE _tvm_tirx_git_result ERROR_QUIET)
+    if(_tvm_tirx_git_result EQUAL 0)
+      string(REGEX REPLACE "^v" "" TVM_TIRX_VERSION "${_tvm_tirx_git_tag}")
+    endif()
+  endif()
+endif()
 if(PROJECT_IS_TOP_LEVEL)
   tvm_tirx_option(TVM_TIRX_BUILD_TESTS BOOL OFF "Build C++ tests")
   tvm_tirx_option(TVM_TIRX_BUILD_PYTHON_MODULE BOOL OFF "Build the Python 
package with scikit-build-core")
diff --git a/ci/wheel/prepare_release_metadata.py 
b/ci/wheel/prepare_release_metadata.py
index 40348f78c..b5a084f4d 100644
--- a/ci/wheel/prepare_release_metadata.py
+++ b/ci/wheel/prepare_release_metadata.py
@@ -15,9 +15,14 @@
 # specific language governing permissions and limitations
 # under the License.
 
-"""Pin the optional LLVM wheel to the main wheel's resolved release version."""
+"""Pin the optional LLVM wheel to the main wheel's resolved release version.
+
+With ``--crate-version-from-tag``, also set the Rust crate version to the 
release tag
+without its leading ``v`` (``v0.1.0``, ``v0.1.0-rc0`` or ``v0.1.0-post1``).
+"""
 
 import argparse
+import re
 from pathlib import Path
 
 import tomlkit
@@ -42,7 +47,12 @@ def resolve_version(root, metadata):
 def main():
     parser = argparse.ArgumentParser(description=__doc__)
     parser.add_argument("root", nargs="?", type=Path, 
default=Path(__file__).resolve().parents[2])
-    root = parser.parse_args().root.resolve()
+    parser.add_argument("--crate-version-from-tag", metavar="TAG")
+    args = parser.parse_args()
+    tag = args.crate_version_from_tag
+    if tag is not None and not re.fullmatch(r"v\d+\.\d+\.\d+(-(rc|post)\d+)?", 
tag):
+        parser.error(f"unsupported release tag {tag!r}: expected vX.Y.Z, -rcN 
or -postN")
+    root = args.root.resolve()
     main_path = root / "pyproject.toml"
     extra_path = root / "ci/wheel/tvm-tirx-llvm-targets/pyproject.toml"
     main = tomlkit.parse(main_path.read_text(encoding="utf-8"))
@@ -61,6 +71,12 @@ def main():
     main_path.write_text(tomlkit.dumps(main), encoding="utf-8")
     extra_path.write_text(tomlkit.dumps(extra), encoding="utf-8")
     print(f"Prepared main and LLVM targets wheels at version {version}")
+    if tag is not None:
+        crate_path = root / "rust/tvm-tirx/Cargo.toml"
+        crate = tomlkit.parse(crate_path.read_text(encoding="utf-8"))
+        crate["package"]["version"] = tag[1:]
+        crate_path.write_text(tomlkit.dumps(crate), encoding="utf-8")
+        print(f"Prepared tvm-tirx crate at version {tag[1:]}")
 
 
 if __name__ == "__main__":
diff --git a/docs/dev/release_process.rst b/docs/dev/release_process.rst
index 4159dbb47..d9bca4d6a 100644
--- a/docs/dev/release_process.rst
+++ b/docs/dev/release_process.rst
@@ -40,13 +40,14 @@ Pre-release checklist (Step 0)
 ------------------------------
 
 Before running the steps below, prepare the candidate tag and release thread.
-Keep the package version consistent in ``pyproject.toml`` 
(``project.version``),
-``CMakeLists.txt`` (``TVM_TIRX_VERSION``), and ``python/tvm_tirx/libinfo.py``
-(``__version__``). Tags do not update these fields automatically.
+The tag sets the version: the candidate tag is ``vX.Y.Z-rcN`` and the final 
tag is
+``vX.Y.Z`` (``vX.Y.Z-postN`` for a post release). setuptools-scm derives the 
Python
+package version, CMake reads it from scikit-build-core or ``git describe``, 
and the
+crate publication workflow sets the crate version from the tag. No source file 
needs
+a version edit.
 
 **Step 0.1.** Tag the candidate ``$TIRX_VERSION`` on
 `GitHub <https://github.com/apache/tvm-tirx/releases/new>`__ at the reviewed 
commit.
-Use the intended package version, such as ``0.1.0``, in all three files.
 
 **Step 0.2.** Open a `release tracking issue
 <https://github.com/apache/tvm-tirx/issues/new>`__. Call the release vote once
@@ -71,6 +72,9 @@ This builds and signs the source release artifacts under
      (
        cd "$_workdir"
        git clone --recursive --branch "$_ver" 
https://github.com/apache/tvm-tirx.git "$_source_dir"
+       # The tarball has no .git; PKG-INFO gives setuptools-scm the final 
version.
+       printf 'Metadata-Version: 2.1\nName: apache-tvm-tirx\nVersion: %s\n' \
+         "${TIRX_RELEASE_VERSION#v}" > "$_source_dir/PKG-INFO"
        tar --exclude=.git --exclude=.gitignore --exclude=.gitattributes \
          --exclude=.gitmodules -czf "$_tarball" "$_source_dir"
        gpg --armor --output "$_tarball.asc" --detach-sig "$_tarball"
@@ -109,19 +113,15 @@ the result in the release thread.
 Step 2. Conclude Release
 ------------------------
 
-After the vote passes, conclude the vote, publish wheels, finalize the release
-tag, and bump the development version.
+After the vote passes, conclude the vote, tag the final release, and publish
+the wheels and the crate from it.
 
 **Step 2.1.** Announce the voting results by opening a ``[RESULT][VOTE]`` 
issue on
 the `issue tracker <https://github.com/apache/tvm-tirx/issues/new>`__.
 Issue notifications are mirrored to ``[email protected]``;
 post the result to ``[email protected]`` as well.
 
-**Step 2.2.** Publish PyPI wheels with the `publication workflow
-<https://github.com/apache/tvm-tirx/actions/workflows/publish_wheel.yml>`__.
-See :doc:`ci_cd` for how wheels are built with cibuildwheel.
-
-**Step 2.3.** Tag the approved candidate commit as the final version:
+**Step 2.2.** Tag the candidate commit as the final release and delete the 
candidate tag:
 
 .. code-block:: bash
 
@@ -131,22 +131,13 @@ See :doc:`ci_cd` for how wheels are built with 
cibuildwheel.
      git fetch upstream --tags
      git tag -a "$TIRX_RELEASE_VERSION" "${TIRX_VERSION}^{commit}" -m "Release 
$TIRX_RELEASE_VERSION"
      git push upstream "$TIRX_RELEASE_VERSION"
+     git push upstream --delete "$TIRX_VERSION"
    )
 
-Keep the candidate tag for traceability. Then create a version-bump branch and
-set all three version fields from Step 0 to the next development version
-(for example, ``0.1.1.dev0`` after ``0.1.0``):
-
-.. code-block:: bash
-
-   cd tvm-tirx-release
-   git switch -c bump-version upstream/main
-   "${EDITOR:-vi}" pyproject.toml CMakeLists.txt python/tvm_tirx/libinfo.py
-   git add pyproject.toml CMakeLists.txt python/tvm_tirx/libinfo.py
-   git commit -m "Bump development version after $TIRX_RELEASE_VERSION"
-   git push -u upstream bump-version
-
-Open a pull request for the version bump.
+**Step 2.3.** Publish the wheels and the crate: run the `wheel
+<https://github.com/apache/tvm-tirx/actions/workflows/publish_wheel.yml>`__ 
and `crate
+<https://github.com/apache/tvm-tirx/actions/workflows/publish_crate.yml>`__ 
publication
+workflows with ``tag`` set to ``$TIRX_RELEASE_VERSION``.
 
 Step 3. Upload Release Artifacts
 --------------------------------
diff --git a/include/tvm/runtime/base.h b/include/tvm/runtime/base.h
index 05b4e34e8..958d7d44c 100644
--- a/include/tvm/runtime/base.h
+++ b/include/tvm/runtime/base.h
@@ -28,11 +28,10 @@
 // we will avoid defining extra C APIs here
 #include <tvm/ffi/c_api.h>
 
-// TIRx version. Overridable at build time via -DTVM_TIRX_VERSION="..." 
(scikit-build-core
-// passes the setuptools_scm-resolved version through CMake). The literal 
below is the
-// fallback for a bare build with no override.
+// TIRx version. CMake defines it from the setuptools-scm version under 
scikit-build-core or
+// from the git tag. The literal below is the fallback for a build with no 
definition.
 #ifndef TVM_TIRX_VERSION
-#define TVM_TIRX_VERSION "0.1.0b1"
+#define TVM_TIRX_VERSION "0.1.0.dev0"
 #endif
 
 // Core runtime visibility is independent of TIRx compiler visibility.
diff --git a/pyproject.toml b/pyproject.toml
index be3369c28..4a134bed1 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -17,7 +17,7 @@
 
 [project]
 name = "apache-tvm-tirx"
-version = "0.1.0b1"
+dynamic = ["version"]
 description = "TVM TIRx"
 license = "Apache-2.0"
 license-files = ["LICENSE"]
@@ -105,6 +105,7 @@ requires = [
   "scikit-build-core>=0.11",
   "mlc-llvm-static[all]==23.1.1.post0",
   "mlc-z3-static==5.3.1.post1",
+  "setuptools-scm>=8",
 ]
 build-backend = "scikit_build_core.build"
 
@@ -112,6 +113,7 @@ build-backend = "scikit_build_core.build"
 cmake.build-type = "Release"
 wheel.py-api = "py3"
 build-dir = "build"
+metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
 
 # Wheel configuration
 install.components = ["tvm_tirx", "tvm_tirx_llvm_backend"]
@@ -126,6 +128,7 @@ sdist.include = [
   "/src/**",
   "/include/**",
   "/python/tvm_tirx/**",
+  "/python/tvm_tirx/_version.py",
   "/licenses/**",
   "/LICENSE",
   "/NOTICE",
@@ -145,6 +148,9 @@ sdist.exclude = ["**"]
 # Logging
 logging.level = "INFO"
 
+[tool.setuptools_scm]
+version_file = "python/tvm_tirx/_version.py"
+
 [tool.scikit-build.cmake.define]
 TVM_TIRX_BUILD_PYTHON_MODULE = "ON"
 TVM_TIRX_BUILD_TESTS = "OFF"
diff --git a/python/tvm_tirx/libinfo.py b/python/tvm_tirx/libinfo.py
index 0f3e2aaa0..9e04bafc8 100644
--- a/python/tvm_tirx/libinfo.py
+++ b/python/tvm_tirx/libinfo.py
@@ -94,7 +94,11 @@ def find_include_path() -> str:
     raise RuntimeError("Cannot find TVM include path.")
 
 
-__version__ = "0.1.0b1"
+try:
+    from ._version import __version__
+except ImportError:
+    # Source checkouts without a build, or this file loaded outside its 
package.
+    __version__ = "0.0.0.dev0"
 
 
 _LIBRARY_NAMES = ("tvm_tirx_compiler", "tvm_runtime")

Reply via email to