mirror of
https://github.com/modelscope/FunASR
synced 2025-09-15 14:48:36 +08:00
version checker
This commit is contained in:
parent
e6b259538b
commit
1c52e364aa
@ -111,6 +111,13 @@ class AutoModel:
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
|
||||
try:
|
||||
from funasr.utils.version_checker import check_for_update
|
||||
|
||||
check_for_update()
|
||||
except:
|
||||
pass
|
||||
|
||||
log_level = getattr(logging, kwargs.get("log_level", "INFO").upper())
|
||||
logging.basicConfig(level=log_level)
|
||||
|
||||
|
||||
24
funasr/utils/version_checker.py
Normal file
24
funasr/utils/version_checker.py
Normal file
@ -0,0 +1,24 @@
|
||||
import requests
|
||||
from packaging import version
|
||||
from funasr import __version__ # Ensure that __version__ is defined in your package's __init__.py
|
||||
|
||||
|
||||
def get_pypi_version(package_name):
|
||||
url = f"https://pypi.org/pypi/{package_name}/json"
|
||||
response = requests.get(url)
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
return version.parse(data["info"]["version"])
|
||||
else:
|
||||
raise Exception("Failed to retrieve version information from PyPI.")
|
||||
|
||||
|
||||
def check_for_update():
|
||||
current_version = version.parse(__version__)
|
||||
pypi_version = get_pypi_version("funasr")
|
||||
|
||||
if current_version < pypi_version:
|
||||
print(f"New version available: {pypi_version}. Your current version is {current_version}.")
|
||||
print('Please use the command "pip install -U funasr" to upgrade.')
|
||||
else:
|
||||
print("You are using the latest version of funasr.")
|
||||
Loading…
Reference in New Issue
Block a user