Skip to content

Commit

Permalink
Show git commit in --version (#253)
Browse files Browse the repository at this point in the history
* Print git commit in `--version`

* Use versioneer to determine git revision

* Use `setuptools_scm`

* Fix scm version

* Fully integrate dynamic versioning

* Delete versioneer-created gitattributes file
  • Loading branch information
pederhan authored May 31, 2024
1 parent 4a35efe commit b922b50
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ wheels/
.installed.cfg
*.egg
MANIFEST
mreg_cli/_version.py

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
6 changes: 5 additions & 1 deletion mreg_cli/__about__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""Metadata about the mreg-cli package."""

from __future__ import annotations

__version__ = "1.0.0"
from importlib.metadata import version

__version__ = version("mreg-cli")
2 changes: 1 addition & 1 deletion mreg_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def main():
args = parser.parse_args()

if args.version:
print(f"mreg-cli version {__version__}")
print(f"mreg-cli {__version__}")
raise SystemExit() from None

setup_logging(args.verbosity)
Expand Down
9 changes: 5 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[build-system]
requires = ["setuptools >= 68.0"]
requires = ["setuptools >= 68.0", "setuptools_scm>=8"]
build-backend = "setuptools.build_meta"

[project]
name = "mreg-cli"
Expand Down Expand Up @@ -36,9 +37,6 @@ Repository = 'https://github.com/unioslo/mreg-cli/'
[project.scripts]
mreg-cli = "mreg_cli.main:main"

[tool.setuptools.dynamic]
version = { attr = "mreg_cli.__about__.__version__" }

[tool.setuptools.packages.find]
include = ["mreg_cli*"]

Expand Down Expand Up @@ -190,3 +188,6 @@ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
[tool.ruff.lint.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10

[tool.setuptools_scm]
version_file = "mreg_cli/_version.py"

0 comments on commit b922b50

Please sign in to comment.