(feat) add --version to cli (#3924)

This commit is contained in:
tobitege
2024-09-18 15:44:51 +02:00
committed by GitHub
parent f7ebc1cf1f
commit c3117e8c39
3 changed files with 61 additions and 2 deletions

View File

@@ -0,0 +1,28 @@
def get_version():
try:
from importlib.metadata import PackageNotFoundError, version
try:
return version('openhands-ai')
except PackageNotFoundError:
pass
except ImportError:
pass
try:
from pkg_resources import DistributionNotFound, get_distribution
try:
return get_distribution('openhands-ai').version
except DistributionNotFound:
pass
except ImportError:
pass
return 'unknown'
try:
__version__ = get_version()
except Exception:
__version__ = 'unknown'