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

Improve version handling #1931

Merged
merged 1 commit into from
Feb 18, 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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ pip-wheel-metadata
# .cache is used by progressive mode
.cache

# Generated by setuptools-scm
src/ansiblelint/_version.py

# other
.DS_Store
.vscode
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ profile = "black"

[tool.setuptools_scm]
local_scheme = "no-local-version"
write_to = "src/ansiblelint/_version.py"
15 changes: 8 additions & 7 deletions src/ansiblelint/version.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
"""Ansible-lint version information."""

try:
import pkg_resources
from ._version import version as __version__ # type: ignore
except ImportError:
pass

try:
import pkg_resources

try:
__version__ = pkg_resources.get_distribution("ansible-lint").version
except Exception:
__version__ = "unknown"
__version__ = pkg_resources.get_distribution("ansible-lint").version
except Exception:
__version__ = "unknown"

__all__ = ("__version__",)