From: Ole Streicher <olebole@debian.org>
Date: Sun, 6 Nov 2016 10:24:07 +0100
Subject: Use a fake relic package for version info

The original package depends on a git repository, which is not there
when we build the package from a tarball. So, we take the opportunity
to take the version info from the Debian changelog.

This requires the "python(3)-debian" package as build dependency.
---
 relic/__init__.py |  1 +
 relic/release.py  | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+)
 create mode 100644 relic/__init__.py
 create mode 100644 relic/release.py

diff --git a/relic/__init__.py b/relic/__init__.py
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/relic/__init__.py
@@ -0,0 +1 @@
+
diff --git a/relic/release.py b/relic/release.py
new file mode 100644
index 0000000..bf442e7
--- /dev/null
+++ b/relic/release.py
@@ -0,0 +1,52 @@
+from collections import namedtuple
+import datetime
+import dateutil.parser
+import os
+from debian import changelog
+
+template = """
+__all__ = [
+    '__version__',
+    '__version_short__',
+    '__version_long__',
+    '__version_post__',
+    '__version_commit__',
+    '__version_date__',
+    '__version_dirty__',
+    '__build_date__',
+    '__build_status__'
+]
+__version__ = '{pep386}'
+__version_short__ = '{short}'
+__version_long__ = '{long}'
+__version_post__ = ''
+__version_commit__ = ''
+__version_date__ = '{date}'
+__version_dirty__ = {dirty}
+__build_date__ = '{build_date}'
+__build_time__ = '{build_time}'
+__build_status__ = 'release' if not __version_dirty__ else 'development'
+"""
+
+def get_info():
+    DebVersion = namedtuple('DebVersion', ['pep386', 'short', 'long',
+                                           'date', 'dirty'])
+    with open('debian/changelog') as cl_file:
+        cl = changelog.Changelog(cl_file)
+        return DebVersion(pep386=cl.upstream_version,
+                          short=cl.upstream_version,
+                          long=cl.version,
+                          date=dateutil.parser.parse(cl.date),
+                          dirty=(cl.distributions=='UNRELEASED'))
+
+def write_template(info, module_path, filename='version.py'):
+    path = os.path.join(module_path, filename)
+    with open(path, 'w+') as f:
+        output = template.format(pep386=info.pep386,
+                                 short=info.short,
+                                 long=info.long,
+                                 date=info.date,
+                                 build_date=info.date.date(),
+                                 build_time=info.date.time(),
+                                 dirty=info.dirty)
+        f.write(output)
