From 029d0185cd44f9728b538ea3fc6c529d04fbd6d5 Mon Sep 17 00:00:00 2001
From: Tamas Gal <tgal@km3net.de>
Date: Wed, 26 Feb 2020 12:28:14 +0100
Subject: [PATCH] Add version management

---
 docs/conf.py   | 6 ++++--
 pyproject.toml | 3 +++
 setup.py       | 4 +---
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/docs/conf.py b/docs/conf.py
index aca5f67..131090f 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -15,6 +15,8 @@
 import sys
 import os
 
+import jppy
+
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
 # documentation root, use os.path.abspath to make it absolute, like shown here.
@@ -61,9 +63,9 @@ author = u'Tamas Gal'
 # built documents.
 #
 # The short X.Y version.
-version = u'3.0.0'
+version = jppy.version
 # The full version, including alpha/beta/rc tags.
-release = u'3.0.0'
+release = ujppy.version
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
diff --git a/pyproject.toml b/pyproject.toml
index 51000e4..a0a6409 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,2 +1,5 @@
 [build-system]
 requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"]
+
+[tool.setuptools_scm]
+write_to = "jppy/version.py"
diff --git a/setup.py b/setup.py
index 063f36e..2251eca 100644
--- a/setup.py
+++ b/setup.py
@@ -5,8 +5,6 @@ import sys
 import setuptools
 import subprocess as sp
 
-__version__ = '3.0.0'
-
 
 class get_pybind_include(object):
     """Helper class to determine the pybind11 include path
@@ -50,6 +48,7 @@ ext_modules = [
 # Populating the __init__.py with submodule imports, so that one can import
 # the package and use the submodules directly with the dot-sytax.
 with open("jppy/__init__.py", "w") as fobj:
+    fobj.write("from .version import version\n")
     for module in ext_modules:
         fobj.write("from . import {}\n".format(module.name.split('.')[1]))
 
@@ -128,7 +127,6 @@ class BuildExt(build_ext):
 
 setup(
     name='jppy',
-    version=__version__,
     author='Tamas Gal',
     author_email='tgal@km3net.de',
     url='https://git.km3net.de/km3py/jppy',
-- 
GitLab