"nndet/csrc/vscode:/vscode.git/clone" did not exist on "68352e5cce884bf72455ca9cc9119445ca44b3f1"
te_version.py 1.09 KB
Newer Older
1
2
3
4
5
6
7
8
9
# Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# See LICENSE for license information.

"""Transformer Engine version string."""
import os
from pathlib import Path
import subprocess

10

11
12
13
14
15
16
17
18
def te_version() -> str:
    """Transformer Engine version string

    Includes Git commit as local version, unless suppressed with
    NVTE_NO_LOCAL_VERSION environment variable.

    """
    root_path = Path(__file__).resolve().parent
19
    with open(root_path / "VERSION.txt", "r") as f:
20
        version = f.readline().strip()
21
22
23
    if not int(os.getenv("NVTE_NO_LOCAL_VERSION", "0")) and not bool(
        int(os.getenv("NVTE_RELEASE_BUILD", "0"))
    ):
24
25
        try:
            output = subprocess.run(
26
                ["git", "rev-parse", "--short", "HEAD"],
27
28
29
30
31
32
33
34
35
36
37
                capture_output=True,
                cwd=root_path,
                check=True,
                universal_newlines=True,
            )
        except (subprocess.CalledProcessError, OSError):
            pass
        else:
            commit = output.stdout.strip()
            version += f"+{commit}"
    return version