fix(version): do not lookup parent .git for git version detection

This commit is contained in:
Xuehai Pan 2025-05-19 18:43:53 +08:00
parent af416db5d1
commit cd0eb7e476
3 changed files with 19 additions and 7 deletions

View file

@ -12,7 +12,6 @@ insert_final_newline = true
[*.py]
indent_size = 4
src_paths=nvitop
[*.{yaml,yml,json,xml}]
indent_size = 2

View file

@ -28,11 +28,17 @@ if not __release__:
import os
import subprocess
root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
try:
prefix, sep, suffix = (
subprocess.check_output( # noqa: S603
['git', 'describe', '--abbrev=7'], # noqa: S607
cwd=os.path.dirname(os.path.abspath(__file__)),
[ # noqa: S607
'git',
f'--git-dir={os.path.join(root_dir, ".git")}',
'describe',
'--abbrev=7',
],
cwd=root_dir,
stderr=subprocess.DEVNULL,
text=True,
)
@ -53,4 +59,4 @@ if not __release__:
except (OSError, subprocess.CalledProcessError):
pass
del os, subprocess
del os, subprocess, root_dir

View file

@ -28,11 +28,17 @@ if not __release__:
import os
import subprocess
root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
try:
prefix, sep, suffix = (
subprocess.check_output( # noqa: S603
['git', 'describe', '--abbrev=7'], # noqa: S607
cwd=os.path.dirname(os.path.abspath(__file__)),
[ # noqa: S607
'git',
f'--git-dir={os.path.join(root_dir, ".git")}',
'describe',
'--abbrev=7',
],
cwd=root_dir,
stderr=subprocess.DEVNULL,
text=True,
)
@ -53,7 +59,8 @@ if not __release__:
except (OSError, subprocess.CalledProcessError):
pass
del os, subprocess
del os, subprocess, root_dir
# The package `nvidia-ml-py` is not backward compatible over releases. This may
# cause problems with Old versions of NVIDIA drivers.