From ceb60b9a37d669a51945710ae036e7fc428dc7e9 Mon Sep 17 00:00:00 2001 From: tofarr Date: Wed, 4 Dec 2024 13:34:07 -0700 Subject: [PATCH] Prioritize version from pyproject.toml (#5412) --- openhands/__init__.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/openhands/__init__.py b/openhands/__init__.py index 4b918466a4..eda56824e3 100644 --- a/openhands/__init__.py +++ b/openhands/__init__.py @@ -4,6 +4,16 @@ __package_name__ = 'openhands_ai' def get_version(): + # Try getting the version from pyproject.toml + try: + root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + with open(os.path.join(root_dir, 'pyproject.toml'), 'r') as f: + for line in f: + if line.startswith('version ='): + return line.split('=')[1].strip().strip('"') + except FileNotFoundError: + pass + try: from importlib.metadata import PackageNotFoundError, version @@ -18,16 +28,6 @@ def get_version(): except (ImportError, DistributionNotFound): pass - # Try getting the version from pyproject.toml - try: - root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - with open(os.path.join(root_dir, 'pyproject.toml'), 'r') as f: - for line in f: - if line.startswith('version ='): - return line.split('=')[1].strip().strip('"') - except FileNotFoundError: - pass - return 'unknown'