setup.py: use get_version
This commit is contained in:
parent
810fcb5039
commit
e3e1fea51b
|
@ -1,3 +1,5 @@
|
||||||
|
__version__ = '1.0'
|
||||||
|
|
||||||
class Plugin(object):
|
class Plugin(object):
|
||||||
def get_before_urls(self):
|
def get_before_urls(self):
|
||||||
from . import urls
|
from . import urls
|
||||||
|
|
32
setup.py
32
setup.py
|
@ -4,8 +4,38 @@
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
import os
|
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-ltpa',
|
setup(name='authentic2-idp-ltpa',
|
||||||
version='1.0',
|
version=get_version(),
|
||||||
license='AGPLv3',
|
license='AGPLv3',
|
||||||
description='Authentic2 IdP LTPA',
|
description='Authentic2 IdP LTPA',
|
||||||
author="Entr'ouvert",
|
author="Entr'ouvert",
|
||||||
|
|
Reference in New Issue