Add version available at runtime
authorunknown <kimgr@WSAB101310.eur.gad.schneider-electric.com>
Tue, 2 Feb 2016 20:31:48 +0000 (21:31 +0100)
committerunknown <kimgr@WSAB101310.eur.gad.schneider-electric.com>
Tue, 2 Feb 2016 20:31:48 +0000 (21:31 +0100)
asn1ate.__version__ will now contain the package version.
setup.py pulls it from there with a technique described in:
http://python-packaging-user-guide.readthedocs.org/en/latest/single_source_version/

asn1ate/__init__.py
setup.py

index e69de29..63a563f 100644 (file)
@@ -0,0 +1,3 @@
+\r
+# asn1ate version\r
+__version__ = '0.5.1.dev'\r
index b2c6e77..1b37da9 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -1,14 +1,27 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
+import os
 try:
     from setuptools import setup
 except:
     from distutils.core import setup
 
+
+def get_version():
+    version_file = os.path.join(os.path.dirname(__file__),
+                                'asn1ate', '__init__.py')
+
+    environment = {}
+    with open(version_file) as fp:
+        exec(fp.read(), environment)
+
+    return environment['__version__']
+
+
 setup(
     name='asn1ate',
-    version='0.5.1.dev',
+    version=get_version(),
     description='ASN.1 translation library.',
     author='Kim Gräsman',
     author_email='kim.grasman@gmail.com',