setup.py: use our own get_version()

This commit is contained in:
Benjamin Dauvergne 2016-03-16 13:42:24 +01:00 committed by Frédéric Péters
parent b3914c84cf
commit 08bfb7515e
1 changed files with 22 additions and 3 deletions

View File

@ -1,17 +1,36 @@
#!/usr/bin/env python
import os
import subprocess
from os.path import exists
from version import get_git_version
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
def get_version():
'''Use the VERSION, if absent generates a version with git describe, if not
tag exists, take 0.0.0- and add the length of the commit log.
'''
if os.path.exists('VERSION'):
with open('VERSION', 'r') as v:
return v.read()
if os.path.exists('.git'):
p = subprocess.Popen(['git', 'describe', '--dirty', '--match=v*'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
result = p.communicate()[0]
if p.returncode == 0:
result = result.split()[0][1:]
else:
result = '0.0.0-%s' % len(subprocess.check_output(
['git', 'rev-list', 'HEAD']).splitlines())
return result.replace('-', '.').replace('.g', '+g')
return '0.0.0'
setup(
name='django-tenant-schemas',
version=get_git_version(),
version=get_version(),
author='Bernardo Pires Carneiro',
author_email='carneiro.be@gmail.com',
packages=[