Skip to content

Commit

Permalink
Prioritize version from pyproject.toml (#5412)
Browse files Browse the repository at this point in the history
  • Loading branch information
tofarr authored Dec 4, 2024
1 parent 794408c commit ceb60b9
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions openhands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@


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

Expand All @@ -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'


Expand Down

0 comments on commit ceb60b9

Please sign in to comment.