From c5f5262a96dae49bab3653499f0f12726fe46b16 Mon Sep 17 00:00:00 2001 From: j Date: Sun, 15 Nov 2015 14:52:59 +0100 Subject: [PATCH] get version from git --- .bzrignore | 4 ---- setup.py | 13 ++++++++----- 2 files changed, 8 insertions(+), 9 deletions(-) delete mode 100644 .bzrignore diff --git a/.bzrignore b/.bzrignore deleted file mode 100644 index 9620ab1..0000000 --- a/.bzrignore +++ /dev/null @@ -1,4 +0,0 @@ -build -dist -oxutils.egg-info -ox/__version.py diff --git a/setup.py b/setup.py index 12567dc..112ceff 100644 --- a/setup.py +++ b/setup.py @@ -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: