Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add alternative way to retrieve version number from pyproject.toml #531

Merged
merged 4 commits into from Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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