From c4c6db5a5ebea7ae2e523dd4abf21fa21dec3032 Mon Sep 17 00:00:00 2001
From: Anton Joubert <ajoubert@ska.ac.za>
Date: Fri, 20 Dec 2019 21:50:34 +0200
Subject: [PATCH] SAR-54 update setup.py to use katversion

`katversion` allows for automatic versioning based on the git status.
Tags with semantic versions are automatically picked up.

Also added some missing information to `setup.py`.
---
 README.md               |  4 ++--
 setup.py                | 10 +++++++---
 ska_logging/__init__.py | 14 +++++++++++++-
 3 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/README.md b/README.md
index bb4f94d..e15c9cc 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-SKA Logging Configuration
-=========================
+SKA Logging Configuration Library
+=================================
 
 [![Documentation Status](https://readthedocs.org/projects/ska-logging/badge/?version=latest)](https://developer.skatelescope.org/projects/ska-logging/en/latest/?badge=latest)
 
diff --git a/setup.py b/setup.py
index 0b0484f..306618d 100644
--- a/setup.py
+++ b/setup.py
@@ -8,8 +8,7 @@ with open("README.md") as readme_file:
 
 setup(
     name="ska_logging",
-    version="0.1.0",
-    description="",
+    description="Square Kilometre Array logging configuration library",
     long_description=readme + "\n\n",
     author="Anton Joubert",
     author_email="ajoubert+ska@ska.ac.za",
@@ -29,17 +28,22 @@ setup(
         "Programming Language :: Python :: 3.6",
         "Programming Language :: Python :: 3.7",
         "Programming Language :: Python :: 3.8",
+        "Topic :: Software Development :: Libraries :: Python Modules",
+        "Topic :: Scientific/Engineering :: Astronomy",
     ],
     python_requires=">=3.5",
     test_suite="tests",
     install_requires=[],
     setup_requires=[
+        # dependency for automatic git-based version
+        "katversion",
         # dependency for `python setup.py test`
         "pytest-runner",
         # dependencies for `python setup.py build_sphinx`
         "sphinx",
         "recommonmark",
     ],
+    use_katversion=True,
     tests_require=["pytest", "pytest-cov", "pytest-json-report", "pycodestyle"],
-    extras_require={"dev": ["prospector[with_pyroma]", "yapf", "isort"]},
+    extras_require={"dev": ["prospector[with_pyroma]", "black", "isort"]},
 )
diff --git a/ska_logging/__init__.py b/ska_logging/__init__.py
index c781de4..f90d3da 100644
--- a/ska_logging/__init__.py
+++ b/ska_logging/__init__.py
@@ -3,9 +3,21 @@
 """Module init code."""
 
 __all__ = ("configure_logging",)
-__version__ = "0.1.0"
 __author__ = "Anton Joubert"
 __email__ = "ajoubert+ska@ska.ac.za"
 
 
 from .configuration import configure_logging
+
+
+# BEGIN VERSION CHECK
+# Get package version when locally imported from repo or via -e develop install
+try:
+    import katversion as _katversion
+except ImportError:  # pragma: no cover
+    import time as _time
+
+    __version__ = "0.0+unknown.{}".format(_time.strftime("%Y%m%d%H%M"))
+else:  # pragma: no cover
+    __version__ = _katversion.get_version(__path__[0])
+# END VERSION CHECK
-- 
GitLab