Skip to content

Commit

Permalink
Merge pull request #531 from python-rope/fix-python-mode
Browse files Browse the repository at this point in the history
Add alternative way to retrieve version number from pyproject.toml
  • Loading branch information
lieryan committed Nov 25, 2022
2 parents c402fb2 + abdfe0b commit f11e18a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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)
Expand Down
19 changes: 17 additions & 2 deletions 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
Expand Down

0 comments on commit f11e18a

Please sign in to comment.