summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2014-03-13 12:42:10 (GMT)
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2014-03-13 12:42:10 (GMT)
commitd097509b3f46f5780cf3c72bbca782304c81e479 (patch)
treee60a0b214a5648a84233dc22251eeea0186de442
parent0aa81a9b2e270f73554995072ad1d709a9bc6b6c (diff)
downloadauthentic2-idp-cas-1.0.zip
authentic2-idp-cas-1.0.tar.gz
authentic2-idp-cas-1.0.tar.bz2
setup.py: use get_versionv1.0
-rw-r--r--authentic2_idp_cas/__init__.py1
-rwxr-xr-xsetup.py32
2 files changed, 32 insertions, 1 deletions
diff --git a/authentic2_idp_cas/__init__.py b/authentic2_idp_cas/__init__.py
index ae88d52..575a7f0 100644
--- a/authentic2_idp_cas/__init__.py
+++ b/authentic2_idp_cas/__init__.py
@@ -1,6 +1,7 @@
from django.utils.timezone import now
from django.template.loader import render_to_string
+__version__ = '1.0'
class Plugin(object):
def get_before_urls(self):
diff --git a/setup.py b/setup.py
index 71b60cc..2fa8c01 100755
--- a/setup.py
+++ b/setup.py
@@ -2,8 +2,38 @@
from setuptools import setup, find_packages
import os
+def get_version():
+ import glob
+ import re
+ import os
+
+ version = None
+ for d in glob.glob('*'):
+ if not os.path.isdir(d):
+ continue
+ module_file = os.path.join(d, '__init__.py')
+ if not os.path.exists(module_file):
+ continue
+ for v in re.findall("""__version__ *= *['"](.*)['"]""",
+ open(module_file).read()):
+ assert version is None
+ version = v
+ if version:
+ break
+ assert version is not None
+ if os.path.exists('.git'):
+ import subprocess
+ p = subprocess.Popen(['git','describe','--dirty','--match=v*'],
+ stdout=subprocess.PIPE)
+ result = p.communicate()[0]
+ assert p.returncode == 0, 'git returned non-zero'
+ new_version = result.split()[0][1:]
+ assert new_version.split('-')[0] == version, '__version__ must match the last git annotated tag'
+ version = new_version.replace('-', '.')
+ return version
+
setup(name='authentic2-idp-cas',
- version='1.0',
+ version=get_version(),
license='AGPLv3',
description='Authentic2 IdP CAS',
author="Entr'ouvert",