summaryrefslogtreecommitdiffstats
path: root/setup.py
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2013-05-15 13:18:35 (GMT)
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2013-05-15 13:18:35 (GMT)
commite8bd772b8c01c36149bbe6f612f2bebc9d777546 (patch)
tree42a220e6afa0be1b643017fc1c4e97309886140f /setup.py
parenta51c563a3099cb545414045602ba9f993a7b5755 (diff)
downloadeopayment-e8bd772b8c01c36149bbe6f612f2bebc9d777546.zip
eopayment-e8bd772b8c01c36149bbe6f612f2bebc9d777546.tar.gz
eopayment-e8bd772b8c01c36149bbe6f612f2bebc9d777546.tar.bz2
setup.py: import get_version function from python-entrouvert setup.py
Diffstat (limited to 'setup.py')
-rwxr-xr-xsetup.py32
1 files changed, 29 insertions, 3 deletions
diff --git a/setup.py b/setup.py
index 589875e..d63fea2 100755
--- a/setup.py
+++ b/setup.py
@@ -37,9 +37,35 @@ class TestCommand(distutils.core.Command):
t.run(tests)
def get_version():
- text = file('eopayment/__init__.py').read()
- m = re.search("__version__ = ['\"](.*)['\"]", text)
- return m.group(1)
+ 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'],
+ stdout=subprocess.PIPE)
+ result = p.communicate()[0]
+ assert p.returncode == 0, 'git returned non-zero'
+ new_version = result.split()[0]
+ assert not new_version.endswith('-dirty'), 'git workdir is not clean'
+ assert new_version.split('-')[0] == version, '__version__ must match the last git annotated tag'
+ version = new_version.replace('-', '.')
+ return version
distutils.core.setup(name='eopayment',
version=get_version(),