Commit 0a017e5c authored by xiabo's avatar xiabo
Browse files

版本号修改

parent 40e07381
# Copyright (c) OpenMMLab. All rights reserved. # Copyright (c) OpenMMLab. All rights reserved.
from .version import *
def bootstrap(): def bootstrap():
import os import os
import sys import sys
......
# Copyright (c) OpenMMLab. All rights reserved. # Copyright (c) OpenMMLab. All rights reserved.
from typing import Tuple from typing import Tuple
__dcu_version__ = '0.0.13'
__version__ = '0.0.13' __version__ = '0.0.13'
short_version = __version__ short_version = __version__
...@@ -27,4 +27,4 @@ def parse_version_info(version_str: str) -> Tuple: ...@@ -27,4 +27,4 @@ def parse_version_info(version_str: str) -> Tuple:
version_info = parse_version_info(__version__) version_info = parse_version_info(__version__)
__all__ = ['__version__', 'version_info', 'parse_version_info'] __all__ = ['__version__', '__dcu_version__', 'version_info', 'parse_version_info']
...@@ -4,6 +4,11 @@ import sys ...@@ -4,6 +4,11 @@ import sys
from setuptools import find_packages, setup from setuptools import find_packages, setup
import subprocess
from typing import Optional, Union
from pathlib import Path
import torch
pwd = os.path.dirname(__file__) pwd = os.path.dirname(__file__)
version_file = 'lmdeploy/version.py' version_file = 'lmdeploy/version.py'
...@@ -14,10 +19,63 @@ def readme(): ...@@ -14,10 +19,63 @@ def readme():
return content return content
def get_sha(pytorch_root: Union[str, Path]) -> str:
try:
return subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=pytorch_root).decode('ascii').strip()
except Exception:
return 'Unknown'
def get_abi():
try:
command = "echo '#include <string>' | gcc -x c++ -E -dM - | fgrep _GLIBCXX_USE_CXX11_ABI"
result = subprocess.run(command, shell=True, capture_output=True, text=True)
output = result.stdout.strip()
abi = "abi" + output.split(" ")[-1]
return abi
except Exception:
return 'abiUnknown'
def get_version_add(sha: Optional[str] = None) -> str:
version=''
lmdeploy_root = os.path.dirname(os.path.abspath(__file__))
add_version_path = os.path.join(os.path.join(lmdeploy_root, "lmdeploy"), "version.py")
if sha != 'Unknown':
if sha is None:
sha = get_sha(lmdeploy_root)
version = 'git' + sha[:7]
# abi
version += "." + get_abi()
# dtk version
if os.getenv("ROCM_PATH"):
rocm_path = os.getenv('ROCM_PATH', "")
rocm_version_path = os.path.join(rocm_path, '.info', "rocm_version")
with open(rocm_version_path, 'r',encoding='utf-8') as file:
lines = file.readlines()
rocm_version=lines[0][:-2].replace(".", "")
version += ".dtk" + rocm_version
# torch version
version += ".torch" + torch.__version__[:4]
lines=[]
with open(add_version_path, 'r',encoding='utf-8') as file:
lines = file.readlines()
lines[2] = "__dcu_version__ = '0.0.13+{}'\n".format(version)
with open(add_version_path, encoding="utf-8",mode="w") as file:
file.writelines(lines)
file.close()
def get_version(): def get_version():
with open(os.path.join(pwd, version_file), 'r') as f: get_version_add()
version_file = 'lmdeploy/version.py'
with open(version_file, encoding='utf-8') as f:
exec(compile(f.read(), version_file, 'exec')) exec(compile(f.read(), version_file, 'exec'))
return locals()['__version__'] return locals()['__dcu_version__']
def check_ext_modules(): def check_ext_modules():
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment