diff --git a/CHANGELOG.md b/CHANGELOG.md index 73ad00d12..44743a397 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ - ... +# Release 1.5.1 +- #531 Add alternative way to retrieve version number from pyproject.toml + # Release 1.5.0 - #492 Feat: Global configuration support (@bagel897) diff --git a/rope/__init__.py b/rope/__init__.py index 489396cd1..f0bacd6d0 100644 --- a/rope/__init__.py +++ b/rope/__init__.py @@ -1,10 +1,25 @@ """rope, a python refactoring library""" -from pkg_resources import get_distribution +from pkg_resources import get_distribution, DistributionNotFound + +try: + VERSION = get_distribution("rope").version +except DistributionNotFound: + + def get_fallback_version(): + import re + import pathlib + + pyproject = ( + pathlib.Path(__file__).resolve().parent.parent / "pyproject.toml" + ).read_text() + version = re.search("version.*=.*'(.*)'", pyproject) + return version.group(1) if version else None + + VERSION = get_fallback_version() INFO = __doc__ -VERSION = get_distribution("rope").version COPYRIGHT = """\ Copyright (C) 2021-2022 Lie Ryan Copyright (C) 2019-2021 Matej Cepl