get version from git

This commit is contained in:
j 2015-11-15 14:52:59 +01:00
parent 98d83192ce
commit c5f5262a96
2 changed files with 8 additions and 9 deletions

View file

@ -1,4 +0,0 @@
build
dist
oxutils.egg-info
ox/__version.py

View file

@ -1,21 +1,24 @@
#!/usr/bin/env python
# vi:si:et:sw=4:sts=4:ts=4
# encoding: utf-8
try:
from setuptools import setup
except:
from distutils.core import setup
def get_revision():
import subprocess
return subprocess.check_output(['git', 'rev-list', 'HEAD', '--count']).strip()
def get_version():
import os
import re
info = os.path.join(os.path.dirname(__file__), '.bzr/branch/last-revision')
_git = os.path.join(os.path.dirname(__file__), '.git')
__version = os.path.join(os.path.dirname(__file__), 'ox/__version.py')
changelog = os.path.join(os.path.dirname(__file__), 'debian/changelog')
if os.path.exists(info):
f = open(info)
rev = int(f.read().split()[0])
f.close()
if os.path.exists(_git):
rev = get_revision()
if rev:
version = "2.3.%d" % rev
with open(__version, 'w') as fd: