test more sloted options
[tiramisu.git] / setup.py
index b425011..1ca3915 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -2,13 +2,37 @@
 # -*- coding: utf-8 -*-
 from distutils.core import setup
 
+import os
+import subprocess
+
+def fetch_version():
+    """Get version from version.in or latest git tag"""
+    version_file='version.in'
+    version = "1.0"
+    git_last_tag_cmd = ['git', 'describe', '--tags', '--abbrev=0']
+
+    try:
+        if os.path.isfile(version_file):
+            version=file(version_file).readline().strip()
+        elif os.path.isdir('.git'):
+            popen = subprocess.Popen(git_last_tag_cmd, stdout=subprocess.PIPE)
+            out, ret = popen.communicate()
+            for line in out.split('\n'):
+                if line:
+                    version = line.lstrip('release/')
+                    break
+    except OSError:
+        pass # Failing is fine, we just can't print the version then
+
+    return version
+
+
 setup(
-    author='Gwenaël Rémond',
-    author_email='gremond@cadoles.com',
+    author='cadoles team',
+    author_email='contact@cadoles.com',
     name='tiramisu',
-    version='1.0',
+    version=fetch_version(),
     description='configuration management tool',
     url='http://labs.libre-entreprise.org/projects/tiramisu',
-    package_dir = {'tiramisu':'tiramisu'},
     packages=['tiramisu']
 )